NodeUpdateTest.php 1.95 KB
Newer Older
1 2
<?php

3
namespace Drupal\Tests\node\Functional\Update;
4

5
use Drupal\Core\Entity\Entity\EntityFormDisplay;
6
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
7 8 9 10 11 12 13 14 15 16 17 18 19

/**
 * Tests that node settings are properly updated during database updates.
 *
 * @group node
 */
class NodeUpdateTest extends UpdatePathTestBase {

  /**
   * {@inheritdoc}
   */
  protected function setDatabaseDumpFiles() {
    $this->databaseDumpFiles = [
20
      __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz',
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
    ];
  }

  /**
   * Tests that the node entity type has a 'published' entity key.
   *
   * @see node_update_8301()
   */
  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'));
  }

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
  /**
   * Tests that the node entity form has the status checkbox.
   *
   * @see node_post_update_configure_status_field_widget()
   */
  public function testStatusCheckbox() {
    // Run updates.
    $this->runUpdates();

    $query = \Drupal::entityQuery('entity_form_display')
      ->condition('targetEntityType', 'node');
    $ids = $query->execute();
    $form_displays = EntityFormDisplay::loadMultiple($ids);

    /**
     * @var string $id
     * @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display
     */
    foreach ($form_displays as $id => $form_display) {
      $component = $form_display->getComponent('status');
      $this->assertEqual('boolean_checkbox', $component['type']);
      $this->assertEqual(['display_label' => TRUE], $component['settings']);
    }
  }

67
}