You are here

public function NodeTypeTest::testNodeTypeGetFunctions in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\node\Functional\NodeTypeTest::testNodeTypeGetFunctions()

Ensures that node type functions (node_type_get_*) work correctly.

Load available node types and validate the returned data.

File

core/modules/node/tests/src/Functional/NodeTypeTest.php, line 38

Class

NodeTypeTest
Ensures that node type functions work correctly.

Namespace

Drupal\Tests\node\Functional

Code

public function testNodeTypeGetFunctions() {
  $node_types = NodeType::loadMultiple();
  $node_names = node_type_get_names();
  $this
    ->assertTrue(isset($node_types['article']), 'Node type article is available.');
  $this
    ->assertTrue(isset($node_types['page']), 'Node type basic page is available.');
  $this
    ->assertEqual($node_types['article']
    ->label(), $node_names['article'], 'Correct node type base has been returned.');
  $article = NodeType::load('article');
  $this
    ->assertEqual($node_types['article'], $article, 'Correct node type has been returned.');
  $this
    ->assertEqual($node_types['article']
    ->label(), $article
    ->label(), 'Correct node type name has been returned.');
}