Tests basic form CRUD functionality.
function testFormCRUD() {
$langcode = LANGUAGE_NOT_SPECIFIED;
$name1 = $this
->randomName(8);
$name2 = $this
->randomName(10);
$edit = array(
'name' => $name1,
'user_id' => mt_rand(0, 128),
"field_test_text[{$langcode}][0][value]" => $this
->randomName(16),
);
$this
->drupalPost('entity-test/add', $edit, t('Save'));
$entity = $this
->loadEntityByName($name1);
$this
->assertTrue($entity, 'Entity found in the database.');
$edit['name'] = $name2;
$this
->drupalPost('entity-test/manage/' . $entity
->id() . '/edit', $edit, t('Save'));
$entity = $this
->loadEntityByName($name1);
$this
->assertFalse($entity, 'The entity has been modified.');
$entity = $this
->loadEntityByName($name2);
$this
->assertTrue($entity, 'Modified entity found in the database.');
$this
->assertNotEqual($entity->name->value, $name1, 'The entity name has been modified.');
$this
->drupalPost('entity-test/manage/' . $entity
->id() . '/edit', array(), t('Delete'));
$entity = $this
->loadEntityByName($name2);
$this
->assertFalse($entity, 'Entity not found in the database.');
}