CiviGrant - Don't auto-create any grant types
authorColeman Watts <coleman@civicrm.org>
Tue, 8 Mar 2022 13:51:41 +0000 (08:51 -0500)
committerColeman Watts <coleman@civicrm.org>
Wed, 9 Mar 2022 14:38:37 +0000 (09:38 -0500)
CRM/Upgrade/Incremental/php/FiveFortySeven.php
CRM/Upgrade/Incremental/sql/5.48.beta1.mysql.tpl
ext/civigrant/managed/OptionGroup_grant_type.mgd.php
ext/civigrant/tests/phpunit/api/v3/GrantTest.php

index fa47928b1516f7fa5bb5ed52b46fd7e6a4dd7cf2..ff2204c8c8f09dce5b00be559224d63c5906a21a 100644 (file)
@@ -213,34 +213,6 @@ class CRM_Upgrade_Incremental_php_FiveFortySeven extends CRM_Upgrade_Incremental
             'name' => 'grant_type',
           ],
         ],
-        'OptionGroup_grant_type_OptionValue_Emergency' => [
-          'entity' => 'OptionValue',
-          'values' => [
-            'option_group_id:name' => 'grant_type',
-            'name' => 'Emergency',
-          ],
-        ],
-        'OptionGroup_grant_type_OptionValue_Family Support' => [
-          'entity' => 'OptionValue',
-          'values' => [
-            'option_group_id:name' => 'grant_type',
-            'name' => 'Family Support',
-          ],
-        ],
-        'OptionGroup_grant_type_OptionValue_General Protection' => [
-          'entity' => 'OptionValue',
-          'values' => [
-            'option_group_id:name' => 'grant_type',
-            'name' => 'General Protection',
-          ],
-        ],
-        'OptionGroup_grant_type_OptionValue_Impunity' => [
-          'entity' => 'OptionValue',
-          'values' => [
-            'option_group_id:name' => 'grant_type',
-            'name' => 'Impunity',
-          ],
-        ],
         'OptionGroup_report_template_OptionValue_CRM_Report_Form_Grant_Detail' => [
           'entity' => 'OptionValue',
           'values' => [
index acba8b0a9c56b04dcc4c64128df0f11a081c09be..6583c67b02b2159ee5d5a0735b46e5b5c4e2d1c3 100644 (file)
@@ -2,3 +2,6 @@
 
 -- Remove entry for Grant Reports since grant is not a component anymore so this url just shows an empty list
 DELETE FROM civicrm_navigation WHERE url='civicrm/report/list?compid=5&reset=1';
+
+DELETE FROM civicrm_managed WHERE module = "civigrant" AND entity_type = "OptionValue"
+AND name LIKE "OptionGroup_grant_type_%";
index 8c98381b9a9f42229470720052e1ecd97d637d5a..4f1ccf826bea4044f872f147a743c5d07ab01278 100644 (file)
@@ -18,116 +18,4 @@ return [
       ],
     ],
   ],
