function ImageTestCase::testImageNodeDeletion in Image 6
Same name and namespace in other branches
- 7 tests/image.test \ImageTestCase::testImageNodeDeletion()
Verify that images with missing file information can be deleted from edit form.
File
- tests/
image.test, line 281
Class
- ImageTestCase
- Test image functionality.
Code
function testImageNodeDeletion() {
// Create an image.
$edit = array(
'title' => $this
->randomName(),
'body' => $this
->randomName(),
'files[image]' => realpath($this->image),
);
// Create image.
$this
->drupalPost('node/add/image', $edit, t('Save'));
$this
->assertRaw(t('@type %title has been created.', array(
'@type' => 'Image',
'%title' => $edit['title'],
)), t('Image node was created.'));
$node = node_load(array(
'title' => $edit['title'],
));
$this
->assertTrue($node, t('Image node is found in database.'));
// Remove {files} row to create corruption condition.
$this
->assertTrue(db_query("DELETE f FROM {files} f INNER JOIN {image} i WHERE f.fid = i.fid AND i.nid = %d", $node->nid), t('Image file information was deleted.'));
$node = node_load(array(
'title' => $edit['title'],
));
$this
->assertFalse(isset($node->images['_original']), t('Image file information is missing on re-loaded node.'));
$this
->drupalPost('node/' . $node->nid . '/edit', array(), t('Delete'));
$this
->assertRaw(t('Are you sure you want to delete %title?', array(
'%title' => $edit['title'],
)), t('Delete confirmation form is displayed.'));
$this
->drupalPost(NULL, array(), t('Delete'));
$this
->assertRaw(t('@type %title has been deleted.', array(
'@type' => 'Image',
'%title' => $edit['title'],
)), t('Image node was deleted.'));
}