private function ForumTest::verifyForums in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/forum/src/Tests/ForumTest.php \Drupal\forum\Tests\ForumTest::verifyForums()
Verifies that the logged in user has access to a forum node.
Parameters
\Drupal\Core\Entity\EntityInterface $node: The node being checked.
bool $admin: Boolean to indicate whether the user can 'access administration pages'.
int $response: The expected HTTP response code.
2 calls to ForumTest::verifyForums()
- ForumTest::doBasicTests in core/
modules/ forum/ src/ Tests/ ForumTest.php - Runs basic tests on the indicated user.
- ForumTest::testForum in core/
modules/ forum/ src/ Tests/ ForumTest.php - Tests forum functionality through the admin and user interfaces.
File
- core/
modules/ forum/ src/ Tests/ ForumTest.php, line 578 - Contains \Drupal\forum\Tests\ForumTest.
Class
- ForumTest
- Create, view, edit, delete, and change forum entries and verify its consistency in the database.
Namespace
Drupal\forum\TestsCode
private function verifyForums(EntityInterface $node, $admin, $response = 200) {
$response2 = $admin ? 200 : 403;
// View forum help node.
$this
->drupalGet('admin/help/forum');
$this
->assertResponse($response2);
if ($response2 == 200) {
$this
->assertTitle(t('Forum | Drupal'), 'Forum help title was displayed');
$this
->assertText(t('Forum'), 'Forum help node was displayed');
}
// View forum container page.
$this
->verifyForumView($this->forumContainer);
// View forum page.
$this
->verifyForumView($this->forum, $this->forumContainer);
// View root forum page.
$this
->verifyForumView($this->rootForum);
// View forum node.
$this
->drupalGet('node/' . $node
->id());
$this
->assertResponse(200);
$this
->assertTitle($node
->label() . ' | Drupal', 'Forum node was displayed');
$breadcrumb_build = array(
Link::createFromRoute(t('Home'), '<front>'),
Link::createFromRoute(t('Forums'), 'forum.index'),
Link::createFromRoute($this->forumContainer['name'], 'forum.page', array(
'taxonomy_term' => $this->forumContainer['tid'],
)),
Link::createFromRoute($this->forum['name'], 'forum.page', array(
'taxonomy_term' => $this->forum['tid'],
)),
);
$breadcrumb = array(
'#theme' => 'breadcrumb',
'#links' => $breadcrumb_build,
);
$this
->assertRaw(\Drupal::service('renderer')
->renderRoot($breadcrumb), 'Breadcrumbs were displayed');
// View forum edit node.
$this
->drupalGet('node/' . $node
->id() . '/edit');
$this
->assertResponse($response);
if ($response == 200) {
$this
->assertTitle('Edit Forum topic ' . $node
->label() . ' | Drupal', 'Forum edit node was displayed');
}
if ($response == 200) {
// Edit forum node (including moving it to another forum).
$edit = array();
$edit['title[0][value]'] = 'node/' . $node
->id();
$edit['body[0][value]'] = $this
->randomMachineName(256);
// Assume the topic is initially associated with $forum.
$edit['taxonomy_forums'] = $this->rootForum['tid'];
$edit['shadow'] = TRUE;
$this
->drupalPostForm('node/' . $node
->id() . '/edit', $edit, t('Save'));
$this
->assertRaw(t('Forum topic %title has been updated.', array(
'%title' => $edit['title[0][value]'],
)), 'Forum node was edited');
// Verify topic was moved to a different forum.
$forum_tid = db_query("SELECT tid FROM {forum} WHERE nid = :nid AND vid = :vid", array(
':nid' => $node
->id(),
':vid' => $node
->getRevisionId(),
))
->fetchField();
$this
->assertTrue($forum_tid == $this->rootForum['tid'], 'The forum topic is linked to a different forum');
// Delete forum node.
$this
->drupalPostForm('node/' . $node
->id() . '/delete', array(), t('Delete'));
$this
->assertResponse($response);
$this
->assertRaw(t('Forum topic %title has been deleted.', array(
'%title' => $edit['title[0][value]'],
)), 'Forum node was deleted');
}
}