function NodeTypeTest::testNodeTypeGetFunctions

Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\node\Functional\NodeTypeTest::testNodeTypeGetFunctions()
  2. 8.9.x core/modules/node/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\node\Functional\NodeTypeTest::testNodeTypeGetFunctions()
  3. 10 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 41

Class

NodeTypeTest
Ensures that node type functions work correctly.

Namespace

Drupal\Tests\node\Functional

Code

public function testNodeTypeGetFunctions() : void {
    $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->assertEquals($node_names['article'], $node_types['article']->label(), 'Correct node type base has been returned.');
    $article = NodeType::load('article');
    $this->assertEquals($node_types['article'], $article, 'Correct node type has been returned.');
    $this->assertEquals($node_types['article']->label(), $article->label(), 'Correct node type name has been returned.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.