Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC] Test - fix to use v3 api on postAsserts #20257

Merged
merged 1 commit into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ protected function tearDown(): void {
* @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();
}
Expand Down
8 changes: 6 additions & 2 deletions tests/phpunit/api/v3/ACLCachingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,32 @@ public function setUp(): void {

/**
* (non-PHPdoc)
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @see CiviUnitTestCase::tearDown()
*/
public function tearDown(): void {
$tablesToTruncate = [
'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);
$this->CustomGroupCreate(['extends' => 'Activity']);
$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');
}

}
2 changes: 1 addition & 1 deletion tests/phpunit/api/v3/DomainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function setUp(): void {
* 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__);
Expand Down