diff --git a/src/FocalPointEffectBase.php b/src/FocalPointEffectBase.php index 41d259a..9d1b7ca 100644 --- a/src/FocalPointEffectBase.php +++ b/src/FocalPointEffectBase.php @@ -240,6 +240,8 @@ abstract class FocalPointEffectBase extends ResizeImageEffect implements Contain * Get the 'focal_point_preview_value' query string value. * * @return string|NULL + * + * @codeCoverageIgnore */ protected function getPreviewValue() { return \Drupal::request()->query->get('focal_point_preview_value'); diff --git a/tests/src/Unit/Effects/FocalPointEffectsTest.php b/tests/src/Unit/Effects/FocalPointEffectsTest.php index 9f74ecf..c599a0d 100644 --- a/tests/src/Unit/Effects/FocalPointEffectsTest.php +++ b/tests/src/Unit/Effects/FocalPointEffectsTest.php @@ -11,6 +11,7 @@ use Drupal\Core\Config\ImmutableConfig; use Drupal\Core\Image\ImageInterface; use Drupal\crop\CropInterface; use Drupal\crop\CropStorageInterface; +use Drupal\focal_point\FocalPointManager; use Drupal\focal_point\Plugin\ImageEffect\FocalPointCropImageEffect; use Drupal\focal_point\FocalPointEffectBase; use Psr\Log\LoggerInterface; @@ -40,7 +41,7 @@ class FocalPointEffectsTest extends FocalPointUnitTestCase { $crop_storage = $this->prophesize(CropStorageInterface::class); $focal_point_config = $this->prophesize(ImmutableConfig::class); - $effect = new FocalPointCropImageEffect([], 'plugin_id', [], $logger->reveal(), $crop_storage->reveal(), $focal_point_config->reveal()); + $effect = new FocalPointCropImageEffect([], 'plugin_id', [], $logger->reveal(), $this->focalPointManager, $crop_storage->reveal(), $focal_point_config->reveal()); $this->assertAttributeEquals($crop_storage->reveal(), 'cropStorage', $effect); $this->assertAttributeEquals($focal_point_config->reveal(), 'focalPointConfig', $effect); } @@ -96,7 +97,7 @@ class FocalPointEffectsTest extends FocalPointUnitTestCase { ]); // Use reflection to test a private/protected method. - $effect = new TestFocalPointEffectBase([], 'plugin_id', [], $logger->reveal(), $focal_point_manager, $crop_storage->reveal(), $immutable_config->reveal()); + $effect = new TestFocalPointEffectBase([], 'plugin_id', [], $logger->reveal(), $this->focalPointManager, $crop_storage->reveal(), $immutable_config->reveal()); $effect_reflection = new \ReflectionClass(TestFocalPointEffectBase::class); $method = $effect_reflection->getMethod('calculateAnchor'); $method->setAccessible(TRUE); diff --git a/tests/src/Unit/FocalPointManagerTest.php b/tests/src/Unit/FocalPointManagerTest.php index fe9b9df..c0133e1 100644 --- a/tests/src/Unit/FocalPointManagerTest.php +++ b/tests/src/Unit/FocalPointManagerTest.php @@ -8,7 +8,8 @@ namespace Drupal\Tests\focal_point\Unit; use Drupal\crop\CropInterface; -use Drupal\file\FileInterface; +use Drupal\focal_point\FocalPointManager; +use Drupal\Core\Entity\EntityTypeManager; /** * @coversDefaultClass \Drupal\focal_point\FocalPointManager @@ -18,6 +19,21 @@ use Drupal\file\FileInterface; class FocalPointManagerTest extends FocalPointUnitTestCase { /** + * @covers ::__construct + */ + public function testConstuctor() { + $crop_storage = $this->prophesize(CropStorageInterface::class); + $entity_type_manager = $this->prophesize(EntityTypeManager::class); + $entity_type_manager->getStorage('crop')->willReturn($crop_storage); + + $focal_point_manager = new FocalPointManager($entity_type_manager->reveal()); + $focal_point_manager_reflection = new \ReflectionClass(FocalPointManager::class); + $property = $focal_point_manager_reflection->getProperty('cropStorage'); + $property->setAccessible(TRUE); + $this->assertEquals($crop_storage->reveal(), $property->getValue($focal_point_manager)); + } + + /** * @covers ::validateFocalPoint * * @dataProvider providerValidateFocalPoint