Skip to content

Commit b6fad8c

Browse files
committed
Fix GroupTabTest
1 parent a3513a1 commit b6fad8c

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

src/Controller/OgAdminRoutesController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ public static function create(ContainerInterface $container) {
5757
public function overview(RouteMatchInterface $route_match) {
5858
/** @var \Drupal\Core\Entity\EntityInterface $group */
5959
$group = $route_match->getParameter('group');
60-
60+
if (is_numeric($group)) {
61+
$group = \Drupal::entityTypeManager()->getStorage('node')->load($group);
62+
}
6163
// Get list from routes.
6264
$content = [];
6365

tests/src/Functional/GroupTabTest.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ class GroupTabTest extends BrowserTestBase {
2626
*/
2727
protected $group;
2828

29-
/**
30-
* Test entity group.
31-
*
32-
* @var \Drupal\node\NodeInterface
33-
*/
34-
protected $nonGroup;
35-
3629
/**
3730
* A group bundle name.
3831
*
@@ -82,24 +75,19 @@ protected function setUp() {
8275
Og::groupTypeManager()->addGroup('node', $this->bundle1);
8376

8477
// Create node author user.
85-
$user = $this->createUser();
78+
$this->user1 = $this->drupalCreateUser(['administer group']);
79+
80+
// Create normal user.
81+
$this->user2 = $this->drupalCreateUser(['access content']);
8682

8783
// Create nodes.
8884
$this->group = Node::create([
8985
'type' => $this->bundle1,
9086
'title' => $this->randomString(),
91-
'uid' => $user->id(),
87+
'uid' => $this->user1->id(),
9288
]);
9389
$this->group->save();
9490

95-
$this->nonGroup = Node::create([
96-
'type' => $this->bundle2,
97-
'title' => $this->randomString(),
98-
'uid' => $user->id(),
99-
]);
100-
$this->nonGroup->save();
101-
102-
$this->user1 = $this->drupalCreateUser(['administer group']);
10391
}
10492

10593
/**
@@ -109,8 +97,11 @@ public function testGroupTab() {
10997
$this->drupalLogin($this->user1);
11098
$this->drupalGet('group/node/' . $this->group->id() . '/admin');
11199
$this->assertResponse(200);
100+
$this->drupalLogout();
101+
}
112102

113-
$this->drupalGet('group/node/' . $this->nonGroup->id() . '/admin');
103+
public function testGroupTabAccessDenied() {
104+
$this->drupalGet('group/node/' . $this->group->id() . '/admin');
114105
$this->assertResponse(403);
115106
}
116107

0 commit comments

Comments
 (0)