1 node.test | NodeTypeTestCase::testNodeTypeHasContent() |
Ensures that node_type_has_content function works correctly.
Add new node type and test function returns correct result with and without content present.
File
- core/
modules/ node/ tests/ node.test, line 2229 - Tests for node.module.
Class
- NodeTypeTestCase
- Tests related to node types.
Code
function testNodeTypeHasContent() {
// Delete the two default nodes.
node_delete_multiple(array(1, 2));
// Test node type to assert no content has been created.
$this->assertFalse(node_type_has_content('post'), 'The post node type has no content associated with it.');
// Create a post.
$node = new Node();
$node->type = 'post';
node_object_prepare($node);
$node->title = 'A new post';
node_save($node);
// Test node type to assert content has been created.
$this->assertTrue(node_type_has_content('post'), 'The post node type has content associated with it.');
}