File tree Expand file tree Collapse file tree 3 files changed +45
-2
lines changed
Expand file tree Collapse file tree 3 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,40 @@ public function provideWrongConvertDirs(): ?\Generator
4444 yield ['./ ' , 'The specified path (.) is not a file. ' , MagickBinaryNotFoundException::class];
4545 }
4646
47+ /**
48+ * @param $fileSources
49+ *
50+ * @dataProvider convertDataProvider
51+ */
52+ public function testConvert ($ fileSources , string $ fileOutput ): void
53+ {
54+
55+ $ command = new Command (IMAGEMAGICK_DIR );
56+
57+ $ response = $ command
58+ ->convert ($ fileSources )
59+ ->output ($ fileOutput )
60+ ->run ();
61+
62+ static ::assertFileExists ($ fileOutput );
63+
64+ static ::assertFalse ($ response ->hasFailed ());
65+ }
66+
67+ public function convertDataProvider (): array
68+ {
69+ $ singleSource = $ this ->resourcesDir .'/moon_180.jpg ' ;
70+ $ multipleSources = [
71+ $ this ->resourcesDir .'/moon_180.jpg ' ,
72+ $ this ->resourcesDir .'/dabug.png ' ,
73+ ];
74+
75+ return [
76+ [$ singleSource , $ this ->resourcesDir .'/outputs/output1.pdf ' ],
77+ [$ multipleSources , $ this ->resourcesDir .'/outputs/output2.pdf ' ],
78+ ];
79+ }
80+
4781 public function testResizeImage (): void
4882 {
4983 $ command = new Command (IMAGEMAGICK_DIR );
Original file line number Diff line number Diff line change @@ -177,9 +177,18 @@ public function newCommand(?string $binary = null): self
177177 /**
178178 * @see https://imagemagick.org/script/convert.php
179179 */
180- public function convert (string $ sourceFile , bool $ checkIfFileExists = true ): self
180+ public function convert ($ sourceFiles , bool $ checkIfFileExists = true ): self
181181 {
182- return $ this ->newCommand ('convert ' )->file ($ sourceFile , $ checkIfFileExists );
182+ if (!is_array ($ sourceFiles )) {
183+ $ sourceFiles = [$ sourceFiles ];
184+ }
185+
186+ $ this ->newCommand ('convert ' );
187+ foreach ($ sourceFiles as $ sourceFile ) {
188+ $ this ->file ($ sourceFile , $ checkIfFileExists );
189+ }
190+
191+ return $ this ;
183192 }
184193
185194 /**
You can’t perform that action at this time.
0 commit comments