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.
function testAddOrphanTopic() {
// Must remove forum topics to test creating orphan topics.
$vid = 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.
$this
->drupalLogin($this->admin_user);
$this
->drupalPost('node/add/forum', array(
'title' => $this
->randomName(10),
'body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this
->randomName(120),
), 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.
module_enable(array(
'forum',
));
}