From e5dd95b2f3439ad488eac81f0b9663fef88dcc76 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 13 Nov 2014 19:43:37 -0800 Subject: [PATCH] api_v3_SyntaxConformanceTest - Fix loading of SYNTAX_CONFORMANCE_ENTITIES --- .../phpunit/api/v3/SyntaxConformanceTest.php | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index 0b9cb64b4b..88949e9ca5 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -29,10 +29,15 @@ require_once 'CiviTest/CiviUnitTestCase.php'; /** - * Test APIv3 civicrm_sytanc conformance* functions + * Test that the core actions for APIv3 entities comply with standard syntax+behavior. * - * @package CiviCRM_APIv3 - * @subpackage API_Core + * By default, this tests all API entities. To only test specific entities, call phpunit with + * environment variable SYNTAX_CONFORMANCE_ENTITIES, e.g. + * + * env SYNTAX_CONFORMANCE_ENTITIES="Contact Event" ./scripts/phpunit api_v3_SyntaxConformanceTest + * + * @package CiviCRM_APIv3 + * @subpackage API_Core */ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { @@ -99,19 +104,18 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { * @return array */ public static function entities($skip = NULL) { - // To only test specific entities, call phpunit with SYNTAX_CONFORMANCE_ENTITIES="TheEntityName" - // or uncomment this line: - //return array(array ('Tag'), array ('Activity') ); + // The order of operations in here is screwy. In the case where SYNTAX_CONFORMANCE_ENTITIES is + // defined, we should be able to parse+return it immediately. However, some weird dependency + // crept into the system where civicrm_api('Entity','get') must be called as part of entities() + // (even if its return value is ignored). + $tmp = civicrm_api('Entity', 'Get', array('version' => 3)); if (getenv('SYNTAX_CONFORMANCE_ENTITIES')) { - $result = array(); - foreach (explode(' ', getenv('SYNTAX_CONFORMANCE_ENTITIES')) as $entity) { - $result[] = array($entity); - } - return $result; + $tmp = array( + 'values' => explode(' ', getenv('SYNTAX_CONFORMANCE_ENTITIES')) + ); } - $tmp = civicrm_api('Entity', 'Get', array('version' => 3)); if (!is_array($skip)) { $skip = array(); } -- 2.25.1