From 6c8d4050b414a7e16915f69930c870c347d75645 Mon Sep 17 00:00:00 2001 From: Johan Vervloet Date: Thu, 18 Jun 2015 21:37:46 +0200 Subject: [PATCH] CRM-16701 - Some fixes in the unit tests. * The form_values string I used was wrong. * Creating does not work. Now the unit tests detect this. ---------------------------------------- * CRM-16701: Create API for saved searches https://issues.civicrm.org/jira/browse/CRM-16701 --- tests/phpunit/api/v3/SavedSearchTest.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/api/v3/SavedSearchTest.php b/tests/phpunit/api/v3/SavedSearchTest.php index 62e9c906a2..1f73dd563f 100644 --- a/tests/phpunit/api/v3/SavedSearchTest.php +++ b/tests/phpunit/api/v3/SavedSearchTest.php @@ -55,14 +55,18 @@ class api_v3_SavedSearchTest extends CiviUnitTestCase { // all contacts tagged with 'company'. // I got the params below from the database. + $url = CIVICRM_UF_BASEURL . "/civicrm/contact/search/advanced?reset=1"; + $serialized_url = serialize($url); + $this->params = array( - 'form_values' => 'a:36:{s:5:"qfKey";s:37:"4b50e233dcbe77cced4bd8fd8df90567_9974";s:8:"entryURL";s:64:"' . CIVICRM_UF_BASEURL . '/civicrm/contact/search/advanced?reset=1";s:12:"hidden_basic";s:1:"1";s:12:"contact_type";a:0:{}s:5:"group";a:0:{}s:10:"group_type";a:0:{}s:21:"group_search_selected";s:5:"group";s:9:"sort_name";s:0:"";s:5:"email";s:0:"";s:14:"contact_source";s:0:"";s:9:"job_title";s:0:"";s:10:"contact_id";s:0:"";s:19:"external_identifier";s:0:"";s:7:"uf_user";s:0:"";s:10:"tag_search";s:0:"";s:11:"uf_group_id";s:0:"";s:14:"component_mode";s:1:"1";s:8:"operator";s:3:"AND";s:25:"display_relationship_type";s:0:"";s:15:"privacy_options";a:0:{}s:16:"privacy_operator";s:2:"OR";s:14:"privacy_toggle";s:1:"1";s:13:"email_on_hold";a:1:{s:7:"on_hold";s:0:"";}s:30:"preferred_communication_method";a:5:{i:1;s:0:"";i:2;s:0:"";i:3;s:0:"";i:4;s:0:"";i:5;s:0:"";}s:18:"preferred_language";s:0:"";s:13:"phone_numeric";s:0:"";s:22:"phone_location_type_id";s:0:"";s:19:"phone_phone_type_id";s:0:"";s:4:"task";s:2:"13";s:8:"radio_ts";s:6:"ts_sel";s:12:"toggleSelect";s:1:"1";s:10:"mark_x_165";s:1:"1";s:10:"mark_x_155";s:1:"1";s:10:"mark_x_124";s:1:"1";s:9:"mark_x_35";s:1:"1";s:12:"contact_tags";a:1:{i:2;i:1;}}', - 'where_clause' => '( `civicrm_entity_tag-2`.tag_id IN (2) ) ', - 'select_tables' => "a:8:{s:15:\"civicrm_contact\";i:1;s:15:\"civicrm_address\";i:1;s:15:\"civicrm_country\";i:1;s:13:\"civicrm_email\";i:1;s:13:\"civicrm_phone\";i:1;s:10:\"civicrm_im\";i:1;s:19:\"civicrm_worldregion\";i:1;s:22:\"`civicrm_entity_tag-2`\";s:168:\" LEFT JOIN civicrm_entity_tag `civicrm_entity_tag-2` ON ( `civicrm_entity_tag-2`.entity_id = contact_a.id AND `civicrm_entity_tag-2`.entity_table = \'civicrm_contact\') \";} ", - 'where_tables' => "a:2:{s:15:\"civicrm_contact\";i:1;s:22:\"`civicrm_entity_tag-2`\";s:168:\" LEFT JOIN civicrm_entity_tag `civicrm_entity_tag-2` ON ( `civicrm_entity_tag-2`.entity_id = contact_a.id AND `civicrm_entity_tag-2`.entity_table = \'civicrm_contact\') \";}", + 'form_values' => 'a:36:{s:5:"qfKey";s:37:"4b50e233dcbe77cced4bd8fd8df90567_9974";s:8:"entryURL";' + . $serialized_url . 's:12:"hidden_basic";s:1:"1";s:12:"contact_type";a:0:{}s:5:"group";a:0:{}s:10:"group_type";a:0:{}s:21:"group_search_selected";s:5:"group";s:9:"sort_name";s:0:"";s:5:"email";s:0:"";s:14:"contact_source";s:0:"";s:9:"job_title";s:0:"";s:10:"contact_id";s:0:"";s:19:"external_identifier";s:0:"";s:7:"uf_user";s:0:"";s:10:"tag_search";s:0:"";s:11:"uf_group_id";s:0:"";s:14:"component_mode";s:1:"1";s:8:"operator";s:3:"AND";s:25:"display_relationship_type";s:0:"";s:15:"privacy_options";a:0:{}s:16:"privacy_operator";s:2:"OR";s:14:"privacy_toggle";s:1:"1";s:13:"email_on_hold";a:1:{s:7:"on_hold";s:0:"";}s:30:"preferred_communication_method";a:5:{i:1;s:0:"";i:2;s:0:"";i:3;s:0:"";i:4;s:0:"";i:5;s:0:"";}s:18:"preferred_language";s:0:"";s:13:"phone_numeric";s:0:"";s:22:"phone_location_type_id";s:0:"";s:19:"phone_phone_type_id";s:0:"";s:4:"task";s:2:"13";s:8:"radio_ts";s:6:"ts_sel";s:12:"toggleSelect";s:1:"1";s:10:"mark_x_165";s:1:"1";s:10:"mark_x_155";s:1:"1";s:10:"mark_x_124";s:1:"1";s:9:"mark_x_35";s:1:"1";s:12:"contact_tags";a:1:{i:2;i:1;}}', ); } + /** + * Create a saved search, and see whether the returned values make sense. + */ public function testCreateSavedSearch() { // Act: $result = $this->callAPIAndDocument( @@ -91,6 +95,8 @@ class api_v3_SavedSearchTest extends CiviUnitTestCase { // Assert: $this->assertEquals(1, $get_result['count']); $this->assertNotNull($get_result['values'][$get_result['id']]['id']); + $this->assertEquals( + $this->params['form_values'], $get_result['values'][$get_result['id']]['form_values']); } public function testDeleteSavedSearch() { -- 2.25.1