You are here

public function AspectSwitcherTest::setUp in Image Effects 8.3

Same name and namespace in other branches
  1. 8 tests/src/Functional/Effect/AspectSwitcherTest.php \Drupal\Tests\image_effects\Functional\Effect\AspectSwitcherTest::setUp()
  2. 8.2 tests/src/Functional/Effect/AspectSwitcherTest.php \Drupal\Tests\image_effects\Functional\Effect\AspectSwitcherTest::setUp()

Overrides ImageEffectsTestBase::setUp

File

tests/src/Functional/Effect/AspectSwitcherTest.php, line 46

Class

AspectSwitcherTest
AspectSwitcher effect test.

Namespace

Drupal\Tests\image_effects\Functional\Effect

Code

public function setUp() : void {
  parent::setUp();

  // Create 2 test image styles, one for landscape and one for portrait and
  // add the specific effect to each.
  foreach ([
    'landscape',
    'portrait',
  ] as $orientation) {
    $style_name = $orientation . '_image_style_test';
    $style_label = ucfirst($orientation) . ' Image Style Test';
    $style = ImageStyle::create([
      'name' => $style_name,
      'label' => $style_label,
    ]);
    $style
      ->addImageEffect($this->effects[$orientation]);
    $this
      ->assertEquals(SAVED_NEW, $style
      ->save());
  }
  $test_directory = 'public://styles/' . $this->testImageStyleName;
  $this->fileSystem
    ->prepareDirectory($test_directory, FileSystemInterface::CREATE_DIRECTORY);
}