From 3241b69008cb13ff753c7f86d0f9a53f02ac14f5 Mon Sep 17 00:00:00 2001 From: mark burdett Date: Thu, 14 Nov 2019 21:52:29 -0800 Subject: [PATCH] Remove obsolete type check tests, preserving one to ensure TypeError is thrown. --- tests/phpunit/api/v3/ContributionTest.php | 2 +- tests/phpunit/api/v3/CustomFieldTest.php | 19 ----------- tests/phpunit/api/v3/CustomGroupTest.php | 18 ---------- tests/phpunit/api/v3/EventTest.php | 11 ------- .../phpunit/api/v3/GroupOrganizationTest.php | 33 ------------------- .../phpunit/api/v3/JobProcessMailingTest.php | 3 +- tests/phpunit/api/v3/MailingContactTest.php | 14 -------- .../phpunit/api/v3/MembershipPaymentTest.php | 8 ----- tests/phpunit/api/v3/MembershipTest.php | 8 ----- .../phpunit/api/v3/ParticipantPaymentTest.php | 25 -------------- tests/phpunit/api/v3/ParticipantTest.php | 17 ---------- .../api/v3/PaymentProcessorTypeTest.php | 15 --------- tests/phpunit/api/v3/RelationshipTypeTest.php | 11 ------- .../phpunit/api/v3/SyntaxConformanceTest.php | 33 ------------------- tests/phpunit/api/v3/UFJoinTest.php | 11 ------- tests/phpunit/api/v3/UFMatchTest.php | 20 ----------- 16 files changed, 3 insertions(+), 245 deletions(-) diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index b13ebe4d61..04c212d1f2 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -1752,9 +1752,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { } public function testDeleteParamsNotArrayContribution() { + $this->expectException(TypeError::class); $params = 'contribution_id= 1'; $contribution = $this->callAPIFailure('contribution', 'delete', $params); - $this->assertEquals($contribution['error_message'], 'Input variable `params` is not an array'); } public function testDeleteWrongParamContribution() { diff --git a/tests/phpunit/api/v3/CustomFieldTest.php b/tests/phpunit/api/v3/CustomFieldTest.php index 7d65df2a74..ecb40289f2 100644 --- a/tests/phpunit/api/v3/CustomFieldTest.php +++ b/tests/phpunit/api/v3/CustomFieldTest.php @@ -31,16 +31,6 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { parent::tearDown(); } - /** - * Check with no array. - */ - public function testCustomFieldCreateNoArray() { - $fieldParams = NULL; - - $customField = $this->callAPIFailure('custom_field', 'create', $fieldParams); - $this->assertEquals($customField['error_message'], 'Input variable `params` is not an array'); - } - /** * Check with no label. */ @@ -406,15 +396,6 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { ///////////////// civicrm_custom_field_delete methods - /** - * Check with no array. - */ - public function testCustomFieldDeleteNoArray() { - $params = NULL; - $customField = $this->callAPIFailure('custom_field', 'delete', $params); - $this->assertEquals($customField['error_message'], 'Input variable `params` is not an array'); - } - /** * Check without Field ID. */ diff --git a/tests/phpunit/api/v3/CustomGroupTest.php b/tests/phpunit/api/v3/CustomGroupTest.php index 5fd1adc1e6..e891f28eb0 100644 --- a/tests/phpunit/api/v3/CustomGroupTest.php +++ b/tests/phpunit/api/v3/CustomGroupTest.php @@ -199,15 +199,6 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { $this->assertEquals($customGroup['values'][$customGroup['id']]['style'], 'Inline'); } - /** - * Check with not array. - */ - public function testCustomGroupCreateNotArray() { - $params = NULL; - $customGroup = $this->callAPIFailure('custom_group', 'create', $params); - $this->assertEquals($customGroup['error_message'], 'Input variable `params` is not an array'); - } - /** * Check without title. */ @@ -336,15 +327,6 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { $this->assertEquals($customGroup['error_message'], 'Mandatory key(s) missing from params array: id'); } - /** - * Check with no array. - */ - public function testCustomGroupDeleteNoArray() { - $params = NULL; - $customGroup = $this->callAPIFailure('custom_group', 'delete', $params); - $this->assertEquals($customGroup['error_message'], 'Input variable `params` is not an array'); - } - /** * Check with valid custom group id. */ diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index 9dd4b67227..e547da041f 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -756,17 +756,6 @@ class api_v3_EventTest extends CiviUnitTestCase { $result = $this->callAPIFailure('Event', 'Delete', $params); } - /** - * Test civicrm_event_search with wrong params type. - * @param int $version - * @dataProvider versionThreeAndFour - */ - public function testSearchWrongParamsType($version) { - $this->_apiversion = $version; - $params = 'a string'; - $result = $this->callAPIFailure('event', 'get', $params); - } - /** * Test civicrm_event_search with empty params. * @param int $version diff --git a/tests/phpunit/api/v3/GroupOrganizationTest.php b/tests/phpunit/api/v3/GroupOrganizationTest.php index 4006a5c6ab..4ed4ed9f0c 100644 --- a/tests/phpunit/api/v3/GroupOrganizationTest.php +++ b/tests/phpunit/api/v3/GroupOrganizationTest.php @@ -83,17 +83,6 @@ class api_v3_GroupOrganizationTest extends CiviUnitTestCase { $this->assertAPISuccess($result); } - /** - * Test civicrm_group_organization_get with wrong params. - * - * @dataProvider versionThreeAndFour - */ - public function testGroupOrganizationGetWithWrongParams() { - $params = 'groupOrg'; - $result = $this->callAPIFailure('group_organization', 'get', $params); - $this->assertEquals($result['error_message'], 'Input variable `params` is not an array'); - } - /** * Test civicrm_group_organization_get invalid keys. * @@ -149,17 +138,6 @@ class api_v3_GroupOrganizationTest extends CiviUnitTestCase { $this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: group_id, organization_id'); } - /** - * Check with invalid params. - * - * @dataProvider versionThreeAndFour - */ - public function testGroupOrganizationCreateParamsNotArray() { - $params = 'group_org'; - $result = $this->callAPIFailure('group_organization', 'create', $params); - $this->assertEquals($result['error_message'], 'Input variable `params` is not an array'); - } - /** * Check with invalid params keys. * @@ -175,17 +153,6 @@ class api_v3_GroupOrganizationTest extends CiviUnitTestCase { ///////////////// civicrm_group_organization_remove methods - /** - * Test civicrm_group_organization_remove with params not an array. - * - * @dataProvider versionThreeAndFour - */ - public function testGroupOrganizationDeleteParamsNotArray() { - $params = 'delete'; - $result = $this->callAPIFailure('group_organization', 'delete', $params); - $this->assertEquals($result['error_message'], 'Input variable `params` is not an array'); - } - /** * Test civicrm_group_organization_remove with empty params. * diff --git a/tests/phpunit/api/v3/JobProcessMailingTest.php b/tests/phpunit/api/v3/JobProcessMailingTest.php index 68f304629b..4334acecb8 100644 --- a/tests/phpunit/api/v3/JobProcessMailingTest.php +++ b/tests/phpunit/api/v3/JobProcessMailingTest.php @@ -189,7 +189,8 @@ class api_v3_JobProcessMailingTest extends CiviUnitTestCase { ]); $this->callAPISuccess('mailing', 'create', $this->_params); $this->_mut->assertRecipients([]); - $this->callAPIFailure('job', 'process_mailing', "Failure in api call for job process_mailing: Job has not been executed as it is a non-production environment."); + $result = $this->callAPIFailure('job', 'process_mailing', []); + $this->assertEquals($result['error_message'], "Job has not been executed as it is a Staging (non-production) environment."); // Test with runInNonProductionEnvironment param. $this->callAPISuccess('job', 'process_mailing', ['runInNonProductionEnvironment' => TRUE]); diff --git a/tests/phpunit/api/v3/MailingContactTest.php b/tests/phpunit/api/v3/MailingContactTest.php index 5513438d3c..0000fcf4fd 100644 --- a/tests/phpunit/api/v3/MailingContactTest.php +++ b/tests/phpunit/api/v3/MailingContactTest.php @@ -41,20 +41,6 @@ class api_v3_MailingContactTest extends CiviUnitTestCase { parent::tearDown(); } - /** - * Test that the api responds correctly to null params. - * - * Do not copy and paste. - * - * Tests like this that test the wrapper belong in the SyntaxConformance class - * (which already has a 'not array test) - * I have left this here in case 'null' isn't covered in that class - * but don't copy it only any other classes - */ - public function testMailingNullParams() { - $this->callAPIFailure('MailingContact', 'get', NULL); - } - public function testMailingContactGetFields() { $result = $this->callAPISuccess('MailingContact', 'getfields', [ 'action' => 'get', diff --git a/tests/phpunit/api/v3/MembershipPaymentTest.php b/tests/phpunit/api/v3/MembershipPaymentTest.php index 62512496e2..8aa94d018d 100644 --- a/tests/phpunit/api/v3/MembershipPaymentTest.php +++ b/tests/phpunit/api/v3/MembershipPaymentTest.php @@ -91,14 +91,6 @@ class api_v3_MembershipPaymentTest extends CiviUnitTestCase { ///////////////// civicrm_membershipPayment_get methods - /** - * Test civicrm_membershipPayment_get with wrong params type. - */ - public function testGetWrongParamsType() { - $params = 'eeee'; - $GetWrongParamsType = $this->callAPIFailure('membership_payment', 'get', $params, 'Input variable `params` is not an array'); - } - /** * Test civicrm_membershipPayment_get - success expected. */ diff --git a/tests/phpunit/api/v3/MembershipTest.php b/tests/phpunit/api/v3/MembershipTest.php index 1975ef74c1..7619412b76 100644 --- a/tests/phpunit/api/v3/MembershipTest.php +++ b/tests/phpunit/api/v3/MembershipTest.php @@ -100,14 +100,6 @@ class api_v3_MembershipTest extends CiviUnitTestCase { $this->callAPIFailure('membership', 'delete', ['id' => 'blah']); } - /** - * Test civicrm_membership_delete() with invalid Membership Id. - */ - public function testMembershipDeleteWithInvalidMembershipId() { - $membershipId = 'membership'; - $this->callAPIFailure('membership', 'delete', $membershipId); - } - /** * Test membership deletion and with the preserve contribution param. */ diff --git a/tests/phpunit/api/v3/ParticipantPaymentTest.php b/tests/phpunit/api/v3/ParticipantPaymentTest.php index 737a629f2f..e040c69b8d 100644 --- a/tests/phpunit/api/v3/ParticipantPaymentTest.php +++ b/tests/phpunit/api/v3/ParticipantPaymentTest.php @@ -60,14 +60,6 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { ]); } - /** - * Test civicrm_participant_payment_create with wrong params type. - */ - public function testPaymentCreateWrongParamsType() { - $params = 'a string'; - $this->callAPIFailure('participant_payment', 'create', $params); - } - /** * Test civicrm_participant_payment_create with empty params. */ @@ -130,15 +122,6 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { ///////////////// civicrm_participant_payment_create methods - /** - * Test civicrm_participant payment create with wrong params type. - */ - public function testPaymentUpdateWrongParamsType() { - $params = 'a string'; - $result = $this->callAPIFailure('participant_payment', 'create', $params); - $this->assertEquals('Input variable `params` is not an array', $result['error_message']); - } - /** * Check with empty array. */ @@ -268,14 +251,6 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { $this->callAPISuccess('participant_payment', 'delete', $params); } - /** - * Test civicrm_participant_payment_delete with wrong params type. - */ - public function testPaymentDeleteWrongParamsType() { - $params = 'a string'; - $this->callAPIFailure('participant_payment', 'delete', $params); - } - /** * Check with empty array. */ diff --git a/tests/phpunit/api/v3/ParticipantTest.php b/tests/phpunit/api/v3/ParticipantTest.php index 1cbfbfb60f..6c485116b4 100644 --- a/tests/phpunit/api/v3/ParticipantTest.php +++ b/tests/phpunit/api/v3/ParticipantTest.php @@ -645,15 +645,6 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { ///////////////// civicrm_participant_update methods - /** - * Test civicrm_participant_update with wrong params type. - */ - public function testUpdateWrongParamsType() { - $params = 'a string'; - $result = $this->callAPIFailure('participant', 'create', $params); - $this->assertEquals('Input variable `params` is not an array', $result['error_message']); - } - /** * Check with empty array. */ @@ -720,14 +711,6 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { ///////////////// civicrm_participant_delete methods - /** - * Test civicrm_participant_delete with wrong params type. - */ - public function testDeleteWrongParamsType() { - $params = 'a string'; - $result = $this->callAPIFailure('participant', 'delete', $params); - } - /** * Test civicrm_participant_delete with empty params. */ diff --git a/tests/phpunit/api/v3/PaymentProcessorTypeTest.php b/tests/phpunit/api/v3/PaymentProcessorTypeTest.php index 56e2c49427..9cbd9e5326 100644 --- a/tests/phpunit/api/v3/PaymentProcessorTypeTest.php +++ b/tests/phpunit/api/v3/PaymentProcessorTypeTest.php @@ -90,13 +90,6 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase { $result = $this->callAPIFailure('payment_processor_type', 'delete', $params); } - /** - * Check with No array. - */ - public function testPaymentProcessorTypeDeleteParamsNotArray() { - $result = $this->callAPIFailure('payment_processor_type', 'delete', 'string'); - } - /** * Check if required fields are not passed. */ @@ -141,14 +134,6 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase { $this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: name, title, class_name, billing_mode'); } - /** - * Check with No array. - */ - public function testPaymentProcessorTypeUpdateParamsNotArray() { - $result = $this->callAPIFailure('payment_processor_type', 'create', 'string'); - $this->assertEquals($result['error_message'], 'Input variable `params` is not an array'); - } - /** * Check with all parameters. */ diff --git a/tests/phpunit/api/v3/RelationshipTypeTest.php b/tests/phpunit/api/v3/RelationshipTypeTest.php index 08efbece2b..b9b4f6706a 100644 --- a/tests/phpunit/api/v3/RelationshipTypeTest.php +++ b/tests/phpunit/api/v3/RelationshipTypeTest.php @@ -249,17 +249,6 @@ class api_v3_RelationshipTypeTest extends CiviUnitTestCase { $this->assertEquals(2, $results['count']); } - /** - * Check with params Not Array. - * @param int $version - * @dataProvider versionThreeAndFour - */ - public function testRelationshipTypesGetParamsNotArray($version) { - $this->_apiversion = $version; - - $results = $this->callAPIFailure('relationship_type', 'get', 'string'); - } - /** * Check with valid params array. * @param int $version diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index 8d5e4617a3..c32ba6e9e1 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -809,21 +809,6 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { $this->assertContains("Unknown api version", $result['error_message']); } - /** - * @dataProvider entities_get - * @param $Entity - */ - public function testEmptyParam_getString($Entity) { - - if (in_array($Entity, $this->toBeImplemented['get'])) { - // $this->markTestIncomplete("civicrm_api3_{$Entity}_get to be implemented"); - return; - } - $result = $this->callAPIFailure($Entity, 'Get', 'string'); - $this->assertEquals(2000, $result['error_code']); - $this->assertEquals('Input variable `params` is not an array', $result['error_message']); - } - /** * @dataProvider entities_get * @Xdepends testEmptyParam_get // no need to test the simple if the empty doesn't work/is skipped. doesn't seem to work @@ -1317,15 +1302,6 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { $result = $this->callAPIFailure($Entity, 'Create', ['id' => 999]); } - /** - * @dataProvider entities - */ - public function testCreateWrongTypeParamTag_create() { - $result = civicrm_api("Tag", 'Create', 'this is not a string'); - $this->assertEquals(1, $result['is_error']); - $this->assertEquals("Input variable `params` is not an array", $result['error_message']); - } - /** * @dataProvider entities_updatesingle * @@ -1591,15 +1567,6 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { $result = $this->callAPIFailure($Entity, 'Delete', ['id' => 999999]); } - /** - * @dataProvider entities - */ - public function testDeleteWrongTypeParamTag_delete() { - $result = civicrm_api("Tag", 'Delete', 'this is not a string'); - $this->assertEquals(1, $result['is_error']); - $this->assertEquals("Input variable `params` is not an array", $result['error_message']); - } - /** * Create two entities and make sure delete action only deletes one! * diff --git a/tests/phpunit/api/v3/UFJoinTest.php b/tests/phpunit/api/v3/UFJoinTest.php index eefe2b51d2..71f04a1bd1 100644 --- a/tests/phpunit/api/v3/UFJoinTest.php +++ b/tests/phpunit/api/v3/UFJoinTest.php @@ -81,17 +81,6 @@ class api_v3_UFJoinTest extends CiviUnitTestCase { } } - /** - * @param int $version - * @dataProvider versionThreeAndFour - */ - public function testUFJoinEditWrongParamsType($version) { - $this->_apiversion = $version; - $params = 'a string'; - $result = $this->callAPIFailure('uf_join', 'create', $params); - $this->assertEquals($result['error_message'], 'Input variable `params` is not an array'); - } - /** * @param int $version * @dataProvider versionThreeAndFour diff --git a/tests/phpunit/api/v3/UFMatchTest.php b/tests/phpunit/api/v3/UFMatchTest.php index 9808dc8c96..2e1d50901e 100644 --- a/tests/phpunit/api/v3/UFMatchTest.php +++ b/tests/phpunit/api/v3/UFMatchTest.php @@ -75,16 +75,6 @@ class api_v3_UFMatchTest extends CiviUnitTestCase { $this->assertEquals($result['values'][$result['id']]['contact_id'], 69); } - /** - * @param int $version - * @dataProvider versionThreeAndFour - */ - public function testGetUFMatchIDWrongParam($version) { - $this->_apiversion = $version; - $params = 'a string'; - $result = $this->callAPIFailure('uf_match', 'get', $params); - } - /** * Fetch uf id by contact id. * @param int $version @@ -99,16 +89,6 @@ class api_v3_UFMatchTest extends CiviUnitTestCase { $this->assertEquals($result['values'][$result['id']]['uf_id'], 42); } - /** - * @param int $version - * @dataProvider versionThreeAndFour - */ - public function testGetUFIDWrongParam($version) { - $this->_apiversion = $version; - $params = 'a string'; - $result = $this->callAPIFailure('uf_match', 'get', $params); - } - /** * Test civicrm_activity_create() using example code * @param int $version -- 2.25.1