44 * @copyright Copyright (C) Ibexa AS. All rights reserved.
55 * @license For full copyright and license information view LICENSE file distributed with this source code.
66 */
7+ declare (strict_types=1 );
78
89namespace Ibexa \Tests \Bundle \Core \Imagine ;
910
1011use DateTime ;
1112use Ibexa \Bundle \Core \Imagine \AliasGenerator ;
1213use Ibexa \Bundle \Core \Imagine \Variation \ImagineAwareAliasGenerator ;
14+ use Ibexa \Contracts \Core \FieldType \Value ;
1315use Ibexa \Contracts \Core \FieldType \Value as FieldTypeValue ;
1416use Ibexa \Contracts \Core \Repository \Exceptions \InvalidVariationException ;
1517use Ibexa \Contracts \Core \Repository \Values \Content \Field ;
1618use Ibexa \Contracts \Core \Variation \Values \ImageVariation ;
19+ use Ibexa \Contracts \Core \Variation \VariationHandler ;
1720use Ibexa \Contracts \Core \Variation \VariationPathGenerator ;
1821use Ibexa \Core \FieldType \Image \Value as ImageValue ;
1922use Ibexa \Core \FieldType \TextLine \Value as TextLineValue ;
3134use Liip \ImagineBundle \Imagine \Cache \Resolver \ResolverInterface ;
3235use Liip \ImagineBundle \Imagine \Filter \FilterConfiguration ;
3336use Liip \ImagineBundle \Imagine \Filter \FilterManager ;
37+ use PHPUnit \Framework \MockObject \MockObject ;
3438use PHPUnit \Framework \TestCase ;
3539use Psr \Log \LoggerInterface ;
3640
37- class AliasGeneratorTest extends TestCase
41+ final class AliasGeneratorTest extends TestCase
3842{
39- /** @var \PHPUnit\Framework\MockObject\MockObject|\Liip\ImagineBundle\Binary\Loader\LoaderInterface */
40- private $ dataLoader ;
43+ private MockObject |LoaderInterface $ dataLoader ;
4144
42- /** @var \PHPUnit\Framework\MockObject\MockObject|\Liip\ImagineBundle\Imagine\Filter\FilterManager */
43- private $ filterManager ;
45+ private MockObject |FilterManager $ filterManager ;
4446
45- /** @var \PHPUnit\Framework\MockObject\MockObject|\Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface */
46- private $ ioResolver ;
47+ private MockObject |ResolverInterface $ ioResolver ;
4748
48- /** @var \Liip\ImagineBundle\Imagine\Filter\FilterConfiguration */
49- private $ filterConfiguration ;
49+ private MockObject |FilterConfiguration $ filterConfiguration ;
5050
51- /** @var \PHPUnit\Framework\MockObject\MockObject|\Psr\Log\LoggerInterface */
52- private $ logger ;
51+ private MockObject |LoggerInterface $ logger ;
5352
54- /** @var \PHPUnit\Framework\MockObject\MockObject|\Imagine\Image\ImagineInterface */
55- private $ imagine ;
53+ private MockObject |ImagineInterface $ imagine ;
5654
57- /** @var \Ibexa\Bundle\Core\Imagine\AliasGenerator */
58- private $ aliasGenerator ;
55+ private MockObject |AliasGenerator $ aliasGenerator ;
5956
60- /** @var \Ibexa\Contracts\Core\Variation\VariationHandler */
61- private $ decoratedAliasGenerator ;
57+ private MockObject |VariationHandler $ decoratedAliasGenerator ;
6258
63- /** @var \PHPUnit\Framework\MockObject\MockObject|\Imagine\Image\BoxInterface */
64- private $ box ;
59+ private MockObject |BoxInterface $ box ;
6560
66- /** @var \PHPUnit\Framework\MockObject\MockObject|\Imagine\Image\ImageInterface */
67- private $ image ;
61+ private MockObject |ImageInterface $ image ;
6862
69- /** @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\Core\IO\IOServiceInterface */
70- private $ ioService ;
63+ private MockObject |IOServiceInterface $ ioService ;
7164
72- /** @var \PHPUnit\Framework\MockObject\MockObject|\Ibexa\Contracts\Core\Variation\VariationPathGenerator */
73- private $ variationPathGenerator ;
65+ private MockObject |VariationPathGenerator $ variationPathGenerator ;
7466
7567 protected function setUp (): void
7668 {
@@ -105,11 +97,8 @@ protected function setUp(): void
10597
10698 /**
10799 * @dataProvider supportsValueProvider
108- *
109- * @param \Ibexa\Contracts\Core\FieldType\Value $value
110- * @param bool $isSupported
111100 */
112- public function testSupportsValue ($ value , $ isSupported )
101+ public function testSupportsValue (Value $ value , bool $ isSupported ): void
113102 {
114103 self ::assertSame ($ isSupported , $ this ->aliasGenerator ->supportsValue ($ value ));
115104 }
@@ -123,7 +112,7 @@ public function testSupportsValue($value, $isSupported)
123112 *
124113 * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
125114 */
126- public function supportsValueProvider ()
115+ public function supportsValueProvider (): array
127116 {
128117 return [
129118 [$ this ->createMock (FieldTypeValue::class), false ],
@@ -133,7 +122,7 @@ public function supportsValueProvider()
133122 ];
134123 }
135124
136- public function testGetVariationWrongValue ()
125+ public function testGetVariationWrongValue (): void
137126 {
138127 $ this ->expectException (\InvalidArgumentException::class);
139128
@@ -149,7 +138,7 @@ public function testGetVariationWrongValue()
149138 *
150139 * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType
151140 */
152- public function testGetVariationNotStored ()
141+ public function testGetVariationNotStored (): void
153142 {
154143 $ originalPath = 'foo/bar/image.jpg ' ;
155144 $ variationName = 'my_variation ' ;
@@ -195,7 +184,7 @@ public function testGetVariationNotStored()
195184 );
196185 }
197186
198- public function testGetVariationOriginal ()
187+ public function testGetVariationOriginal (): void
199188 {
200189 $ originalPath = 'foo/bar/image.jpg ' ;
201190 $ variationName = 'original ' ;
@@ -209,6 +198,8 @@ public function testGetVariationOriginal()
209198 'imageId ' => $ imageId ,
210199 'width ' => $ imageWidth ,
211200 'height ' => $ imageHeight ,
201+ 'fileSize ' => 1024 ,
202+ 'mime ' => 'image/jpeg ' ,
212203 ]
213204 );
214205 $ field = new Field ([
@@ -242,17 +233,26 @@ public function testGetVariationOriginal()
242233 'imageId ' => $ imageId ,
243234 'height ' => $ imageHeight ,
244235 'width ' => $ imageWidth ,
236+ 'fileSize ' => 1024 ,
237+ 'mimeType ' => 'image/jpeg ' ,
245238 ]
246239 );
247- self ::assertEquals ($ expected , $ this ->decoratedAliasGenerator ->getVariation ($ field , new VersionInfo (), $ variationName ));
240+ self ::assertEquals (
241+ $ expected ,
242+ $ this ->decoratedAliasGenerator ->getVariation (
243+ $ field ,
244+ new VersionInfo (),
245+ $ variationName
246+ )
247+ );
248248 }
249249
250250 /**
251251 * Test obtaining Image Variation that hasn't been stored yet and has multiple references.
252252 *
253253 * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType
254254 */
255- public function testGetVariationNotStoredHavingReferences ()
255+ public function testGetVariationNotStoredHavingReferences (): void
256256 {
257257 $ originalPath = 'foo/bar/image.jpg ' ;
258258 $ variationName = 'my_variation ' ;
@@ -323,7 +323,7 @@ public function testGetVariationNotStoredHavingReferences()
323323 *
324324 * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType
325325 */
326- public function testGetVariationAlreadyStored ()
326+ public function testGetVariationAlreadyStored (): void
327327 {
328328 $ originalPath = 'foo/bar/image.jpg ' ;
329329 $ variationName = 'my_variation ' ;
@@ -362,7 +362,7 @@ public function testGetVariationAlreadyStored()
362362 );
363363 }
364364
365- public function testGetVariationOriginalNotFound ()
365+ public function testGetVariationOriginalNotFound (): void
366366 {
367367 $ this ->expectException (SourceImageNotFoundException::class);
368368
@@ -378,7 +378,7 @@ public function testGetVariationOriginalNotFound()
378378 $ this ->aliasGenerator ->getVariation ($ field , new VersionInfo (), 'foo ' );
379379 }
380380
381- public function testGetVariationInvalidVariation ()
381+ public function testGetVariationInvalidVariation (): void
382382 {
383383 $ this ->expectException (InvalidVariationException::class);
384384
0 commit comments