From 0201b57f4da320f952f1a51d5df4cb28a38f4c42 Mon Sep 17 00:00:00 2001 From: Dave Greenberg Date: Mon, 7 Apr 2014 13:57:55 -0700 Subject: [PATCH] CRM-13891 - test fixes, replace hard-coded IDs with name lookups and accommodate option group with more than 10 options. ---------------------------------------- * CRM-13891: http://issues.civicrm.org/jira/browse/CRM-13891 --- tests/phpunit/CRM/Core/PseudoConstantTest.php | 2 +- tests/phpunit/api/v3/CustomSearchTest.php | 6 +++--- tests/phpunit/api/v3/ReportTemplateTest.php | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/CRM/Core/PseudoConstantTest.php b/tests/phpunit/CRM/Core/PseudoConstantTest.php index 4662a231a3..ee947cca18 100644 --- a/tests/phpunit/CRM/Core/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Core/PseudoConstantTest.php @@ -576,7 +576,7 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { } // Ensure count of optionValues is not extraordinarily high. - $max = CRM_Utils_Array::value('max', $field, 10); + $max = CRM_Utils_Array::value('max', $field, 12); $this->assertLessThanOrEqual($max, count($optionValues), $message); } } diff --git a/tests/phpunit/api/v3/CustomSearchTest.php b/tests/phpunit/api/v3/CustomSearchTest.php index db49192c38..fe6ad5e2de 100644 --- a/tests/phpunit/api/v3/CustomSearchTest.php +++ b/tests/phpunit/api/v3/CustomSearchTest.php @@ -25,7 +25,7 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase { $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Contact_Form_Search_Custom_Examplez" AND label = "CRM_Contact_Form_Search_Custom_Examplez" - AND option_group_id = 25'); + AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "custom_search") '); $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"'); @@ -39,7 +39,7 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase { $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Contact_Form_Search_Custom_Examplez" AND label = "CRM_Contact_Form_Search_Custom_Examplez" - AND option_group_id = 25'); + AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "custom_search") '); $this->assertDBQuery(0, 'SELECT is_active FROM civicrm_option_value WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"'); @@ -53,7 +53,7 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase { $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Contact_Form_Search_Custom_Examplez" AND label = "CRM_Contact_Form_Search_Custom_Examplez" - AND option_group_id = 25'); + AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "custom_search") '); $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"'); diff --git a/tests/phpunit/api/v3/ReportTemplateTest.php b/tests/phpunit/api/v3/ReportTemplateTest.php index 99ee9644fe..2178aa95d3 100644 --- a/tests/phpunit/api/v3/ReportTemplateTest.php +++ b/tests/phpunit/api/v3/ReportTemplateTest.php @@ -60,7 +60,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { $this->assertEquals(7, $result['values'][$entityId]['component_id'], 'In line ' . __LINE__); $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Report_Form_Examplez" - AND option_group_id = 41 '); + AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "report_template") '); $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value WHERE name = "CRM_Report_Form_Examplez"'); @@ -72,7 +72,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Report_Form_Examplez" - AND option_group_id = 41'); + AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "report_template") '); $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Report_Form_Examplez" AND component_id IS NULL'); @@ -85,7 +85,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Report_Form_Examplez" - AND option_group_id = 41'); + AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "report_template") '); $this->assertDBQuery(0, 'SELECT is_active FROM civicrm_option_value WHERE name = "CRM_Report_Form_Examplez"'); @@ -97,7 +97,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Report_Form_Examplez" - AND option_group_id = 41'); + AND option_group_id IN (SELECT id from civicrm_option_group WHERE name = "report_template") '); $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value WHERE name = "CRM_Report_Form_Examplez"'); -- 2.25.1