Merge pull request #11735 from mukeshcompucorp/CRM-21814-add-proper-container-to...
[civicrm-core.git] / tests / phpunit / api / v3 / ExtensionTest.php
index bb04b2a7175b3d80d1b99598627c82e04dab0382..c208db048a27020090b2861811522127104ad595 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017                                |
+ | Copyright CiviCRM LLC (c) 2004-2018                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -89,7 +89,27 @@ class api_v3_ExtensionTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('extension', 'get', array());
     $testExtensionResult = $this->callAPISuccess('extension', 'get', array('key' => 'test.extension.manager.paymenttest'));
     $this->assertNotNull($result['values'][$testExtensionResult['id']]['typeInfo']);
-    $this->assertEquals(6, $result['count']);
+    $this->assertTrue($result['count'] >= 6);
+  }
+
+  /**
+   * Filtering by status=installed or status=uninstalled should produce different results.
+   */
+  public function testExtensionGetByStatus() {
+    $installed = $this->callAPISuccess('extension', 'get', array('status' => 'installed'));
+    $uninstalled = $this->callAPISuccess('extension', 'get', array('status' => 'uninstalled'));
+
+    // If the filter works, then results should be strictly independent.
+    $this->assertEquals(
+      array(),
+      array_intersect(
+        CRM_Utils_Array::collect('key', $installed['values']),
+        CRM_Utils_Array::collect('key', $uninstalled['values'])
+      )
+    );
+
+    $all = $this->callAPISuccess('extension', 'get', array());
+    $this->assertEquals($all['count'], $installed['count'] + $uninstalled['count']);
   }
 
   public function testGetMultipleExtensions() {