Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / node / tests / src / Functional / Update / NodeUpdateTest.php
1 <?php
2
3 namespace Drupal\Tests\node\Functional\Update;
4
5 use Drupal\Core\Entity\Entity\EntityFormDisplay;
6 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
7
8 /**
9  * Tests that node settings are properly updated during database updates.
10  *
11  * @group node
12  */
13 class NodeUpdateTest extends UpdatePathTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   protected function setDatabaseDumpFiles() {
19     $this->databaseDumpFiles = [
20       __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz',
21     ];
22   }
23
24   /**
25    * Tests that the node entity type has a 'published' entity key.
26    *
27    * @see node_update_8301()
28    */
29   public function testPublishedEntityKey() {
30     // Check that the 'published' entity key does not exist prior to the update.
31     $entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('node');
32     $this->assertFalse($entity_type->getKey('published'));
33
34     // Run updates.
35     $this->runUpdates();
36
37     // Check that the entity key exists and it has the correct value.
38     $entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('node');
39     $this->assertEqual('status', $entity_type->getKey('published'));
40   }
41
42   /**
43    * Tests that the node entity form has the status checkbox.
44    *
45    * @see node_post_update_configure_status_field_widget()
46    */
47   public function testStatusCheckbox() {
48     // Run updates.
49     $this->runUpdates();
50
51     $query = \Drupal::entityQuery('entity_form_display')
52       ->condition('targetEntityType', 'node');
53     $ids = $query->execute();
54     $form_displays = EntityFormDisplay::loadMultiple($ids);
55
56     /**
57      * @var string $id
58      * @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display
59      */
60     foreach ($form_displays as $id => $form_display) {
61       $component = $form_display->getComponent('status');
62       $this->assertEqual('boolean_checkbox', $component['type']);
63       $this->assertEqual(['display_label' => TRUE], $component['settings']);
64     }
65   }
66
67 }