X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fapi%2Fv3%2FSyntaxConformanceTest.php;h=b69486a376a7a4f9b715d532451bfdd88acba26b;hb=e39fff89e8b857768ee5c3a8f86ac73deded601f;hp=3dc5663db9a51328b02df645857b0a9264aef5b6;hpb=c9585a7ef2056a3701592f5dfb3c92af6fe901f9;p=civicrm-core.git diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index 3dc5663db9..b69486a376 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -278,7 +278,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { * * Mailing Contact Just doesn't support id. We have always insisted on finding a way to * support id in API but in this case the underlying tables are crying out for a restructure - * & it just doesn't make sense, on the otherhand Event need id to be existant as pseudo property + * & it just doesn't make sense, on the otherhand Event need id to be existent as pseudo property * is been associated with it, so we need to bypass for get api otherwise it will through pseudo_match validation * * @param bool $sequential @@ -599,6 +599,15 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { 'weight', //won't update as there is no 1 in the same price set ), ), + 'SavedSearch' => array( + // I think the fields below are generated based on form_values. + 'cant_update' => array( + 'search_custom_id', + 'where_clause', + 'select_tables', + 'where_tables', + ), + ), ); if (empty($knownFailures[$entity]) || empty($knownFailures[$entity][$key])) { return array(); @@ -615,7 +624,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { */ public function testNotImplemented_get($Entity) { $result = civicrm_api($Entity, 'Get', array('version' => 3)); - $this->assertEquals(1, $result['is_error'], 'In line ' . __LINE__); + $this->assertEquals(1, $result['is_error']); // $this->assertContains("API ($Entity, Get) does not exist", $result['error_message']); $this->assertRegExp('/API (.*) does not exist/', $result['error_message']); } @@ -657,7 +666,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { return; } $result = civicrm_api($Entity, 'Get', array()); - $this->assertEquals(1, $result['is_error'], 'In line ' . __LINE__); + $this->assertEquals(1, $result['is_error']); $this->assertContains("Mandatory key(s) missing from params array", $result['error_message']); } @@ -998,7 +1007,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { */ public function testNotImplemented_create($Entity) { $result = civicrm_api($Entity, 'Create', array('version' => 3)); - $this->assertEquals(1, $result['is_error'], 'In line ' . __LINE__); + $this->assertEquals(1, $result['is_error']); $this->assertContains(strtolower("API ($Entity, Create) does not exist"), strtolower($result['error_message'])); } @@ -1018,7 +1027,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { * @throws \PHPUnit_Framework_IncompleteTestError */ public function testEmptyParam_create($Entity) { - $this->markTestIncomplete("fixing this test to test the api functions fails on numberous tests + $this->markTestIncomplete("fixing this test to test the api functions fails on numerous tests which will either create a completely blank entity (batch, participant status) or have a damn good crack at it (e.g mailing job). Marking this as incomplete beats false success"); return; @@ -1053,7 +1062,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { */ public function testCreateWrongTypeParamTag_create() { $result = civicrm_api("Tag", 'Create', 'this is not a string'); - $this->assertEquals(1, $result['is_error'], 'In line ' . __LINE__); + $this->assertEquals(1, $result['is_error']); $this->assertEquals("Input variable `params` is not an array", $result['error_message']); } @@ -1125,11 +1134,6 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { break; case CRM_Utils_Type::T_TIMESTAMP: - // 4.6 doesn't support timestamp updates from 4.7 we should uncomment this. See CRM-16431. - continue; - - //case CRM_Utils_Type::T_DATETIME: - case 12: $entity[$fieldName] = '2012-05-20 03:05:20'; break; @@ -1140,7 +1144,19 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { case CRM_Utils_Type::T_TEXT: case CRM_Utils_Type::T_LONGTEXT: case CRM_Utils_Type::T_EMAIL: - $entity[$fieldName] = substr('New String', 0, CRM_Utils_Array::Value('maxlength', $specs, 100)); + if ($fieldName == 'form_values' && $entity_name == 'SavedSearch') { + // This is a hack for the SavedSearch API. It expects form_values + // to be a serialized array. + // If you want to fix this, you should definitely read this forum + // post. + // http://forum.civicrm.org/index.php/topic,33990.0.html + // See also my question on the CiviCRM Stack Exchange: + // https://civicrm.stackexchange.com/questions/3437 + $entity[$fieldName] = array('sort_name' => "SortName2"); + } + else { + $entity[$fieldName] = substr('New String', 0, CRM_Utils_Array::Value('maxlength', $specs, 100)); + } break; case CRM_Utils_Type::T_INT: @@ -1258,7 +1274,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { public function testNotImplemented_delete($Entity) { $nonExistantID = 151416349; $result = civicrm_api($Entity, 'Delete', array('version' => 3, 'id' => $nonExistantID)); - $this->assertEquals(1, $result['is_error'], 'In line ' . __LINE__); + $this->assertEquals(1, $result['is_error']); $this->assertContains(strtolower("API ($Entity, Delete) does not exist"), strtolower($result['error_message'])); } @@ -1282,7 +1298,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { return; } $result = civicrm_api($Entity, 'Delete', array()); - $this->assertEquals(1, $result['is_error'], 'In line ' . __LINE__); + $this->assertEquals(1, $result['is_error']); $this->assertContains("Mandatory key(s) missing from params array", $result['error_message']); } @@ -1307,7 +1323,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { */ public function testDeleteWrongTypeParamTag_delete() { $result = civicrm_api("Tag", 'Delete', 'this is not a string'); - $this->assertEquals(1, $result['is_error'], 'In line ' . __LINE__); + $this->assertEquals(1, $result['is_error']); $this->assertEquals("Input variable `params` is not an array", $result['error_message']); }