From 19d60c08db0ef36a33f0b797184395b4c63e8432 Mon Sep 17 00:00:00 2001 From: Finn Lewis Date: Tue, 5 Nov 2024 11:23:46 +0000 Subject: [PATCH] Fix some of the failing tests. (#519) * Fix some of the failing tests. * The test context service returns group 1 don't enable it until (or just before) that group is actually created to be able to be returned. --------- Co-authored-by: ekes --- tests/src/Kernel/ContentTypeHelperTest.php | 6 ++++++ tests/src/Kernel/GroupDefaultContentTest.php | 6 ++++++ tests/src/Kernel/UserRoleTest.php | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/tests/src/Kernel/ContentTypeHelperTest.php b/tests/src/Kernel/ContentTypeHelperTest.php index 0225ec6..0609a2d 100644 --- a/tests/src/Kernel/ContentTypeHelperTest.php +++ b/tests/src/Kernel/ContentTypeHelperTest.php @@ -63,6 +63,12 @@ class ContentTypeHelperTest extends GroupKernelTestBase { protected function setUp(): void { parent::setUp(); + // Set config that group_sites needs to run tests. + $this->config('group_sites.settings') + ->set('no_site_access_policy', 'group_sites.no_site_access_policy.do_nothing') + ->set('site_access_policy', 'group_sites.site_access_policy.single') + ->save(); + // You really don't want to install localgov_page or localgov_events in a // Kernel test! NodeType::create([ diff --git a/tests/src/Kernel/GroupDefaultContentTest.php b/tests/src/Kernel/GroupDefaultContentTest.php index 26848d4..4cf0b1d 100644 --- a/tests/src/Kernel/GroupDefaultContentTest.php +++ b/tests/src/Kernel/GroupDefaultContentTest.php @@ -56,6 +56,12 @@ class GroupDefaultContentTest extends GroupKernelTestBase { protected function setUp(): void { parent::setUp(); + // Set config that group_sites needs to run tests. + $this->config('group_sites.settings') + ->set('no_site_access_policy', 'group_sites.no_site_access_policy.do_nothing') + ->set('site_access_policy', 'group_sites.site_access_policy.single') + ->save(); + $this->installEntitySchema('group_content_menu'); $this->installSchema('node', 'node_access'); diff --git a/tests/src/Kernel/UserRoleTest.php b/tests/src/Kernel/UserRoleTest.php index c7f17f4..ab08ac6 100644 --- a/tests/src/Kernel/UserRoleTest.php +++ b/tests/src/Kernel/UserRoleTest.php @@ -22,6 +22,7 @@ class UserRoleTest extends GroupKernelTestBase { 'group', 'group_content_menu', 'group_sites', + 'group_sites_test', 'image', 'media', 'media_library', @@ -60,6 +61,12 @@ protected function setUp(): void { * Test the addition and removal of Trusted Editor role to group members. */ public function testTrustedEditor() { + // Set config that group_sites needs to run tests. + $this->config('group_sites.settings') + ->set('context_provider', '@group_sites_test.hardcoded_group_context:group') + ->set('no_site_access_policy', 'group_sites.no_site_access_policy.do_nothing') + ->set('site_access_policy', 'group_sites.site_access_policy.single') + ->save(); // Create some groups. $group1 = Group::create([