[NFC] Test cleanup
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 14 Dec 2021 21:13:37 +0000 (10:13 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 14 Dec 2021 23:21:00 +0000 (12:21 +1300)
This biggest part of this is relying on the tearDown to do the cleanup more. This is the right
way because if the test fails the cleanup won't happen if it is in the test itsef

tests/phpunit/api/v3/RelationshipTest.php

index 9af49654d9379cb9fbdf56d65de75627af9f4880..4d23fcb05774bff9ea3cd4cb8c076701f7ea0a20 100644 (file)
@@ -9,6 +9,8 @@
  +--------------------------------------------------------------------+
  */
 
+use Civi\Api4\RelationshipType;
+
 /**
  * Class contains api test cases for "civicrm_relationship"
  * @group headless
@@ -31,9 +33,9 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
    * @var  int
    */
   protected $_cId_b2;
-  protected $_relTypeID;
+  protected $relationshipTypeID;
   protected $_ids = [];
-  protected $_customFieldId = NULL;
+  protected $_customFieldId;
   protected $_params;
 
   protected $entity;
@@ -63,11 +65,11 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
       'is_active' => 1,
     ];
 
-    $this->_relTypeID = $this->relationshipTypeCreate($relTypeParams);
+    $this->relationshipTypeID = $this->relationshipTypeCreate($relTypeParams);
     $this->_params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-12-20',
       'is_active' => 1,
     ];
@@ -81,26 +83,26 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
    */
   public function tearDown(): void {
     $this->quickCleanup(['civicrm_relationship', 'civicrm_membership'], TRUE);
-    $this->relationshipTypeDelete($this->_relTypeID);
+    RelationshipType::delete(FALSE)->addWhere('id', '>', ($this->relationshipTypeID - 1))->execute();
     parent::tearDown();
   }
 
   /**
    * Check with empty array.
+   *
    * @param int $version
+   *
    * @dataProvider versionThreeAndFour
    */
