You are here

public function CreateUITest::testAddForm in Entity API 8.0

Tests the add form.

File

tests/src/Functional/CreateUITest.php, line 81
Contains \Drupal\Tests\entity\Functional\CreateUITest.

Class

CreateUITest
Tests the entity creation UI provided by EntityCreateController.

Namespace

Drupal\Tests\entity\Functional

Code

public function testAddForm() {
  $this
    ->drupalGet('/entity_test_enhanced/add/first');
  $assert = $this
    ->assertSession();
  $assert
    ->elementTextContains('css', '.page-title', 'Add entity test with enhancements');
  $assert
    ->elementExists('css', 'form.entity-test-enhanced-first-add-form');

  // In case of multiple bundles, the current one is a part of the page title.
  EnhancedEntityBundle::create([
    'id' => 'second',
    'label' => 'Second',
    'description' => 'The <b>second</b> bundle',
  ])
    ->save();
  $this
    ->drupalGet('/entity_test_enhanced/add/first');
  $this
    ->assertSession()
    ->elementTextContains('css', '.page-title', 'Add First');
}