You are here

public function ImageExampleTestCase::testImageExamplePage in Examples for Developers 7

Tests for image block provided by module.

File

image_example/image_example.test, line 91
Test case for testing the image example module.

Class

ImageExampleTestCase
Functional tests for the Image Example module.

Code

public function testImageExamplePage() {

  // Login the admin user.
  $this
    ->drupalLogin($this->webUser);
  $this
    ->drupalCreateNode(array(
    'promote' => 1,
  ));

  // Upload an image to the image page.
  $images = $this
    ->drupalGetTestFiles('image');
  $edit = array(
    'files[image_example_image_fid]' => drupal_realpath($images[0]->uri),
    'image_example_style_name' => 'image_example_style',
  );
  $this
    ->drupalPost('image_example/styles', $edit, t('Save'));
  $this
    ->assertText(t('The image @image_name was uploaded', array(
    '@image_name' => $images[0]->filename,
  )), 'Image uploaded to image block.');

  // Verify the image is displayed.
  $this
    ->drupalGet('image_example/styles');
  $fid = variable_get('image_example_image_fid', FALSE);
  $image = isset($fid) ? file_load($fid) : NULL;
  $this
    ->assertRaw(file_uri_target($image->uri), 'Image is displayed');
}