private function ForumTest::doAdminTests in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/forum/src/Tests/ForumTest.php \Drupal\forum\Tests\ForumTest::doAdminTests()
Runs admin tests on the admin user.
Parameters
object $user: The logged-in user.
1 call to ForumTest::doAdminTests()
- 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 288 - 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 doAdminTests($user) {
// Login the user.
$this
->drupalLogin($user);
// Add forum to the Tools menu.
$edit = array();
$this
->drupalPostForm('admin/structure/menu/manage/tools', $edit, t('Save'));
$this
->assertResponse(200);
// Edit forum taxonomy.
// Restoration of the settings fails and causes subsequent tests to fail.
$this
->editForumVocabulary();
// Create forum container.
$this->forumContainer = $this
->createForum('container');
// Verify "edit container" link exists and functions correctly.
$this
->drupalGet('admin/structure/forum');
// Verify help text is shown.
$this
->assertText(t('Forums contain forum topics. Use containers to group related forums'));
// Verify action links are there.
$this
->assertLink('Add forum');
$this
->assertLink('Add container');
$this
->clickLink('edit container');
$this
->assertRaw('Edit container', 'Followed the link to edit the container');
// Create forum inside the forum container.
$this->forum = $this
->createForum('forum', $this->forumContainer['tid']);
// Verify the "edit forum" link exists and functions correctly.
$this
->drupalGet('admin/structure/forum');
$this
->clickLink('edit forum');
$this
->assertRaw('Edit forum', 'Followed the link to edit the forum');
// Navigate back to forum structure page.
$this
->drupalGet('admin/structure/forum');
// Create second forum in container, destined to be deleted below.
$delete_forum = $this
->createForum('forum', $this->forumContainer['tid']);
// Save forum overview.
$this
->drupalPostForm('admin/structure/forum/', array(), t('Save'));
$this
->assertRaw(t('The configuration options have been saved.'));
// Delete this second forum.
$this
->deleteForum($delete_forum['tid']);
// Create forum at the top (root) level.
$this->rootForum = $this
->createForum('forum');
// Test vocabulary form alterations.
$this
->drupalGet('admin/structure/taxonomy/manage/forums');
$this
->assertFieldByName('op', t('Save'), 'Save button found.');
$this
->assertNoFieldByName('op', t('Delete'), 'Delete button not found.');
// Test term edit form alterations.
$this
->drupalGet('taxonomy/term/' . $this->forumContainer['tid'] . '/edit');
// Test parent field been hidden by forum module.
$this
->assertNoField('parent[]', 'Parent field not found.');
// Create a default vocabulary named "Tags".
$description = 'Use tags to group articles on similar topics into categories.';
$help = 'Enter a comma-separated list of words to describe your content.';
$vocabulary = entity_create('taxonomy_vocabulary', array(
'name' => 'Tags',
'description' => $description,
'vid' => 'tags',
'langcode' => \Drupal::languageManager()
->getDefaultLanguage()
->getId(),
'help' => $help,
));
$vocabulary
->save();
// Test tags vocabulary form is not affected.
$this
->drupalGet('admin/structure/taxonomy/manage/tags');
$this
->assertFieldByName('op', t('Save'), 'Save button found.');
$this
->assertLink(t('Delete'));
// Test tags vocabulary term form is not affected.
$this
->drupalGet('admin/structure/taxonomy/manage/tags/add');
$this
->assertField('parent[]', 'Parent field found.');
// Test relations widget exists.
$relations_widget = $this
->xpath("//details[@id='edit-relations']");
$this
->assertTrue(isset($relations_widget[0]), 'Relations widget element found.');
}