protected function EntityFormTest::doTestFormCRUD in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Entity/EntityFormTest.php \Drupal\system\Tests\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/ src/ Tests/ Entity/ EntityFormTest.php - Tests basic form CRUD functionality.
File
- core/
modules/ system/ src/ Tests/ Entity/ EntityFormTest.php, line 73 - Contains \Drupal\system\Tests\Entity\EntityFormTest.
Class
- EntityFormTest
- Tests the entity form.
Namespace
Drupal\system\Tests\EntityCode
protected function doTestFormCRUD($entity_type) {
$name1 = $this
->randomMachineName(8);
$name2 = $this
->randomMachineName(10);
$edit = array(
'name[0][value]' => $name1,
'field_test_text[0][value]' => $this
->randomMachineName(16),
);
$this
->drupalPostForm($entity_type . '/add', $edit, t('Save'));
$entity = $this
->loadEntityByName($entity_type, $name1);
$this
->assertTrue($entity, format_string('%entity_type: Entity found in the database.', array(
'%entity_type' => $entity_type,
)));
$edit['name[0][value]'] = $name2;
$this
->drupalPostForm($entity_type . '/manage/' . $entity
->id() . '/edit', $edit, t('Save'));
$entity = $this
->loadEntityByName($entity_type, $name1);
$this
->assertFalse($entity, format_string('%entity_type: The entity has been modified.', array(
'%entity_type' => $entity_type,
)));
$entity = $this
->loadEntityByName($entity_type, $name2);
$this
->assertTrue($entity, format_string('%entity_type: Modified entity found in the database.', array(
'%entity_type' => $entity_type,
)));
$this
->assertNotEqual($entity->name->value, $name1, format_string('%entity_type: The entity name has been modified.', array(
'%entity_type' => $entity_type,
)));
$this
->drupalGet($entity_type . '/manage/' . $entity
->id() . '/edit');
$this
->clickLink(t('Delete'));
$this
->drupalPostForm(NULL, array(), t('Delete'));
$entity = $this
->loadEntityByName($entity_type, $name2);
$this
->assertFalse($entity, format_string('%entity_type: Entity not found in the database.', array(
'%entity_type' => $entity_type,
)));
}