protected function EntityFormTest::doTestFormCRUD in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/Entity/EntityFormTest.php \Drupal\Tests\system\Functional\Entity\EntityFormTest::doTestFormCRUD()
- 9 core/modules/system/tests/src/Functional/Entity/EntityFormTest.php \Drupal\Tests\system\Functional\Entity\EntityFormTest::doTestFormCRUD()
Executes the form CRUD tests for the given entity type.
Parameters
string $entity_type: The entity type to run the tests with.
1 call to EntityFormTest::doTestFormCRUD()
- EntityFormTest::testFormCRUD in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityFormTest.php - Tests basic form CRUD functionality.
File
- core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityFormTest.php, line 115
Class
- EntityFormTest
- Tests the entity form.
Namespace
Drupal\Tests\system\Functional\EntityCode
protected function doTestFormCRUD($entity_type) {
$name1 = $this
->randomMachineName(8);
$name2 = $this
->randomMachineName(10);
$edit = [
'name[0][value]' => $name1,
'field_test_text[0][value]' => $this
->randomMachineName(16),
];
$this
->drupalGet($entity_type . '/add');
$this
->submitForm($edit, 'Save');
$entity = $this
->loadEntityByName($entity_type, $name1);
$this
->assertNotNull($entity, new FormattableMarkup('%entity_type: Entity found in the database.', [
'%entity_type' => $entity_type,
]));
$edit['name[0][value]'] = $name2;
$this
->drupalGet($entity_type . '/manage/' . $entity
->id() . '/edit');
$this
->submitForm($edit, 'Save');
$entity = $this
->loadEntityByName($entity_type, $name1);
$this
->assertNull($entity, new FormattableMarkup('%entity_type: The entity has been modified.', [
'%entity_type' => $entity_type,
]));
$entity = $this
->loadEntityByName($entity_type, $name2);
$this
->assertNotNull($entity, new FormattableMarkup('%entity_type: Modified entity found in the database.', [
'%entity_type' => $entity_type,
]));
$this
->assertNotEquals($name1, $entity->name->value, new FormattableMarkup('%entity_type: The entity name has been modified.', [
'%entity_type' => $entity_type,
]));
$this
->drupalGet($entity_type . '/manage/' . $entity
->id() . '/edit');
$this
->clickLink('Delete');
$this
->submitForm([], 'Delete');
$entity = $this
->loadEntityByName($entity_type, $name2);
$this
->assertNull($entity, new FormattableMarkup('%entity_type: Entity not found in the database.', [
'%entity_type' => $entity_type,
]));
}