You are here

function ImageTestCase::testImageNodePreview in Image 7

Same name and namespace in other branches
  1. 6 tests/image.test \ImageTestCase::testImageNodePreview()

Verify image previews and proper submission.

File

tests/image.test, line 137

Class

ImageTestCase
Test image functionality.

Code

function testImageNodePreview() {

  // Setup POST data for image.
  $edit = array(
    'title' => $this
      ->randomName(),
    'body' => $this
      ->randomName(),
    'files[image]' => realpath($this->image),
  );

  // Preview image node.
  $this
    ->drupalGet('node/add/image');
  $this
    ->drupalPost(NULL, $edit, t('Preview'));

  // Save image node preview as is.
  $this
    ->drupalPost(NULL, NULL, t('Save'));

  // Verify image node was properly created.
  $node = node_load(array(
    'title' => $edit['title'],
  ));
  $this
    ->assertTrue($node, t('Image node is found in database.'));
  $this
    ->assertTrue(file_exists($node->images['_original']), t('Original image exists.'));
  $filename = preg_replace('/_[^\\.]+/', '', basename($node->images['_original']));
  $this
    ->assertTrue($filename == basename($this->image), t('Image file was properly stored.'));
}