-  [
-    'name' => 'OptionGroup_grant_type_OptionValue_Emergency',
-    'entity' => 'OptionValue',
-    'cleanup' => 'unused',
-    'update' => 'unmodified',
-    'params' => [
-      'version' => 4,
-      'values' => [
-        'option_group_id.name' => 'grant_type',
-        'label' => 'Emergency',
-        'value' => '1',
-        'name' => 'Emergency',
-        'grouping' => NULL,
-        'filter' => 0,
-        'is_default' => TRUE,
-        'weight' => 1,
-        'description' => NULL,
-        'is_optgroup' => FALSE,
-        'is_reserved' => FALSE,
-        'is_active' => TRUE,
-        'icon' => NULL,
-        'color' => NULL,
-        'component_id' => NULL,
-        'visibility_id' => NULL,
-        'domain_id' => 'current_domain',
-      ],
-    ],
-  ],
-  [
-    'name' => 'OptionGroup_grant_type_OptionValue_Family Support',
-    'entity' => 'OptionValue',
-    'cleanup' => 'unused',
-    'update' => 'unmodified',
-    'params' => [
-      'version' => 4,
-      'values' => [
-        'option_group_id.name' => 'grant_type',
-        'label' => 'Family Support',
-        'value' => '2',
-        'name' => 'Family Support',
-        'grouping' => NULL,
-        'filter' => 0,
-        'is_default' => FALSE,
-        'weight' => 2,
-        'description' => NULL,
-        'is_optgroup' => FALSE,
-        'is_reserved' => FALSE,
-        'is_active' => TRUE,
-        'icon' => NULL,
-        'color' => NULL,
-        'component_id' => NULL,
-        'visibility_id' => NULL,
-        'domain_id' => 'current_domain',
-      ],
-    ],
-  ],
-  [
-    'name' => 'OptionGroup_grant_type_OptionValue_General Protection',
-    'entity' => 'OptionValue',
-    'cleanup' => 'unused',
-    'update' => 'unmodified',
-    'params' => [
-      'version' => 4,
-      'values' => [
-        'option_group_id.name' => 'grant_type',
-        'label' => 'General Protection',
-        'value' => '3',
-        'name' => 'General Protection',
-        'grouping' => NULL,
-        'filter' => 0,
-        'is_default' => FALSE,
-        'weight' => 3,
-        'description' => NULL,
-        'is_optgroup' => FALSE,
-        'is_reserved' => FALSE,
-        'is_active' => TRUE,
-        'icon' => NULL,
-        'color' => NULL,
-        'component_id' => NULL,
-        'visibility_id' => NULL,
-        'domain_id' => 'current_domain',
-      ],
-    ],
-  ],
-  [
-    'name' => 'OptionGroup_grant_type_OptionValue_Impunity',
-    'entity' => 'OptionValue',
-    'cleanup' => 'unused',
-    'update' => 'unmodified',
-    'params' => [
-      'version' => 4,
-      'values' => [
-        'option_group_id.name' => 'grant_type',
-        'label' => 'Impunity',
-        'value' => '4',
-        'name' => 'Impunity',
-        'grouping' => NULL,
-        'filter' => 0,
-        'is_default' => FALSE,
-        'weight' => 4,
-        'description' => NULL,
-        'is_optgroup' => FALSE,
-        'is_reserved' => FALSE,
-        'is_active' => TRUE,
-        'icon' => NULL,
-        'color' => NULL,
-        'component_id' => NULL,
-        'visibility_id' => NULL,
-        'domain_id' => 'current_domain',
-      ],
-    ],
-  ],
 ];
index bf4dfd34d0d64109020fee348dca15d167872776..c48c579770f77fe3c032372a473c43674ef2ab2e 100644 (file)
  * @subpackage API_Grant
  * @group headless
  */
-class api_v3_GrantTest extends \PHPUnit\Framework\TestCase implements \Civi\Test\HeadlessInterface {
+class api_v3_GrantTest extends \PHPUnit\Framework\TestCase implements \Civi\Test\HeadlessInterface, \Civi\Test\TransactionalInterface {
   use \Civi\Test\Api3TestTrait;
   use \Civi\Test\ContactTestTrait;
 
-
   protected $_apiversion = 3;
   protected $params;
   protected $ids = [];
@@ -48,6 +47,14 @@ class api_v3_GrantTest extends \PHPUnit\Framework\TestCase implements \Civi\Test
       'currency' => 'USD',
       'grant_type_id' => 1,
     ];
+    // Create a sample grant type
+    \CRM_Core_BAO_OptionValue::ensureOptionValueExists([
+      'option_group_id' => 'grant_type',
+      'label' => 'Emergency',
+      'name' => 'Emergency',
+      'value' => 1,
+      'is_active' => 1,
+    ]);
   }
 
   /**