<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
+ | CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017 |
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* Test getting a single extension
* CRM-20532
*/
- public function testExtesnionGetSingleExtension() {
+ public function testExtensionGetSingleExtension() {
$result = $this->callAPISuccess('extension', 'get', array('key' => 'test.extension.manager.moduletest'));
$this->assertEquals('test.extension.manager.moduletest', $result['values'][$result['id']]['key']);
$this->assertEquals('module', $result['values'][$result['id']]['type']);
* Test single Extension get with specific fields in return
* CRM-20532
*/
- public function testSingleExtesnionGetWithReturnFields() {
+ public function testSingleExtensionGetWithReturnFields() {
$result = $this->callAPISuccess('extension', 'get', array('key' => 'test.extension.manager.moduletest', 'return' => array('name', 'status', 'key')));
$this->assertEquals('test.extension.manager.moduletest', $result['values'][$result['id']]['key']);
$this->assertFalse(isset($result['values'][$result['id']]['type']));
}
/**
- * Test Extension Get resturns detailed information
+ * Test Extension Get returns detailed information
* Note that this is likely to fail locally but will work on Jenkins due to the result count check
* CRM-20532
*/
- public function testExtesnionGet() {
+ public function testExtensionGet() {
$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() {
$this->assertEquals(2, $result['count']);
}
+ /**
+ * Test that extension get can be filtered by id.
+ */
+ public function testGetExtensionByID() {
+ $result = $this->callAPISuccess('extension', 'get', array('id' => 2, 'return' => array('label')));
+ $this->assertEquals(1, $result['count']);
+ }
+
}