<?php
namespace Drupal\node\Tests;
class NodeTypePersistenceTest extends NodeTestBase {
public static $modules = array(
'history',
'taxonomy',
'options',
'comment',
);
public static function getInfo() {
return array(
'name' => 'Node type persist',
'description' => 'Ensures that node type customization survives module enabling and disabling.',
'group' => 'Node',
);
}
function testNodeTypeCustomizationPersistence() {
$web_user = $this
->drupalCreateUser(array(
'bypass node access',
'administer content types',
'administer modules',
));
$this
->drupalLogin($web_user);
$forum_key = 'modules[Core][forum][enable]';
$forum_enable = array(
$forum_key => "1",
);
$forum_disable = array(
$forum_key => FALSE,
);
$this
->drupalPost('admin/modules', $forum_enable, t('Save configuration'));
$disabled = db_query('SELECT disabled FROM {node_type} WHERE type = :type', array(
':type' => 'forum',
))
->fetchField();
$this
->assertNotIdentical($disabled, FALSE, 'Forum node type found in the database');
$this
->assertEqual($disabled, 0, 'Forum node type is not disabled');
$this
->drupalGet('node/add');
$this
->assertText('forum', 'forum type is found on node/add');
$description = $this
->randomName();
$edit = array(
'description' => $description,
);
$this
->drupalPost('admin/structure/types/manage/forum', $edit, t('Save content type'));
$this
->drupalGet('node/add');
$this
->assertText($description, 'Customized description found');
$this
->drupalPost('admin/modules', $forum_disable, t('Save configuration'));
$disabled = db_query('SELECT disabled FROM {node_type} WHERE type = :type', array(
':type' => 'forum',
))
->fetchField();
$this
->assertEqual($disabled, 1, 'Forum node type is disabled');
$this
->drupalGet('node/add');
$this
->assertNoText('forum', 'forum type is not found on node/add');
$this
->drupalPost('admin/modules', $forum_enable, t('Save configuration'));
$disabled = db_query('SELECT disabled FROM {node_type} WHERE type = :type', array(
':type' => 'forum',
))
->fetchField();
$this
->assertNotIdentical($disabled, FALSE, 'Forum node type found in the database');
$this
->assertEqual($disabled, 0, 'Forum node type is not disabled');
$this
->drupalGet('node/add');
$this
->assertText($description, 'Customized description found');
$this
->drupalPost('admin/modules', $forum_disable, t('Save configuration'));
$edit = array(
'uninstall[forum]' => 'forum',
);
$this
->drupalPost('admin/modules/uninstall', $edit, t('Uninstall'));
$this
->drupalPost(NULL, array(), t('Uninstall'));
$disabled = db_query('SELECT disabled FROM {node_type} WHERE type = :type', array(
':type' => 'forum',
))
->fetchField();
$this
->assertTrue($disabled, 'Forum node type is in the database and is disabled');
$this
->drupalGet('node/add');
$this
->assertNoText('forum', 'forum type is no longer found on node/add');
$this
->drupalPost('admin/modules', $forum_enable, t('Save configuration'));
$this
->drupalGet('node/add');
$this
->assertText($description, 'Customized description is found even after uninstall and reenable.');
}
}