You are here

public function NodeLegacyTest::testEntityLegacyCode in Drupal 8

@expectedDeprecation node_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\node\Entity\Node::loadMultiple(). See https://www.drupal.org/node/2266845 @expectedDeprecation node_load() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\node\Entity\Node::load(). See https://www.drupal.org/node/2266845 @expectedDeprecation node_type_load() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\node\Entity\NodeType::load(). See https://www.drupal.org/node/2266845

File

core/modules/node/tests/src/Kernel/NodeLegacyTest.php, line 47

Class

NodeLegacyTest
Tests legacy user functionality.

Namespace

Drupal\Tests\node\Kernel

Code

public function testEntityLegacyCode() {
  $this
    ->assertCount(0, node_load_multiple());
  Node::create([
    'type' => 'page',
    'title' => $this
      ->randomMachineName(),
  ])
    ->save();
  $this
    ->assertCount(1, node_load_multiple());
  Node::create([
    'type' => 'page',
    'title' => $this
      ->randomMachineName(),
  ])
    ->save();
  $this
    ->assertCount(2, node_load_multiple());
  $this
    ->assertNull(node_load(30));
  $this
    ->assertInstanceOf(NodeInterface::class, node_load(1));
  $this
    ->assertNull(node_type_load('a_node_type_does_not_exist'));
  $this
    ->assertInstanceOf(NodeTypeInterface::class, node_type_load('page'));
}