You are here

protected function ImageEffectsTestBase::assertTextOverlay in Image Effects 8

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/ImageEffectsTestBase.php \Drupal\Tests\image_effects\Functional\ImageEffectsTestBase::assertTextOverlay()
  2. 8.2 tests/src/Functional/ImageEffectsTestBase.php \Drupal\Tests\image_effects\Functional\ImageEffectsTestBase::assertTextOverlay()

Asserts a Text overlay image.

1 call to ImageEffectsTestBase::assertTextOverlay()
TextOverlayTest::testTextOverlayEffect in tests/src/Functional/Effect/TextOverlayTest.php
Text overlay effect test.

File

tests/src/Functional/ImageEffectsTestBase.php, line 346

Class

ImageEffectsTestBase
Base test class for image_effects tests.

Namespace

Drupal\Tests\image_effects\Functional

Code

protected function assertTextOverlay($image, $width, $height) {
  $w_error = abs($image
    ->getWidth() - $width);
  $h_error = abs($image
    ->getHeight() - $height);
  $tolerance = 0.1;
  $this
    ->assertTrue($w_error < $width * $tolerance && $h_error < $height * $tolerance, "Width and height ({$image->getWidth()}x{$image->getHeight()}) approximate expected results ({$width}x{$height})");
}