Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/node/tests/src/Kernel/NodeLegacyTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\node\Kernel; | |
4 | |
5 use Drupal\KernelTests\Core\Entity\EntityKernelTestBase; | |
6 use Drupal\node\Entity\Node; | |
7 use Drupal\node\Entity\NodeType; | |
8 use Drupal\node\NodeInterface; | |
9 use Drupal\node\NodeTypeInterface; | |
10 | |
11 /** | |
12 * Tests legacy user functionality. | |
13 * | |
14 * @group user | |
15 * @group legacy | |
16 */ | |
17 class NodeLegacyTest extends EntityKernelTestBase { | |
18 | |
19 /** | |
20 * Modules to enable. | |
21 * | |
22 * @var array | |
23 */ | |
24 public static $modules = ['node']; | |
25 | |
26 /** | |
27 * {@inheritdoc} | |
28 */ | |
29 protected function setUp() { | |
30 parent::setUp(); | |
31 | |
32 // Create the node bundles required for testing. | |
33 $type = NodeType::create([ | |
34 'type' => 'page', | |
35 'name' => 'page', | |
36 ]); | |
37 $type->save(); | |
38 | |
39 $this->installSchema('node', 'node_access'); | |
40 } | |
41 | |
42 /** | |
43 * @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 | |
44 * @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 | |
45 * @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 | |
46 */ | |
47 public function testEntityLegacyCode() { | |
48 $this->assertCount(0, node_load_multiple()); | |
49 Node::create([ | |
50 'type' => 'page', | |
51 'title' => $this->randomMachineName(), | |
52 ])->save(); | |
53 $this->assertCount(1, node_load_multiple()); | |
54 Node::create([ | |
55 'type' => 'page', | |
56 'title' => $this->randomMachineName(), | |
57 ])->save(); | |
58 $this->assertCount(2, node_load_multiple()); | |
59 | |
60 $this->assertNull(node_load(30)); | |
61 $this->assertInstanceOf(NodeInterface::class, node_load(1)); | |
62 $this->assertNull(node_type_load('a_node_type_does_not_exist')); | |
63 $this->assertInstanceOf(NodeTypeInterface::class, node_type_load('page')); | |
64 } | |
65 | |
66 } |