public function GroupContentMenuTest::testNodeGroupContentMenu in Group Content Menu 8
Test creation of a group content menu with group nodes.
File
- tests/
src/ Functional/ GroupContentMenuTest.php, line 63
Class
- GroupContentMenuTest
- Test description.
Namespace
Drupal\Tests\group_content_menu\FunctionalCode
public function testNodeGroupContentMenu() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
/** @var \Behat\Mink\Element\DocumentElement $page */
$page = $this
->getSession()
->getPage();
// Create a group.
$this
->drupalGet('/group/add/default');
$page
->fillField('label[0][value]', 'Group page');
$page
->pressButton('Create Default label and complete your membership');
$page
->pressButton('Save group and membership');
$assert
->statusCodeEquals(200);
$assert
->pageTextContains('Default label Group page has been created.');
// Visit the group menu page.
$this
->drupalGet('/group/1/menus');
$assert
->statusCodeEquals(200);
$assert
->pageTextContains('There are no group content menu entities yet.');
// Generate a group content menu type.
$this
->drupalGet('admin/structure/group_content_menu_types');
$page
->clickLink('Add group menu type');
$assert
->statusCodeEquals(200);
$page
->fillField('label', 'Group Menu');
$page
->fillField('id', 'group_menu');
$page
->pressButton('Save');
$assert
->statusCodeEquals(200);
$assert
->pageTextContains('The group menu type Group Menu has been added.');
// Enable the gnode content plugin for basic page.
$this
->drupalGet('/admin/group/content/install/default/group_node:page');
$page
->pressButton('Install plugin');
$assert
->pageTextContains('The content plugin was installed on the group type.');
// Enable the gnode content plugin for article.
$this
->drupalGet('/admin/group/content/install/default/group_node:article');
$page
->pressButton('Install plugin');
$assert
->pageTextContains('The content plugin was installed on the group type.');
// Enable the group content plugin.
$this
->drupalGet('/admin/group/content/install/default/group_content_menu:group_menu');
$page
->pressButton('Install plugin');
$assert
->pageTextContains('The content plugin was installed on the group type.');
// Verify the menu settings render even when no group menu has been created.
$this
->drupalGet('/group/1/content/create/group_node:page');
$assert
->pageTextContains('Menu settings');
$assert
->pageTextContains('Parent item');
$page
->fillField('title[0][value]', 'Group node');
$page
->pressButton('Save');
$this
->drupalGet('/node/1/edit');
$assert
->statusCodeEquals(200);
// Verify the menu settings do not display if no menus are available.
$this
->drupalGet('/group/1/content/create/group_node:article');
$assert
->pageTextNotContains('Menu settings');
// Create new group content menu.
$this
->drupalGet('/group/1/menu/add');
$menu_label = $this
->randomString();
$page
->fillField('label[0][value]', $menu_label);
$page
->pressButton('Save');
// Only one group content menu instance is created.
$this
->drupalGet('/group/1/content');
$assert
->pageTextContainsOnce($menu_label);
// Verify menu settings render when a group menu has been created.
$this
->drupalGet('/group/1/content/create/group_node:page');
$assert
->pageTextContains('Menu settings');
$assert
->pageTextContains('Parent item');
$assert
->optionExists('menu[menu_parent]', $menu_label);
$page
->fillField('title[0][value]', 'Group node');
$page
->pressButton('Save');
$this
->drupalGet('/node/2/edit');
$assert
->statusCodeEquals(200);
// Verify the menu settings display, even if no default menu selected.
$this
->drupalGet('/group/1/content/create/group_node:article');
$assert
->pageTextContains('Menu settings');
$assert
->pageTextContains('Parent item');
}