You are here

public function FocalPointEffectsTest::testConstrainCropArea in Focal Point 8

Test constrain logic.

@covers ::constrainCropArea

@dataProvider constrainCropAreaProvider

File

tests/src/Unit/Effects/FocalPointEffectsTest.php, line 174

Class

FocalPointEffectsTest
Tests the Focal Point image effects.

Namespace

Drupal\Tests\focal_point\Unit\Effects

Code

public function testConstrainCropArea($anchor, $image_size, $crop_size, $expected) {
  $image = $this
    ->getTestImage($image_size['width'], $image_size['height']);
  $crop = $this
    ->prophesize(CropInterface::class);
  $crop
    ->size()
    ->willReturn($crop_size);

  // Use reflection to test a private/protected method.
  $effect = $this
    ->getTestEffect();
  $effect_reflection = new \ReflectionClass(TestFocalPointEffectBase::class);
  $method = $effect_reflection
    ->getMethod('constrainCropArea');
  $method
    ->setAccessible(TRUE);
  $args = [
    $anchor,
    $image,
    $crop
      ->reveal(),
  ];
  $this
    ->assertSame($expected, $method
    ->invokeArgs($effect, $args));
}