You are here

public function EntityTest::setUp in Image Replace 7

Same name and namespace in other branches
  1. 8 src/Tests/EntityTest.php \Drupal\image_replace\Tests\EntityTest::setUp()

File

src/Tests/EntityTest.php, line 28

Class

EntityTest
Tests functionality of the replace image effect.

Namespace

Drupal\image_replace\Tests

Code

public function setUp() {
  parent::setUp(array(
    'image',
    'image_replace',
  ));

  // Create an image style containing the replace effect.
  $this->styleName = 'image_replace_test';
  $this
    ->createImageStyle($this->styleName);

  // Add the replacement image field to the article bundle.
  $this
    ->createImageField('image_replacement', 'article');

  // Add the original image field to the article bundle and specify
  // the replacement image as replacement.
  $instance = $this
    ->createImageField('image_original', 'article', array(), array(
    'image_replace' => array(
      $this->styleName => array(
        'source_field' => 'image_replacement',
      ),
    ),
  ));
  $instance['display']['teaser']['type'] = 'image';
  $instance['display']['teaser']['settings']['image_style'] = $this->styleName;
  $instance['display']['full']['type'] = 'image';
  $instance['display']['full']['settings']['image_style'] = NULL;
  field_update_instance($instance);
  field_bundle_settings('node', 'article', array(
    'view_modes' => array(
      'full' => array(
        'custom_settings' => TRUE,
      ),
      'teaser' => array(
        'custom_settings' => TRUE,
      ),
    ),
  ));
}