From f75133ed23ae0811603e4006462e56ef746a9e59 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 22 Dec 2021 10:10:42 -0500 Subject: [PATCH] Fix test error message, and remove bad tests --- api/v3/MailingContact.php | 3 + .../BAO/ContactType/ContactSearchTest.php | 81 ------------------- 2 files changed, 3 insertions(+), 81 deletions(-) diff --git a/api/v3/MailingContact.php b/api/v3/MailingContact.php index b3f2d8bb26..4875e79340 100644 --- a/api/v3/MailingContact.php +++ b/api/v3/MailingContact.php @@ -43,6 +43,9 @@ function _civicrm_api3_mailing_contact_getresults($params, $count) { } $options = _civicrm_api3_get_options_from_params($params, TRUE, 'contribution', 'get'); $fnName = '_civicrm_api3_mailing_contact_get_' . strtolower($params['type']); + if (!function_exists($fnName)) { + throw new API_Exception('Invalid mailing type: ' . $params['type']); + } return $fnName( $params['contact_id'], $options['offset'], diff --git a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php index ead6037968..93c0afd3bd 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php @@ -245,85 +245,4 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase { $this->assertNotContains($this->household, $result['values']); } - /** - * Search with invalid type or subtype. - */ - public function testSearchWithInvalidData() { - // for invalid type - $params = [ - 'contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid', - 'version' => 3, - ]; - $result = civicrm_api('contact', 'get', $params); - $this->assertEquals(empty($result['values']), TRUE); - - // for invalid subtype - $params = ['contact_sub_type' => 'Invalid', 'version' => 3]; - $result = civicrm_api('contact', 'get', $params); - $this->assertEquals(empty($result['values']), TRUE); - - // for invalid contact type as well as subtype - $params = [ - 'contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid', - 'version' => 3, - ]; - $result = civicrm_api('contact', 'get', $params); - $this->assertEquals(empty($result['values']), TRUE); - - // for valid type and invalid subtype - $params = [ - 'contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid', - 'version' => 3, - ]; - $result = civicrm_api('contact', 'get', $params); - $this->assertEquals(empty($result['values']), TRUE); - - // for invalid type and valid subtype - $params = [ - 'contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'indivi_student', - 'version' => 3, - ]; - $result = civicrm_api('contact', 'get', $params); - $this->assertEquals(empty($result['values']), TRUE); - } - - /** - * Search with wrong type or subtype. - */ - public function testSearchWithWrongdData() { - - // for type:Individual subtype:Sponsor - $defaults = []; - $params = [ - 'contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor, - 'version' => 3, - ]; - $result = civicrm_api('contact', 'get', $params); - $this->assertEquals(empty($result['values']), TRUE); - - // for type:Orgaization subtype:Parent - $params = [ - 'contact_type' => 'Orgaization' . CRM_Core_DAO::VALUE_SEPARATOR . $this->parent, - 'version' => 3, - ]; - $result = civicrm_api('contact', 'get', $params, $defaults); - $this->assertEquals(empty($result['values']), TRUE); - - // for type:Household subtype:Sponsor - $params = [ - 'contact_type' => 'Household' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor, - 'version' => 3, - ]; - $result = civicrm_api('contact', 'get', $params, $defaults); - $this->assertEquals(empty($result['values']), TRUE); - - // for type:Household subtype:Student - $params = [ - 'contact_type' => 'Household' . CRM_Core_DAO::VALUE_SEPARATOR . $this->student, - 'version' => 3, - ]; - $result = civicrm_api('contact', 'get', $params, $defaults); - $this->assertEquals(empty($result['values']), TRUE); - } - } -- 2.25.1