3 namespace Drupal\metatag\Tests;
5 use Drupal\simpletest\WebTestBase;
8 * Ensures that meta tags are rendering correctly on forum pages.
12 class MetatagForumTest extends WebTestBase {
17 public static $modules = [
26 * Administrator user for tests.
28 * @var \Drupal\user\UserInterface
33 * Setup basic environment.
35 protected function setUp() {
38 $admin_permissions = [
41 'administer meta tags',
42 'administer site configuration',
46 // Create and login user.
47 $this->adminUser = $this->drupalCreateUser($admin_permissions);
48 $this->drupalLogin($this->adminUser);
50 // Create content type.
51 $this->drupalCreateContentType(['type' => 'page', 'display_submitted' => FALSE]);
52 $this->nodeId = $this->drupalCreateNode(
54 'title' => $this->randomMachineName(8),
58 $this->config('system.site')->set('page.front', '/node/' . $this->nodeId)->save();
62 * Verify that a forum post can be loaded when Metatag is enabled.
64 public function testForumPost() {
65 $this->drupalGet('node/add/forum');
66 $this->assertResponse(200);
68 'title[0][value]' => 'Testing forums',
69 'taxonomy_forums' => 1,
70 'body[0][value]' => 'Just testing.',
72 $save_label = (floatval(\Drupal::VERSION) <= 8.3) ? t('Save and publish') : t('Save');
73 $this->drupalPostForm(NULL, $edit, $save_label);
74 $this->assertResponse(200);
75 $this->assertText(t('@type @title has been created.', ['@type' => t('Forum topic'), '@title' => 'Testing forums']));