|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Netgen\RemoteMedia\Tests\Core\Provider\Cloudinary\TransformationHandler; |
| 6 | + |
| 7 | +use Netgen\RemoteMedia\Core\Provider\Cloudinary\TransformationHandler\Gravity; |
| 8 | +use Netgen\RemoteMedia\Exception\TransformationHandlerFailedException; |
| 9 | +use PHPUnit\Framework\Attributes\CoversClass; |
| 10 | +use PHPUnit\Framework\TestCase; |
| 11 | + |
| 12 | +#[CoversClass(Gravity::class)] |
| 13 | +final class GravityTest extends TestCase |
| 14 | +{ |
| 15 | + protected Gravity $gravity; |
| 16 | + |
| 17 | + protected function setUp(): void |
| 18 | + { |
| 19 | + $this->gravity = new Gravity(); |
| 20 | + } |
| 21 | + |
| 22 | + public function testGravityCompassPosition(): void |
| 23 | + { |
| 24 | + self::assertSame( |
| 25 | + ['gravity' => 'south'], |
| 26 | + $this->gravity->process(['south']), |
| 27 | + ); |
| 28 | + } |
| 29 | + |
| 30 | + public function testGravitySpecialPosition(): void |
| 31 | + { |
| 32 | + self::assertSame( |
| 33 | + ['gravity' => 'face'], |
| 34 | + $this->gravity->process(['face']), |
| 35 | + ); |
| 36 | + } |
| 37 | + |
| 38 | + public function testGravityObject(): void |
| 39 | + { |
| 40 | + self::assertSame( |
| 41 | + ['gravity' => 'microwave'], |
| 42 | + $this->gravity->process(['microwave']), |
| 43 | + ); |
| 44 | + } |
| 45 | + |
| 46 | + public function testGravityWithDefaultAuto(): void |
| 47 | + { |
| 48 | + self::assertSame( |
| 49 | + [ |
| 50 | + 'gravity' => 'auto', |
| 51 | + ], |
| 52 | + $this->gravity->process(['auto']), |
| 53 | + ); |
| 54 | + } |
| 55 | + |
| 56 | + public function testGravityWithAutoType(): void |
| 57 | + { |
| 58 | + self::assertSame( |
| 59 | + [ |
| 60 | + 'gravity' => 'auto:subject', |
| 61 | + ], |
| 62 | + $this->gravity->process(['auto', 'subject']), |
| 63 | + ); |
| 64 | + } |
| 65 | + |
| 66 | + public function testWithoutConfig(): void |
| 67 | + { |
| 68 | + $this->expectException(TransformationHandlerFailedException::class); |
| 69 | + |
| 70 | + $this->gravity->process(); |
| 71 | + } |
| 72 | +} |
0 commit comments