|
1 | | -<?php |
2 | | - |
3 | | -/** |
4 | | - * Copyright (c) Florian Krämer (https://florian-kraemer.net) |
5 | | - * Licensed under The MIT License |
6 | | - * For full copyright and license information, please see the LICENSE.txt |
7 | | - * Redistributions of files must retain the above copyright notice. |
8 | | - * |
9 | | - * @copyright Copyright (c) Florian Krämer (https://florian-kraemer.net) |
10 | | - * @author Florian Krämer |
11 | | - * @link https://github.com/Phauthentic |
12 | | - * @license https://opensource.org/licenses/MIT MIT License |
13 | | - */ |
14 | | - |
15 | | -declare(strict_types=1); |
16 | | - |
17 | | -namespace Phauthentic\Test\TestCase\Processor\Image; |
18 | | - |
19 | | -use Intervention\Image\Image; |
20 | | -use Intervention\Image\ImageManager; |
21 | | -use Phauthentic\Infrastructure\Storage\File; |
22 | | -use Phauthentic\Infrastructure\Storage\FileFactory; |
23 | | -use Phauthentic\Infrastructure\Storage\FileStorageInterface; |
24 | | -use Phauthentic\Infrastructure\Storage\PathBuilder\PathBuilder; |
25 | | -use Phauthentic\Infrastructure\Storage\Processor\Image\ImageVariantCollection; |
26 | | -use Phauthentic\Infrastructure\Storage\Processor\Image\ImageProcessor; |
27 | | -use Phauthentic\Test\TestCase\TestCase; |
28 | | - |
29 | | -/** |
30 | | - * ImageProcessorTest |
31 | | - */ |
32 | | -class ImageProcessorTest extends TestCase |
33 | | -{ |
34 | | - /** |
35 | | - * @return void |
36 | | - */ |
37 | | - public function testProcessor(): void |
38 | | - { |
39 | | - $fileStorage = $this->getMockBuilder(FileStorageInterface::class) |
40 | | - ->getMock(); |
41 | | - |
42 | | - $pathBuilder = new PathBuilder(); |
43 | | - |
44 | | - $imageManager = $this->getMockBuilder(ImageManager::class) |
45 | | - ->getMock(); |
46 | | - |
47 | | - $image = $this->getMockBuilder(Image::class) |
48 | | - ->getMock(); |
49 | | - |
50 | | - $imageManager->expects($this->any()) |
51 | | - ->method('make') |
52 | | - ->willReturn($image); |
53 | | - |
54 | | - $processor = new ImageProcessor( |
55 | | - $fileStorage, |
56 | | - $pathBuilder, |
57 | | - $imageManager |
58 | | - ); |
59 | | - |
60 | | - $fileOnDisk = $this->getFixtureFile('titus.jpg'); |
61 | | - |
62 | | - $file = FileFactory::fromDisk($fileOnDisk, 'local') |
63 | | - ->withUuid('914e1512-9153-4253-a81e-7ee2edc1d973') |
64 | | - ->withFilename('foobar.jpg') |
65 | | - ->addToCollection('avatar') |
66 | | - ->belongsToModel('User', '1'); |
67 | | - |
68 | | - $collection = ImageVariantCollection::create(); |
69 | | - $collection |
70 | | - ->addNew('resizeAndFlip') |
71 | | - ->flipHorizontal() |
72 | | - ->resize(300, 300) |
73 | | - ->optimize(); |
74 | | - |
75 | | - $file = $file->withVariants($collection->toArray()); |
76 | | - |
77 | | - $file = $processor->process($file); |
78 | | - |
79 | | - $this->assertInstanceOf(File::class, $file); |
80 | | - } |
81 | | -} |
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright (c) Florian Krämer (https://florian-kraemer.net) |
| 5 | + * Licensed under The MIT License |
| 6 | + * For full copyright and license information, please see the LICENSE.txt |
| 7 | + * Redistributions of files must retain the above copyright notice. |
| 8 | + * |
| 9 | + * @copyright Copyright (c) Florian Krämer (https://florian-kraemer.net) |
| 10 | + * @author Florian Krämer |
| 11 | + * @link https://github.com/Phauthentic |
| 12 | + * @license https://opensource.org/licenses/MIT MIT License |
| 13 | + */ |
| 14 | + |
| 15 | +declare(strict_types=1); |
| 16 | + |
| 17 | +namespace Phauthentic\Test\TestCase\Processor\Image; |
| 18 | + |
| 19 | +use Intervention\Image\Image; |
| 20 | +use Intervention\Image\ImageManager; |
| 21 | +use Phauthentic\Infrastructure\Storage\File; |
| 22 | +use Phauthentic\Infrastructure\Storage\FileFactory; |
| 23 | +use Phauthentic\Infrastructure\Storage\FileStorageInterface; |
| 24 | +use Phauthentic\Infrastructure\Storage\PathBuilder\PathBuilder; |
| 25 | +use Phauthentic\Infrastructure\Storage\Processor\Image\ImageVariantCollection; |
| 26 | +use Phauthentic\Infrastructure\Storage\Processor\Image\ImageProcessor; |
| 27 | +use Phauthentic\Test\TestCase\TestCase; |
| 28 | + |
| 29 | +/** |
| 30 | + * ImageProcessorTest |
| 31 | + */ |
| 32 | +class ImageProcessorTest extends TestCase |
| 33 | +{ |
| 34 | + /** |
| 35 | + * @return void |
| 36 | + */ |
| 37 | + public function testProcessor(): void |
| 38 | + { |
| 39 | + $fileStorage = $this->getMockBuilder(FileStorageInterface::class) |
| 40 | + ->getMock(); |
| 41 | + |
| 42 | + $pathBuilder = new PathBuilder(); |
| 43 | + |
| 44 | + $imageManager = $this->getMockBuilder(ImageManager::class) |
| 45 | + ->getMock(); |
| 46 | + |
| 47 | + $image = $this->getMockBuilder(Image::class) |
| 48 | + ->getMock(); |
| 49 | + |
| 50 | + $imageManager->expects($this->any()) |
| 51 | + ->method('make') |
| 52 | + ->willReturn($image); |
| 53 | + |
| 54 | + $processor = new ImageProcessor( |
| 55 | + $fileStorage, |
| 56 | + $pathBuilder, |
| 57 | + $imageManager |
| 58 | + ); |
| 59 | + |
| 60 | + $fileOnDisk = $this->getFixtureFile('titus.jpg'); |
| 61 | + |
| 62 | + $file = FileFactory::fromDisk($fileOnDisk, 'local') |
| 63 | + ->withUuid('914e1512-9153-4253-a81e-7ee2edc1d973') |
| 64 | + ->withFilename('foobar.jpg') |
| 65 | + ->addToCollection('avatar') |
| 66 | + ->belongsToModel('User', '1'); |
| 67 | + |
| 68 | + $collection = ImageVariantCollection::create(); |
| 69 | + $collection |
| 70 | + ->addNew('resizeAndFlip') |
| 71 | + ->flipHorizontal() |
| 72 | + ->resize(300, 300) |
| 73 | + ->optimize(); |
| 74 | + |
| 75 | + $file = $file->withVariants($collection->toArray()); |
| 76 | + |
| 77 | + $file = $processor->process($file); |
| 78 | + |
| 79 | + $this->assertInstanceOf(File::class, $file); |
| 80 | + } |
| 81 | +} |
0 commit comments