You are here

public function EntityDisplayTest::testEntityDisplayCRUDSort in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testEntityDisplayCRUDSort()
  2. 10 core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testEntityDisplayCRUDSort()

Test sorting of components by name on basic CRUD operations

File

core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php, line 129

Class

EntityDisplayTest
Tests the entity display configuration entities.

Namespace

Drupal\Tests\field_ui\Kernel

Code

public function testEntityDisplayCRUDSort() {
  $display = EntityViewDisplay::create([
    'targetEntityType' => 'entity_test',
    'bundle' => 'entity_test',
    'mode' => 'default',
  ]);
  $display
    ->setComponent('component_3');
  $display
    ->setComponent('component_1');
  $display
    ->setComponent('component_2');
  $display
    ->save();
  $components = array_keys($display
    ->getComponents());

  // The name field is not configurable so will be added automatically.
  $expected = [
    0 => 'component_1',
    1 => 'component_2',
    2 => 'component_3',
    'name',
  ];
  $this
    ->assertIdentical($components, $expected);
}