case-xml@1 - Add example+assertions of new activity-type
authorTim Otten <totten@civicrm.org>
Thu, 7 Jul 2022 03:12:03 +0000 (20:12 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 7 Jul 2022 03:40:48 +0000 (20:40 -0700)
mixin/case-xml@1/example/tests/mixin/CaseTypeTest.php
mixin/case-xml@1/example/xml/case/DuckDance.xml

index 326a083c9b80e7131c2f8220e5a9c53344d80a78..099a364d3bc768e32bfe9431d181f229927a9d2c 100644 (file)
@@ -23,6 +23,16 @@ class CaseTypeTest extends \PHPUnit\Framework\Assert {
     $this->assertEquals('Duck Dance Case', $items[0]['title']);
     $this->assertEquals(TRUE, $items[0]['is_active']);
     $this->assertEquals(1, count($items));
+
+    // FIXME: This flush should be unnecessary. The fact that we need it indicates a bug during activation.
+    // However, the bug is pre-existing, and adding these assertions will ensure that it doesn't get worse.
+    $cv->api3('System', 'flush', []);
+
+    $actTypes = $cv->api4('OptionValue', 'get', [
+      'where' => [['option_group_id:name', '=', 'activity_type'], ['name', '=', 'Quack']],
+    ]);
+    $this->assertEquals('Quack', $actTypes[0]['name'], 'ActivityType "Quack" should be auto enabled. It\'s missing.');
+    $this->assertEquals(TRUE, $actTypes[0]['is_active'], 'ActivityType "Quack" should be auto enabled. It\'s inactive.');
   }
 
   public function testDisabled($cv) {
@@ -37,6 +47,11 @@ class CaseTypeTest extends \PHPUnit\Framework\Assert {
   public function testUninstalled($cv) {
     $items = $cv->api4('CaseType', 'get', ['where' => [['name', '=', 'DuckDance']]]);
     $this->assertEquals(0, count($items));
+
+    $actTypes = $cv->api4('OptionValue', 'get', [
+      'where' => [['option_group_id:name', '=', 'activity_type'], ['name', '=', 'Quack']],
+    ]);
+    $this->assertEmpty($actTypes);
   }
 
   protected static function getPath($suffix = ''): string {
index 7bbf1783715f02bafba6f9a93143d8078406fa9f..6e02fb9d5ec71f5824b4c7c1b2ec2a91d58dd71f 100644 (file)
@@ -35,6 +35,9 @@
     <ActivityType>
       <name>Phone Call</name>
     </ActivityType>
+    <ActivityType>
+      <name>Quack</name>
+    </ActivityType>
 
   </ActivityTypes>