function EntityDisplayRepositoryTest::testFormDisplay

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayRepositoryTest.php \Drupal\KernelTests\Core\Entity\EntityDisplayRepositoryTest::testFormDisplay()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayRepositoryTest.php \Drupal\KernelTests\Core\Entity\EntityDisplayRepositoryTest::testFormDisplay()
  3. 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayRepositoryTest.php \Drupal\KernelTests\Core\Entity\EntityDisplayRepositoryTest::testFormDisplay()

@covers ::getFormDisplay

File

core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayRepositoryTest.php, line 82

Class

EntityDisplayRepositoryTest
@coversDefaultClass \Drupal\Core\Entity\EntityDisplayRepository

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testFormDisplay() {
    $display = $this->displayRepository
        ->getFormDisplay('user', 'user');
    $this->assertInstanceOf(EntityFormDisplayInterface::class, $display);
    $this->assertTrue($display->isNew(), 'Default form display was created on demand.');
    $this->assertSame(EntityDisplayRepositoryInterface::DEFAULT_DISPLAY_MODE, $display->getMode());
    $display->createCopy('register')
        ->save();
    $display = $this->displayRepository
        ->getFormDisplay('user', 'user', 'register');
    $this->assertInstanceOf(EntityFormDisplayInterface::class, $display);
    $this->assertFalse($display->isNew(), 'An existing form display was loaded.');
    $this->assertSame('register', $display->getMode());
    $display = $this->displayRepository
        ->getFormDisplay('user', 'user', 'magic');
    $this->assertInstanceOf(EntityFormDisplayInterface::class, $display);
    $this->assertTrue($display->isNew(), 'A new non-default form display was created on demand.');
    $this->assertSame('magic', $display->getMode());
}

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