public function EntityDuplicateTest::testForm in Entity API 8
Tests the duplicate form.
File
- tests/
src/ Functional/ EntityDuplicateTest.php, line 67
Class
- EntityDuplicateTest
- Tests the entity duplicate UI.
Namespace
Drupal\Tests\entity\FunctionalCode
public function testForm() {
$entity = EnhancedEntity::create([
'name' => 'Test',
'type' => 'default',
]);
$entity
->save();
$this
->drupalGet($entity
->toUrl('duplicate-form'));
$this
->assertSession()
->pageTextContains('Duplicate Test');
$this
->submitForm([
'name[0][value]' => 'Test2',
], 'Save');
$this
->assertSession()
->pageTextContains('Saved the Test2 enhanced entity.');
$this->storage
->resetCache();
$entity = EnhancedEntity::load('1');
$this
->assertEquals('Test', $entity
->label());
$duplicated_entity = EnhancedEntity::load('2');
$this
->assertEquals('Test2', $duplicated_entity
->label());
}