Skip to content

Commit

Permalink
Remove obsolete type check tests, preserving one to ensure TypeError …
Browse files Browse the repository at this point in the history
…is thrown.
  • Loading branch information
mfb committed Nov 15, 2019
1 parent 43e53e9 commit 3241b69
Show file tree
Hide file tree
Showing 16 changed files with 3 additions and 245 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/api/v3/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1752,9 +1752,9 @@ public function testDeleteEmptyParamsContribution() {
}

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() {
Expand Down
19 changes: 0 additions & 19 deletions tests/phpunit/api/v3/CustomFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ public function tearDown() {
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.
*/
Expand Down Expand Up @@ -406,15 +396,6 @@ public function testCustomFieldCreateWithOptionValues() {

///////////////// 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.
*/
Expand Down
18 changes: 0 additions & 18 deletions tests/phpunit/api/v3/CustomGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,6 @@ public function testCustomGroupCreateNoStyle() {
$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.
*/
Expand Down Expand Up @@ -336,15 +327,6 @@ public function testCustomGroupDeleteWithoutGroupID() {
$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.
*/
Expand Down
11 changes: 0 additions & 11 deletions tests/phpunit/api/v3/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -756,17 +756,6 @@ public function testDeleteWithWrongEventId($version) {
$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
Expand Down
33 changes: 0 additions & 33 deletions tests/phpunit/api/v3/GroupOrganizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,6 @@ public function testGroupOrganizationGetWithEmptyParams() {
$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.
*
Expand Down Expand Up @@ -149,17 +138,6 @@ public function testGroupOrganizationCreateWithEmptyParams() {
$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.
*
Expand All @@ -175,17 +153,6 @@ public function testGroupOrganizationCreateWithInvalidKeys() {

///////////////// 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.
*
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/api/v3/JobProcessMailingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ public function testMailNonProductionRun() {
]);
$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]);
Expand Down
14 changes: 0 additions & 14 deletions tests/phpunit/api/v3/MailingContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,6 @@ public function tearDown() {
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',
Expand Down
8 changes: 0 additions & 8 deletions tests/phpunit/api/v3/MembershipPaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ public function testCreate() {

///////////////// 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.
*/
Expand Down
8 changes: 0 additions & 8 deletions tests/phpunit/api/v3/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ public function testMembershipDeleteInvalidID() {
$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.
*/
Expand Down
25 changes: 0 additions & 25 deletions tests/phpunit/api/v3/ParticipantPaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ public function setUp() {
]);
}

/**
* 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.
*/
Expand Down Expand Up @@ -130,15 +122,6 @@ public function testPaymentInfoForEvent() {

///////////////// 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.
*/
Expand Down Expand Up @@ -268,14 +251,6 @@ public function testPaymentPayLaterOnline() {
$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.
*/
Expand Down
17 changes: 0 additions & 17 deletions tests/phpunit/api/v3/ParticipantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,15 +645,6 @@ public function testUpdateCreateParticipantFeeLevelNoSeparator() {

///////////////// 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.
*/
Expand Down Expand Up @@ -720,14 +711,6 @@ public function testUpdateWithWrongContactId() {

///////////////// 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.
*/
Expand Down
15 changes: 0 additions & 15 deletions tests/phpunit/api/v3/PaymentProcessorTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ public function testPaymentProcessorTypeDeleteEmpty() {
$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.
*/
Expand Down Expand Up @@ -141,14 +134,6 @@ public function testPaymentProcessorTypeUpdateEmpty() {
$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.
*/
Expand Down
11 changes: 0 additions & 11 deletions tests/phpunit/api/v3/RelationshipTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,6 @@ public function testRelationshipTypesGetEmptyParams($version) {
$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
Expand Down
33 changes: 0 additions & 33 deletions tests/phpunit/api/v3/SyntaxConformanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -809,21 +809,6 @@ public function testEmptyParam_get($Entity) {
$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
Expand Down Expand Up @@ -1317,15 +1302,6 @@ public function testInvalidID_create($Entity) {
$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
*
Expand Down Expand Up @@ -1591,15 +1567,6 @@ public function testInvalidID_delete($Entity) {
$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!
*
Expand Down
Loading

0 comments on commit 3241b69

Please sign in to comment.