function NodeUpdateTest::testPublishedEntityKey

Tests that the node entity type has a 'published' entity key.

See also

node_update_8301()

File

core/modules/node/tests/src/Functional/Update/NodeUpdateTest.php, line 30

Class

NodeUpdateTest
Tests that node settings are properly updated during database updates.

Namespace

Drupal\Tests\node\Functional\Update

Code

public function testPublishedEntityKey() {
  // Check that the 'published' entity key does not exist prior to the update.
  $entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('node');
  $this->assertFalse($entity_type->getKey('published'));
  // Run updates.
  $this->runUpdates();
  // Check that the entity key exists and it has the correct value.
  $entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('node');
  $this->assertEqual('status', $entity_type->getKey('published'));
}

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