function ForumTest::testAddOrphanTopic in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/forum/src/Tests/ForumTest.php \Drupal\forum\Tests\ForumTest::testAddOrphanTopic()
Tests that forum nodes can't be added without a parent.
Verifies that forum nodes are not created without choosing "forum" from the select list.
File
- core/
modules/ forum/ src/ Tests/ ForumTest.php, line 260 - 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
function testAddOrphanTopic() {
// Must remove forum topics to test creating orphan topics.
$vid = $this
->config('forum.settings')
->get('vocabulary');
$tids = \Drupal::entityQuery('taxonomy_term')
->condition('vid', $vid)
->execute();
entity_delete_multiple('taxonomy_term', $tids);
// Create an orphan forum item.
$edit = array();
$edit['title[0][value]'] = $this
->randomMachineName(10);
$edit['body[0][value]'] = $this
->randomMachineName(120);
$this
->drupalLogin($this->adminUser);
$this
->drupalPostForm('node/add/forum', $edit, t('Save'));
$nid_count = db_query('SELECT COUNT(nid) FROM {node}')
->fetchField();
$this
->assertEqual(0, $nid_count, 'A forum node was not created when missing a forum vocabulary.');
// Reset the defaults for future tests.
\Drupal::service('module_installer')
->install(array(
'forum',
));
}