GroupTabTest.php in Organic groups 8
File
tests/src/Functional/GroupTabTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\og\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\og\Og;
class GroupTabTest extends BrowserTestBase {
public static $modules = [
'node',
'og',
];
protected $defaultTheme = 'stark';
protected $group;
protected $bundle1;
protected $user1;
protected $user2;
protected function setUp() : void {
parent::setUp();
$this->bundle1 = mb_strtolower($this
->randomMachineName());
$this->bundle2 = mb_strtolower($this
->randomMachineName());
$node_type1 = NodeType::create([
'type' => $this->bundle1,
'name' => $this->bundle1,
]);
$node_type1
->save();
$node_type2 = NodeType::create([
'type' => $this->bundle2,
'name' => $this->bundle2,
]);
$node_type2
->save();
Og::groupTypeManager()
->addGroup('node', $this->bundle1);
$user = $this
->createUser();
$this->group = Node::create([
'type' => $this->bundle1,
'title' => $this
->randomString(),
'uid' => $user
->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 organic groups',
]);
}
public function testGroupTab() {
$this
->drupalLogin($this->user1);
$this
->drupalGet('group/node/' . $this->group
->id() . '/admin');
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalGet('group/node/' . $this->nonGroup
->id() . '/admin');
$this
->assertSession()
->statusCodeEquals(403);
}
}