From 79abc760230b6fa3265cf28676538f8af3f3514a Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 10 May 2021 12:05:35 +1200 Subject: [PATCH] [NFC] Test - fix to use v3 api on postAsserts --- tests/phpunit/CiviTest/CiviUnitTestCase.php | 2 ++ tests/phpunit/api/v3/ACLCachingTest.php | 8 ++++++-- tests/phpunit/api/v3/DomainTest.php | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 4c7bf51e2c..3130c40e95 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -501,6 +501,8 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * @throws \CRM_Core_Exception */ protected function assertPostConditions() { + // Reset to version 3 as not all (e.g payments) work on v4 + $this->_apiversion = 3; if ($this->isLocationTypesOnPostAssert) { $this->assertLocationValidity(); } diff --git a/tests/phpunit/api/v3/ACLCachingTest.php b/tests/phpunit/api/v3/ACLCachingTest.php index d5e1154040..aada6e1356 100644 --- a/tests/phpunit/api/v3/ACLCachingTest.php +++ b/tests/phpunit/api/v3/ACLCachingTest.php @@ -27,6 +27,9 @@ class api_v3_ACLCachingTest extends CiviUnitTestCase { /** * (non-PHPdoc) + * + * @throws \CRM_Core_Exception + * @throws \CiviCRM_API3_Exception * @see CiviUnitTestCase::tearDown() */ public function tearDown(): void { @@ -34,13 +37,14 @@ class api_v3_ACLCachingTest extends CiviUnitTestCase { 'civicrm_activity', ]; $this->quickCleanup($tablesToTruncate, TRUE); + parent::tearDown(); } /** * @param int $version * @dataProvider versionThreeAndFour */ - public function testActivityCreateCustomBefore($version) { + public function testActivityCreateCustomBefore($version): void { $this->_apiversion = $version; $values = $this->callAPISuccess('custom_field', 'getoptions', ['field' => 'custom_group_id']); $this->assertTrue($values['count'] == 0); @@ -48,7 +52,7 @@ class api_v3_ACLCachingTest extends CiviUnitTestCase { $groupCount = $this->callAPISuccess('custom_group', 'getcount', ['extends' => 'activity']); $this->assertEquals($groupCount, 1, 'one group should now exist'); $values = $this->callAPISuccess('custom_field', 'getoptions', ['field' => 'custom_group_id']); - $this->assertTrue($values['count'] == 1, 'check that cached value is not retained for custom_group_id'); + $this->assertEquals(1, $values['count'], 'check that cached value is not retained for custom_group_id'); } } diff --git a/tests/phpunit/api/v3/DomainTest.php b/tests/phpunit/api/v3/DomainTest.php index bb9eb817c8..43aca656cf 100644 --- a/tests/phpunit/api/v3/DomainTest.php +++ b/tests/phpunit/api/v3/DomainTest.php @@ -76,7 +76,7 @@ class api_v3_DomainTest extends CiviUnitTestCase { * Takes no params. * Testing mainly for format. */ - public function testGet() { + public function testGet(): void { $params = ['sequential' => 1]; $result = $this->callAPIAndDocument('domain', 'get', $params, __FUNCTION__, __FILE__); -- 2.25.1