From 182bc25dddf879d8769b19576031322fdbb8b6d6 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 20 Jun 2021 16:13:25 -0400 Subject: [PATCH] Test cleanup - use new APIv4 syntax for checkPermissions --- tests/phpunit/api/v4/Action/FkJoinTest.php | 26 +++++++++++----------- tests/phpunit/api/v4/Entity/SystemTest.php | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/phpunit/api/v4/Action/FkJoinTest.php b/tests/phpunit/api/v4/Action/FkJoinTest.php index dcacfd0efa..d02ac67c28 100644 --- a/tests/phpunit/api/v4/Action/FkJoinTest.php +++ b/tests/phpunit/api/v4/Action/FkJoinTest.php @@ -161,51 +161,51 @@ class FkJoinTest extends UnitTestCase { } public function testBridgeJoinTags() { - $tag1 = Tag::create()->setCheckPermissions(FALSE) + $tag1 = Tag::create(FALSE) ->addValue('name', uniqid('join1')) ->execute() ->first()['name']; - $tag2 = Tag::create()->setCheckPermissions(FALSE) + $tag2 = Tag::create(FALSE) ->addValue('name', uniqid('join2')) ->execute() ->first()['name']; - $tag3 = Tag::create()->setCheckPermissions(FALSE) + $tag3 = Tag::create(FALSE) ->addValue('name', uniqid('join3')) ->execute() ->first()['name']; - $cid1 = Contact::create()->setCheckPermissions(FALSE) + $cid1 = Contact::create(FALSE) ->addValue('first_name', 'Aaa') ->addChain('tag1', EntityTag::create()->setValues(['entity_id' => '$id', 'tag_id:name' => $tag1])) ->addChain('tag2', EntityTag::create()->setValues(['entity_id' => '$id', 'tag_id:name' => $tag2])) ->execute() ->first()['id']; - $cid2 = Contact::create()->setCheckPermissions(FALSE) + $cid2 = Contact::create(FALSE) ->addValue('first_name', 'Bbb') ->addChain('tag1', EntityTag::create()->setValues(['entity_id' => '$id', 'tag_id:name' => $tag1])) ->addChain('tag3', EntityTag::create()->setValues(['entity_id' => '$id', 'tag_id:name' => $tag3])) ->execute() ->first()['id']; - $cid3 = Contact::create()->setCheckPermissions(FALSE) + $cid3 = Contact::create(FALSE) ->addValue('first_name', 'Ccc') ->execute() ->first()['id']; - $required = Contact::get()->setCheckPermissions(FALSE) + $required = Contact::get(FALSE) ->addJoin('Tag', TRUE, 'EntityTag') ->addSelect('first_name', 'tag.name') ->addWhere('id', 'IN', [$cid1, $cid2, $cid3]) ->execute(); $this->assertCount(4, $required); - $optional = Contact::get()->setCheckPermissions(FALSE) + $optional = Contact::get(FALSE) ->addJoin('Tag', FALSE, 'EntityTag', ['tag.name', 'IN', [$tag1, $tag2, $tag3]]) ->addSelect('first_name', 'tag.name') ->addWhere('id', 'IN', [$cid1, $cid2, $cid3]) ->execute(); $this->assertCount(5, $optional); - $grouped = Contact::get()->setCheckPermissions(FALSE) + $grouped = Contact::get(FALSE) ->addJoin('Tag', FALSE, 'EntityTag', ['tag.name', 'IN', [$tag1, $tag3]]) ->addSelect('first_name', 'COUNT(tag.name) AS tag_count') ->addWhere('id', 'IN', [$cid1, $cid2, $cid3]) @@ -215,7 +215,7 @@ class FkJoinTest extends UnitTestCase { $this->assertEquals(2, (int) $grouped[$cid2]['tag_count']); $this->assertEquals(0, (int) $grouped[$cid3]['tag_count']); - $reverse = Tag::get()->setCheckPermissions(FALSE) + $reverse = Tag::get(FALSE) ->addJoin('Contact', FALSE, 'EntityTag', ['contact.id', 'IN', [$cid1, $cid2, $cid3]]) ->addGroupBy('id') ->addSelect('name', 'COUNT(contact.id) AS contacts') @@ -226,7 +226,7 @@ class FkJoinTest extends UnitTestCase { } public function testBridgeJoinRelationshipContactActivity() { - $cid1 = Contact::create()->setCheckPermissions(FALSE) + $cid1 = Contact::create(FALSE) ->addValue('first_name', 'Aaa') ->addChain('activity', Activity::create() ->addValue('activity_type_id:name', 'Meeting') @@ -235,7 +235,7 @@ class FkJoinTest extends UnitTestCase { ) ->execute() ->first()['id']; - $cid2 = Contact::create()->setCheckPermissions(FALSE) + $cid2 = Contact::create(FALSE) ->addValue('first_name', 'Bbb') ->addChain('activity', Activity::create() ->addValue('activity_type_id:name', 'Phone Call') @@ -247,7 +247,7 @@ class FkJoinTest extends UnitTestCase { ) ->execute() ->first()['id']; - $cid3 = Contact::create()->setCheckPermissions(FALSE) + $cid3 = Contact::create(FALSE) ->addValue('first_name', 'Ccc') ->addChain('activity', Activity::create() ->addValue('activity_type_id:name', 'Meeting') diff --git a/tests/phpunit/api/v4/Entity/SystemTest.php b/tests/phpunit/api/v4/Entity/SystemTest.php index 11203e70ec..435c7cb98f 100644 --- a/tests/phpunit/api/v4/Entity/SystemTest.php +++ b/tests/phpunit/api/v4/Entity/SystemTest.php @@ -50,7 +50,7 @@ class SystemTest extends UnitTestCase { $this->assertCount(1, $check); // Ensure cron check has not run - $this->assertCount(0, StatusPreference::get()->setCheckPermissions(FALSE)->addWhere('name', '=', 'checkLastCron')->execute()); + $this->assertCount(0, StatusPreference::get(FALSE)->addWhere('name', '=', 'checkLastCron')->execute()); // Will run on non-prod site with $includeDisabled. // Giving a more-specific name will run all checks with less-specific names too @@ -60,7 +60,7 @@ class SystemTest extends UnitTestCase { $this->assertEquals('Ok', $check['hook_civicrm_check']['title']); // We know the cron check has run because it would have left a record marked 'new' - $record = StatusPreference::get()->setCheckPermissions(FALSE)->addWhere('name', '=', 'checkLastCron')->execute()->first(); + $record = StatusPreference::get(FALSE)->addWhere('name', '=', 'checkLastCron')->execute()->first(); $this->assertEquals('new', $record['prefs']); // Restore env -- 2.25.1