You are here

function ImageTestCase::__testImageNodeValidationAsync in Image 7

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

Verify that images can be created in parallel (session handling).

@todo Doesn't look valid. Can SimpleTest support this at all? @todo testImageCreateNodeFrom() fails is this test is run.

File

tests/image.test, line 166

Class

ImageTestCase
Test image functionality.

Code

function __testImageNodeValidationAsync() {

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

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

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

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

  // Save the first image node.
  $this
    ->drupalPost(NULL, $edit1, t('Save'));

  // Save the second image node.
  $this
    ->drupalPost('node/add/image', $edit2, t('Save'));

  // Verify first image node contains the first image.
  $node = node_load(array(
    'title' => $edit1['title'],
  ));
  $filename = preg_replace('/_[^\\.]+/', '', basename($node->images['_original']));
  $this
    ->assertTrue($filename == basename($this->image), t('First image was properly submitted.'));

  // Verify second image node contains the second image.
  $node = node_load(array(
    'title' => $edit2['title'],
  ));
  $filename = preg_replace('/_[^\\.]+/', '', basename($node->images['_original']));
  $this
    ->assertTrue($filename == basename($this->another_image), t('Second image was properly submitted.'));
}