Skip to content

Commit

Permalink
Fix GroupTabTest
Browse files Browse the repository at this point in the history
  • Loading branch information
DiDebru committed Nov 22, 2018
1 parent a3513a1 commit 0f51cb4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
6 changes: 5 additions & 1 deletion src/Controller/OgAdminRoutesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ public static function create(ContainerInterface $container) {
public function overview(RouteMatchInterface $route_match) {
/** @var \Drupal\Core\Entity\EntityInterface $group */
$group = $route_match->getParameter('group');

$entity_type_id = NULL;
if (!is_object($group)) {
$entity_type_id = $route_match->getRouteObject()->getOption('_og_entity_type_id');
$group = $route_match->getParameter($entity_type_id);
}
// Get list from routes.
$content = [];

Expand Down
27 changes: 9 additions & 18 deletions tests/src/Functional/GroupTabTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ class GroupTabTest extends BrowserTestBase {
*/
protected $group;

/**
* Test entity group.
*
* @var \Drupal\node\NodeInterface
*/
protected $nonGroup;

/**
* A group bundle name.
*
Expand Down Expand Up @@ -82,24 +75,19 @@ protected function setUp() {
Og::groupTypeManager()->addGroup('node', $this->bundle1);

// Create node author user.
$user = $this->createUser();
$this->user1 = $this->drupalCreateUser(['administer group']);

// Create normal user.
$this->user2 = $this->drupalCreateUser(['access content']);

// Create nodes.
$this->group = Node::create([
'type' => $this->bundle1,
'title' => $this->randomString(),
'uid' => $user->id(),
'uid' => $this->user1->id(),
]);
$this->group->save();

$this->nonGroup = Node::create([
'type' => $this->bundle2,
'title' => $this->randomString(),
'uid' => $user->id(),
]);
$this->nonGroup->save();

$this->user1 = $this->drupalCreateUser(['administer group']);
}

/**
Expand All @@ -109,8 +97,11 @@ public function testGroupTab() {
$this->drupalLogin($this->user1);
$this->drupalGet('group/node/' . $this->group->id() . '/admin');
$this->assertResponse(200);
$this->drupalLogout();
}

$this->drupalGet('group/node/' . $this->nonGroup->id() . '/admin');
public function testGroupTabAccessDenied() {
$this->drupalGet('group/node/' . $this->group->id() . '/admin');
$this->assertResponse(403);
}

Expand Down

0 comments on commit 0f51cb4

Please sign in to comment.