function EntityDisplayTest::testEntityDisplayCRUDSort

Same name and namespace in other branches
  1. 8.9.x 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()
  3. 11.x core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testEntityDisplayCRUDSort()

Tests sorting of components by name on basic CRUD operations.

File

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

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->assertSame($expected, $components);
}

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