1 node.test NodeTypeTestCase::testNodeTypeStatus()

Tests that node types correctly handle the 'disabled' flag.

File

core/modules/node/tests/node.test, line 1849
Tests for node.module.

Class

NodeTypeTestCase
Tests related to node types.

Code

function testNodeTypeStatus() {
  // Enable all core node modules, and all types should be active.
  module_enable(array('book'), FALSE);
  $types = node_type_get_types();
  foreach (array('book', 'post', 'page') as $type) {
    $this->assertTrue(isset($types[$type]), format_string('%type is found in node types.', array('%type' => $type)));
    $this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), format_string('%type type is enabled.', array('%type' => $type)));
  }

  // Disable book module and the respective type should still be active, since
  // it is not disabled in book_disable().
  module_disable(array('book'), FALSE);
  $types = node_type_get_types();
  $this->assertTrue(isset($types['book']) && empty($types['book']->disabled), "Book module's node type still active.");
  $this->assertTrue(isset($types['post']) && empty($types['post']->disabled), "Post node type still active.");
  $this->assertTrue(isset($types['page']) && empty($types['page']->disabled), "Page node type still active.");

  // Re-enable the modules and verify that the types are active again.
  module_enable(array('book'), FALSE);
  $types = node_type_get_types();
  foreach (array('book', 'post', 'page') as $type) {
    $this->assertTrue(isset($types[$type]), format_string('%type is found in node types.', array('%type' => $type)));
    $this->assertTrue(isset($types[$type]->disabled) && empty($types[$type]->disabled), format_string('%type type is enabled.', array('%type' => $type)));
  }
}