Skip to content

Commit

Permalink
Update tests to use group keys that match the group ids.
Browse files Browse the repository at this point in the history
  • Loading branch information
finnlewis committed Apr 19, 2024
1 parent c247bc8 commit cc45dd0
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ protected function setUp(): void {

$this->createMicrositeGroups([], 2);
$this->createMicrositeGroupsDomains($this->groups);
$this->domain1 = $this->getDomainFromGroup($this->groups[0]);
$this->domain2 = $this->getDomainFromGroup($this->groups[1]);
$this->domain1 = $this->getDomainFromGroup($this->groups[1]);
$this->domain2 = $this->getDomainFromGroup($this->groups[2]);

// Create some directory content.
$this->channel1 = $this->createDirectoryChannel($this->groups[0]);
$this->pages1 = $this->createDirectoryPages($this->channel1, $this->groups[0], 2);
$this->channel2 = $this->createDirectoryChannel($this->groups[1]);
$this->pages2 = $this->createDirectoryPages($this->channel2, $this->groups[1], 2);
$this->channel1 = $this->createDirectoryChannel($this->groups[1]);
$this->pages1 = $this->createDirectoryPages($this->channel1, $this->groups[1], 2);
$this->channel2 = $this->createDirectoryChannel($this->groups[2]);
$this->pages2 = $this->createDirectoryPages($this->channel2, $this->groups[2], 2);

// Index directory content.
$index = Index::load('localgov_directories_index_default');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ protected function setUp(): void {

$this->createMicrositeGroups([], 2);
$this->createMicrositeGroupsDomains($this->groups);
$this->domain1 = $this->getDomainFromGroup($this->groups[0]);
$this->domain2 = $this->getDomainFromGroup($this->groups[1]);
$this->domain1 = $this->getDomainFromGroup($this->groups[1]);
$this->domain2 = $this->getDomainFromGroup($this->groups[2]);

// Create a user.
$this->user = $this->drupalCreateUser();
$this->groups[0]->addMember($this->user, ['group_roles' => ['microsite-admin']]);
$this->groups[1]->addMember($this->user, ['group_roles' => ['microsite-admin']]);
$this->groups[2]->addMember($this->user, ['group_roles' => ['microsite-admin']]);
}

/**
Expand All @@ -87,14 +87,14 @@ public function testMicrositeDirectoryFacetForms() {
// Create facet type.
$type_listing_url = Url::fromRoute('entity.group_relationship.group_localgov_directories_facet_type.list',
[
'group' => $this->groups[0]->id(),
'group' => $this->groups[1]->id(),
],
)->toString();
$this->drupalGet($this->domain1->getUrl() . $type_listing_url);
$this->assertSession()->pageTextNotContains($facet_type);
$type_add_url = Url::fromRoute('entity.group_relationship.group_localgov_directories_facet_type.add',
[
'group' => $this->groups[0]->id(),
'group' => $this->groups[1]->id(),
],
)->toString();
$this->drupalGet($this->domain1->getUrl() . $type_add_url);
Expand All @@ -108,15 +108,15 @@ public function testMicrositeDirectoryFacetForms() {
// Create facet.
$facet_listing_url = Url::fromRoute('view.lgms_group_directory_facets.page',
[
'group' => $this->groups[0]->id(),
'group' => $this->groups[1]->id(),
'localgov_directories_facets_type' => $facet_type_id,
],
)->toString();
$this->drupalGet($this->domain1->getUrl() . $facet_listing_url);
$this->assertSession()->pageTextContains('There are no directory facets yet.');
$facet_add_url = Url::fromRoute('entity.group_relationship.group_localgov_directories_facets.add',
[
'group' => $this->groups[0]->id(),
'group' => $this->groups[1]->id(),
'localgov_directories_facets_type' => $facet_type_id,
],
)->toString();
Expand All @@ -137,7 +137,7 @@ public function testMicrositeDirectoryFacetForms() {
// Check facet type is listed.
$type_listing_url = Url::fromRoute('entity.group_relationship.group_localgov_directories_facet_type.list',
[
'group' => $this->groups[1]->id(),
'group' => $this->groups[2]->id(),
],
)->toString();
$this->drupalGet($this->domain2->getUrl() . $type_listing_url);
Expand All @@ -146,7 +146,7 @@ public function testMicrositeDirectoryFacetForms() {
// Check facet isn't listed.
$facet_listing_url = Url::fromRoute('view.lgms_group_directory_facets.page',
[
'group' => $this->groups[1]->id(),
'group' => $this->groups[2]->id(),
'localgov_directories_facets_type' => $facet_type_id,
],
)->toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ protected function setUp(): void {

$this->createMicrositeGroups([], 2);
$this->createMicrositeGroupsDomains($this->groups);
$this->domain1 = $this->getDomainFromGroup($this->groups[0]);
$this->domain2 = $this->getDomainFromGroup($this->groups[1]);
$this->domain1 = $this->getDomainFromGroup($this->groups[1]);
$this->domain2 = $this->getDomainFromGroup($this->groups[2]);

// Create some content.
$this->pages1 = $this->createEvents($this->groups[0], 2);
$this->pages2 = $this->createEvents($this->groups[1], 2);
$this->pages1 = $this->createEvents($this->groups[1], 2);
$this->pages2 = $this->createEvents($this->groups[2], 2);

// Index events.
$index = Index::load('localgov_events');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ protected function setUp(): void {

$this->createMicrositeGroups([], 2);
$this->createMicrositeGroupsDomains($this->groups);
$this->domain1 = $this->getDomainFromGroup($this->groups[0]);
$this->domain2 = $this->getDomainFromGroup($this->groups[1]);
$this->domain1 = $this->getDomainFromGroup($this->groups[1]);
$this->domain2 = $this->getDomainFromGroup($this->groups[2]);

// Create some directory content.
$this->newsroom1 = $this->createNewsroom($this->groups[0]);
$this->article1 = $this->createNewsArticles($this->newsroom1, $this->groups[0], 2);
$this->newsroom2 = $this->createNewsroom($this->groups[1]);
$this->article2 = $this->createNewsArticles($this->newsroom2, $this->groups[1], 2);
$this->newsroom1 = $this->createNewsroom($this->groups[1]);
$this->article1 = $this->createNewsArticles($this->newsroom1, $this->groups[1], 2);
$this->newsroom2 = $this->createNewsroom($this->groups[2]);
$this->article2 = $this->createNewsArticles($this->newsroom2, $this->groups[2], 2);

// Index directory content.
$index = Index::load('localgov_news');
Expand Down
6 changes: 3 additions & 3 deletions tests/src/Functional/GroupInvitationAccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ protected function setUp(): void {
$this->createMicrositeGroups([
'uid' => $this->ownerUser->id(),
]);
$this->groups[0]->addMember($this->adminUser, ['group_roles' => 'microsite-admin']);
$this->groups[0]->addMember($this->memberUser);
$this->groups[1]->addMember($this->adminUser, ['group_roles' => 'microsite-admin']);
$this->groups[1]->addMember($this->memberUser);
$this->createMicrositeGroupsDomains($this->groups);
}

/**
* Test content access when unique group access is enabled.
*/
public function testInvitationPermissions() {
$group = $this->groups[0];
$group = $this->groups[1];

// Admin can check invitations.
$this->drupalLogin($this->adminUser);
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Functional/LoginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testLoginRedirect() {
// Can't use drupalLogin as we want to do it on the form with the microsite
// domain.
// @todo move this into a trait, probably on domain_group.
$ga1_domain = $this->getDomainFromGroup($this->groups[0]);
$ga1_domain = $this->getDomainFromGroup($this->groups[1]);
assert($ga1_domain instanceof DomainInterface);
$this->drupalGet($ga1_domain->getUrl() . Url::fromRoute('user.login')->toString());
$this->submitForm([
Expand Down
10 changes: 5 additions & 5 deletions tests/src/Functional/MicrositeSitewideSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ protected function setUp(): void {

$this->createMicrositeGroups([], 2);
$this->createMicrositeGroupsDomains($this->groups);
$this->domain1 = $this->getDomainFromGroup($this->groups[0]);
$this->domain2 = $this->getDomainFromGroup($this->groups[1]);
$this->domain1 = $this->getDomainFromGroup($this->groups[1]);
$this->domain2 = $this->getDomainFromGroup($this->groups[2]);

// Create some content.
$this->pages1 = [
$this->createPage($this->groups[0]),
$this->createPage($this->groups[0]),
$this->createPage($this->groups[1]),
$this->createPage($this->groups[1]),
];
$this->pages2 = [$this->createPage($this->groups[1])];
$this->pages2 = [$this->createPage($this->groups[2])];

// Index directory content.
$index = Index::load('localgov_sitewide_search');
Expand Down
8 changes: 4 additions & 4 deletions tests/src/Functional/ModuleSettingsFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ protected function setUp(): void {
$this->createMicrositeGroups([
'uid' => $this->ownerUser->id(),
]);
$this->groups[0]->addMember($this->adminUser, ['group_roles' => 'microsite-admin']);
$this->groups[0]->addMember($this->memberUser);
$this->groups[1]->addMember($this->adminUser, ['group_roles' => 'microsite-admin']);
$this->groups[1]->addMember($this->memberUser);
$this->createMicrositeGroupsDomains($this->groups);
}

/**
* Test group domain settings form.
*/
public function testDomainGroupForm() {
$group = $this->groups[0];
$group = $this->groups[1];
// Going to domain group settings form.
$this->drupalLogin($this->adminUser);
\Drupal::service('group_sites.admin_mode')->setAdminMode(TRUE);
Expand Down Expand Up @@ -105,7 +105,7 @@ public function testDomainGroupForm() {
* Test access to group management pages.
*/
public function testGroupManagementAccess() {
$group = $this->groups[0];
$group = $this->groups[1];

// Test admin access.
$this->drupalLogin($this->adminUser);
Expand Down

0 comments on commit cc45dd0

Please sign in to comment.