-  public function testRelationshipCreateEmpty($version): void {
+  public function testRelationshipCreateEmpty(int $version): void {
     $this->_apiversion = $version;
     $this->callAPIFailure('relationship', 'create', []);
   }
 
   /**
    * Test Current Employer is correctly set.
-   *
-   * @throws \CRM_Core_Exception
    */
-  public function testCurrentEmployerRelationship() {
+  public function testCurrentEmployerRelationship(): void {
     $employerRelationshipID = $this->callAPISuccessGetValue('RelationshipType', [
       'return' => 'id',
       'name_b_a' => 'Employer Of',
@@ -118,7 +120,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
       'id' => $this->_cId_a,
     ]);
     $organisation = $this->callAPISuccessGetValue('Contact', [
-      'return' => "sort_name",
+      'return' => 'sort_name',
       'id' => $this->_cId_b,
     ]);
     $this->assertEquals($employer, $organisation);
@@ -126,7 +128,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     //Update relationship type
     $this->callAPISuccess('Relationship', 'create', [
       'id' => $employerRelationship['id'],
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
     ]);
     $employeeContact = $this->callAPISuccessGetSingle('Contact', [
       'return' => ['current_employer'],
@@ -138,10 +140,12 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
   /**
    * Check if required fields are not passed.
+   *
    * @param int $version
+   *
    * @dataProvider versionThreeAndFour
    */
-  public function testRelationshipCreateWithoutRequired($version) {
+  public function testRelationshipCreateWithoutRequired(int $version): void {
     $this->_apiversion = $version;
     $params = [
       'start_date' => ['d' => '10', 'M' => '1', 'Y' => '2008'],
@@ -154,10 +158,12 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
   /**
    * Check with incorrect required fields.
+   *
    * @param int $version
+   *
    * @dataProvider versionThreeAndFour
    */
-  public function testRelationshipCreateWithIncorrectData($version) {
+  public function testRelationshipCreateWithIncorrectData(int $version): void {
     $this->_apiversion = $version;
 
     $params = [
@@ -172,7 +178,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $params = [
       'contact_id_a' => 'invalid',
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => ['d' => '10', 'M' => '1', 'Y' => '2008'],
       'is_active' => 1,
     ];
@@ -190,16 +196,18 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
   /**
    * Check relationship creation with invalid Relationship.
+   *
    * @param int $version
+   *
    * @dataProvider versionThreeAndFour
    */
-  public function testRelationshipCreateInvalidRelationship($version) {
+  public function testRelationshipCreateInvalidRelationship(int $version): void {
     $this->_apiversion = $version;
     // Both have the contact type Individual.
     $params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_a,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-01-10',
       'is_active' => 1,
     ];
@@ -210,7 +218,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $params = [
       'contact_id_a' => $this->_cId_b,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-01-10',
       'is_active' => 1,
     ];
@@ -220,15 +228,17 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
   /**
    * Check relationship already exists.
+   *
    * @param int $version
+   *
    * @dataProvider versionThreeAndFour
    */
-  public function testRelationshipCreateAlreadyExists($version) {
+  public function testRelationshipCreateAlreadyExists(int $version): void {
     $this->_apiversion = $version;
     $params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-12-20',
       'end_date' => NULL,
       'is_active' => 1,
@@ -238,55 +248,54 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-12-20',
       'is_active' => 1,
     ];
-    $this->callAPIFailure('relationship', 'create', $params, 'Duplicate Relationship');
-
-    $params['id'] = $relationship['id'];
-    $this->callAPISuccess('relationship', 'delete', $params);
+    $this->callAPIFailure('Relationship', 'create', $params, 'Duplicate Relationship');
   }
 
   /**
    * Check relationship already exists.
+   *
    * @param int $version
+   *
    * @dataProvider versionThreeAndFour
    */
-  public function testRelationshipCreateUpdateAlreadyExists($version) {
+  public function testRelationshipCreateUpdateAlreadyExists(int $version): void {
     $this->_apiversion = $version;
     $params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-12-20',
       'end_date' => NULL,
       'is_active' => 1,
 
     ];
-    $relationship = $this->callAPISuccess('relationship', 'create', $params);
+    $relationship = $this->callAPISuccess('Relationship', 'create', $params);
     $params = [
       'id' => $relationship['id'],
       'is_active' => 0,
       'debug' => 1,
     ];
-    $this->callAPISuccess('relationship', 'create', $params);
-    $this->callAPISuccess('relationship', 'get', $params);
-    $params['id'] = $relationship['id'];
-    $this->callAPISuccess('relationship', 'delete', $params);
+    $this->callAPISuccess('Relationship', 'create', $params);
+    $this->callAPISuccess('Relationship', 'get', $params);
   }
 
   /**
    * Check update doesn't reset stuff badly - CRM-11789.
+   *
    * @param int $version
+   *
    * @dataProvider versionThreeAndFour
    */
-  public function testRelationshipCreateUpdateDoesNotMangle($version) {
+  public function testRelationshipCreateUpdateDoesNotMangle(int $version): void {
     $this->_apiversion = $version;
     $params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-12-20',
       'is_active' => 1,
       'is_permission_a_b' => 1,
@@ -296,34 +305,34 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
     $updateParams = [
       'id' => $relationship['id'],
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
     ];
     $this->callAPISuccess('relationship', 'create', $updateParams);
 
     //make sure the orig params didn't get changed
     $this->getAndCheck($params, $relationship['id'], 'relationship');
-
   }
 
   /**
    * Check relationship creation.
+   *
    * @param int $version
+   *
    * @dataProvider versionThreeAndFour
    */
-  public function testRelationshipCreate($version) {
+  public function testRelationshipCreate(int $version): void {
     $this->_apiversion = $version;
     $params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2010-10-30',
       'end_date' => '2010-12-30',
       'is_active' => 1,
       'note' => 'note',
     ];
 
-    $result = $this->callAPIAndDocument('relationship', 'create', $params, __FUNCTION__, __FILE__);
-    $this->assertNotNull($result['id']);
+    $result = $this->callAPIAndDocument('Relationship', 'create', $params, __FUNCTION__, __FILE__);
     $relationParams = [
       'id' => $result['id'],
     ];
@@ -333,21 +342,21 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('relationship', 'get', ['id' => $result['id']]);
     $values = $result['values'][$result['id']];
     foreach ($params as $key => $value) {
-      if ($key == 'note') {
+      if ($key === 'note') {
         continue;
       }
       $this->assertEquals($value, $values[$key], $key . " doesn't match " . print_r($values, TRUE));
     }
-    $params['id'] = $result['id'];
-    $this->callAPISuccess('relationship', 'delete', $params);
   }
 
   /**
    * Ensure disabling works.
+   *
    * @param int $version
+   *
    * @dataProvider versionThreeAndFour
    */
-  public function testRelationshipUpdate($version) {
+  public function testRelationshipUpdate(int $version): void {
     $this->_apiversion = $version;
     $result = $this->callAPISuccess('relationship', 'create', $this->_params);
     $relID = $result['id'];
@@ -367,15 +376,17 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
   /**
    * Check relationship creation.
+   *
    * @param int $version
+   *
    * @dataProvider versionThreeAndFour
    */
-  public function testRelationshipCreateEmptyEndDate($version) {
+  public function testRelationshipCreateEmptyEndDate(int $version): void {
     $this->_apiversion = $version;
     $params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2010-10-30',
       'end_date' => '',
       'is_active' => 1,
@@ -393,10 +404,10 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('relationship', 'get', ['id' => $result['id']]);
     $values = $result['values'][$result['id']];
     foreach ($params as $key => $value) {
-      if ($key == 'note') {
+      if ($key === 'note') {
         continue;
       }
-      if ($key == 'end_date') {
+      if ($key === 'end_date') {
         $this->assertTrue(empty($values[$key]));
         continue;
       }
@@ -410,7 +421,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
    * Check relationship creation with custom data.
    * FIXME: Api4
    */
-  public function testRelationshipCreateEditWithCustomData() {
+  public function testRelationshipCreateEditWithCustomData(): void {
     $this->createCustomGroupWithFieldsOfAllTypes();
     //few custom Values for comparing
     $custom_params = [
@@ -423,7 +434,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-12-20',
       'is_active' => 1,
     ];
@@ -437,7 +448,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $getParams = ['id' => $result['id']];
     $updateParams = array_merge($getParams, [
       $this->getCustomFieldName('text') => 'Edited Text Value',
-      'relationship_type_id' => $this->_relTypeID . '_b_a',
+      'relationship_type_id' => $this->relationshipTypeID . '_b_a',
       'related_contact_id' => $this->_cId_a,
     ]);
     $reln = new CRM_Contact_Form_Relationship();
@@ -446,11 +457,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $reln->submit($updateParams);
 
     $check = $this->callAPISuccess('relationship', 'get', $getParams);
-    $this->assertEquals("Edited Text Value", $check['values'][$check['id']][$this->getCustomFieldName('text')]);
-
-    $params['id'] = $result['id'];
-    $this->callAPISuccess('relationship', 'delete', $params);
-    $this->relationshipTypeDelete($this->_relTypeID);
+    $this->assertEquals('Edited Text Value', $check['values'][$check['id']][$this->getCustomFieldName('text')]);
   }
 
   /**
@@ -460,7 +467,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
    * and / or moved to the automated test suite
    * FIXME: Api4
    */
-  public function testGetWithCustom() {
+  public function testGetWithCustom(): void {
     $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
 
     $params = $this->_params;
@@ -482,7 +489,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
    * @param int $version
    * @dataProvider versionThreeAndFour
    */
-  public function testRelationshipDeleteWithoutRequired($version) {
+  public function testRelationshipDeleteWithoutRequired($version): void {
     $this->_apiversion = $version;
     $params = [
       'start_date' => '2008-12-20',
@@ -496,7 +503,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
   /**
    * Check with incorrect required fields.
    */
-  public function testRelationshipDeleteWithIncorrectData() {
+  public function testRelationshipDeleteWithIncorrectData(): void {
     $params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
@@ -505,7 +512,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
     $this->callAPIFailure('relationship', 'delete', $params, 'Mandatory key(s) missing from params array: id');
 
-    $params['id'] = "Invalid";
+    $params['id'] = 'Invalid';
     $this->callAPIFailure('relationship', 'delete', $params, 'id is not a valid integer');
   }
 
@@ -519,7 +526,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-12-20',
       'is_active' => 1,
     ];
@@ -527,7 +534,6 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('relationship', 'create', $params);
     $params = ['id' => $result['id']];
     $this->callAPIAndDocument('relationship', 'delete', $params, __FUNCTION__, __FILE__);
-    $this->relationshipTypeDelete($this->_relTypeID);
   }
 
   ///////////////// civicrm_relationship_update methods
@@ -557,7 +563,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $relParams = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '20081214',
       'end_date' => '20091214',
       'is_active' => 1,
@@ -570,16 +576,13 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '20081214',
       'end_date' => '20091214',
       'is_active' => 0,
     ];
 
     $this->callAPIFailure('relationship', 'create', $params, 'Duplicate Relationship');
-
-    $this->callAPISuccess('relationship', 'delete', ['id' => $result['id']]);
-    $this->relationshipTypeDelete($this->_relTypeID);
   }
 
   /**
@@ -587,7 +590,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
    * should be OK if the custom field values differ.
    * FIXME: Api4
    */
-  public function testRelationshipCreateDuplicateWithCustomFields() {
+  public function testRelationshipCreateDuplicateWithCustomFields(): void {
     $this->createCustomGroupWithFieldsOfAllTypes();
 
     $custom_params_1 = [
@@ -607,7 +610,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-12-20',
       'is_active' => 1,
     ];
@@ -620,8 +623,6 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
     $this->assertNotNull($result_2['id']);
     $this->assertEquals(0, $result_2['is_error']);
-
-    $this->relationshipTypeDelete($this->_relTypeID);
   }
 
   /**
@@ -631,7 +632,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
    * does.
    * FIXME: Api4
    */
-  public function testRelationshipCreateDuplicateWithCustomFields2() {
+  public function testRelationshipCreateDuplicateWithCustomFields2(): void {
     $this->createCustomGroupWithFieldsOfAllTypes();
 
     $custom_params_2 = [
@@ -644,7 +645,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $params_1 = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-12-20',
       'is_active' => 1,
     ];
@@ -656,8 +657,6 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
     $this->assertNotNull($result_2['id']);
     $this->assertEquals(0, $result_2['is_error']);
-
-    $this->relationshipTypeDelete($this->_relTypeID);
   }
 
   /**
@@ -680,7 +679,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $params_2 = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-12-20',
       'is_active' => 1,
     ];
@@ -692,8 +691,6 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
     $this->assertNotNull($result_2['id']);
     $this->assertEquals(0, $result_2['is_error']);
-
-    $this->relationshipTypeDelete($this->_relTypeID);
   }
 
   /**
@@ -703,7 +700,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $relParams = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2011-01-01',
       'end_date' => '2013-01-01',
       'is_active' => 1,
@@ -743,7 +740,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
     // Try to retrieve it using chaining.
     $params = [
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'id' => $id,
       'api.Contact.get' => [
         'id' => '$value.contact_id_b',
@@ -773,7 +770,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $params = [
       'id' => $this->_cId_a,
       'api.Relationship.get' => [
-        'relationship_type_id' => $this->_relTypeID,
+        'relationship_type_id' => $this->relationshipTypeID,
         'contact_id_a' => '$value.id',
         'api.Contact.get' => [
           'id' => '$value.contact_id_b',
@@ -802,7 +799,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $relParams = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2011-01-01',
       'end_date' => '2013-01-01',
       'is_active' => 1,
@@ -827,7 +824,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $rel2Params = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b2,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2008-12-20',
       'is_active' => 0,
     ];
@@ -972,52 +969,36 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     $relParams = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2011-01-01',
       'end_date' => '2013-01-01',
       'is_active' => 1,
     ];
 
-    $relationship = $this->callAPISuccess('relationship', 'create', $relParams);
-
-    $contacts = [
-      'contact_id' => $this->_cId_a,
-    ];
-
-    $result = $this->callAPISuccess('relationship', 'get', $contacts);
+    $this->callAPISuccess('relationship', 'create', $relParams);
+    $result = $this->callAPISuccess('Relationship', 'get', ['contact_id' => $this->_cId_a]);
     $this->assertGreaterThan(0, $result['count']);
-    $params = [
-      'id' => $relationship['id'],
-    ];
-    $this->callAPISuccess('relationship', 'delete', $params);
-    $this->relationshipTypeDelete($this->_relTypeID);
   }
 
   /**
    * Check with valid data with relationshipTypes.
    */
-  public function testGetRelationshipWithRelTypes() {
+  public function testGetRelationshipWithRelTypes(): void {
     $relParams = [
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $this->_cId_b,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'start_date' => '2011-01-01',
       'end_date' => '2013-01-01',
       'is_active' => 1,
     ];
 
-    $relationship = $this->callAPISuccess('relationship', 'create', $relParams);
+    $this->callAPISuccess('relationship', 'create', $relParams);
 
     $contact_a = [
       'contact_id' => $this->_cId_a,
     ];
     $this->callAPISuccess('relationship', 'get', $contact_a);
-
-    $params = [
-      'id' => $relationship['id'],
-    ];
-    $this->callAPISuccess('relationship', 'delete', $params);
-    $this->relationshipTypeDelete($this->_relTypeID);
   }
 
   /**
@@ -1028,11 +1009,11 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
    * We should get 1 result without or with correct relationship type id & 0 with
    * an incorrect one
    */
-  public function testGetRelationshipByTypeReciprocal() {
+  public function testGetRelationshipByTypeReciprocal(): void {
     $created = $this->callAPISuccess($this->entity, 'create', $this->_params);
     $result = $this->callAPISuccess($this->entity, 'get', [
       'contact_id' => $this->_cId_a,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
     ]);
     $this->assertEquals(1, $result['count']);
     $result = $this->callAPISuccess($this->entity, 'get', [
@@ -1052,7 +1033,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
    * @param int $version
    * @dataProvider versionThreeAndFour
    */
-  public function testGetRelationshipByTypeDAO($version) {
+  public function testGetRelationshipByTypeDAO($version): void {
     $this->_apiversion = $version;
     $this->_ids['relationship'] = $this->callAPISuccess($this->entity, 'create', ['format.only_id' => TRUE] +
       $this->_params);
@@ -1061,7 +1042,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     ], 1);
     $result = $this->callAPISuccess($this->entity, 'get', [
       'contact_id_a' => $this->_cId_a,
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
     ]);
     $this->assertEquals(1, $result['count']);
     $result = $this->callAPISuccess($this->entity, 'get', [
@@ -1077,10 +1058,12 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
    *
    * We should get 1 result without or with correct relationship type id & 0 with
    * an incorrect one
+   *
    * @param int $version
+   *
    * @dataProvider versionThreeAndFour
    */
-  public function testGetRelationshipByTypeArrayDAO($version) {
+  public function testGetRelationshipByTypeArrayDAO(int $version): void {
     $this->_apiversion = $version;
     $this->callAPISuccess($this->entity, 'create', $this->_params);
     $org3 = $this->organizationCreate();
@@ -1107,12 +1090,12 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
     $result = $this->callAPISuccess($this->entity, 'get', [
       'contact_id_a' => $this->_cId_a,
-      'relationship_type_id' => ['IN' => [$this->_relTypeID, $relType3]],
+      'relationship_type_id' => ['IN' => [$this->relationshipTypeID, $relType3]],
     ]);
 
     $this->assertEquals(2, $result['count']);
-    foreach ($result['values'] as $key => $value) {
-      $this->assertTrue(in_array($value['relationship_type_id'], [$this->_relTypeID, $relType3]));
+    foreach ($result['values'] as $value) {
+      $this->assertContains($value['relationship_type_id'], [$this->relationshipTypeID, $relType3]);
     }
   }
 
@@ -1148,12 +1131,12 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
     $result = $this->callAPISuccess($this->entity, 'get', [
       'contact_id' => $this->_cId_a,
-      'relationship_type_id' => ['IN' => [$this->_relTypeID, $relType3]],
+      'relationship_type_id' => ['IN' => [$this->relationshipTypeID, $relType3]],
     ]);
 
     $this->assertEquals(2, $result['count']);
     foreach ($result['values'] as $key => $value) {
-      $this->assertTrue(in_array($value['relationship_type_id'], [$this->_relTypeID, $relType3]));
+      $this->assertTrue(in_array($value['relationship_type_id'], [$this->relationshipTypeID, $relType3]));
     }
   }
 
@@ -1220,7 +1203,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
     // although our contact has more than one relationship we have passed them in as contact_id_a & can't get reciprocal
     $this->assertEquals(1, $result['count']);
     foreach ($result['values'] as $key => $value) {
-      $this->assertTrue(in_array($value['relationship_type_id'], [$relType1]));
+      $this->assertContains($value['relationship_type_id'], [$relType1]);
     }
   }
 
@@ -1324,7 +1307,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
       'duration_unit' => 'year',
       'duration_interval' => 1,
       'period_type' => 'rolling',
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'relationship_direction' => 'b_a',
       'visibility' => 'Public',
       'auto_renew' => 0,
@@ -1336,7 +1319,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
       'contact_id' => $mainContactID,
     ]);
     $this->callAPISuccess('Relationship', 'create', [
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'contact_id_a' => $this->_cId_a,
       'contact_id_b' => $mainContactID,
     ]);
@@ -1345,7 +1328,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase {
 
     // Adding a relationship with a future start date should NOT create a membership
     $this->callAPISuccess('Relationship', 'create', [
-      'relationship_type_id' => $this->_relTypeID,
+      'relationship_type_id' => $this->relationshipTypeID,
       'contact_id_a' => $this->_cId_a_2,
       'contact_id_b' => $mainContactID,
       'start_date' => 'now + 1 week',