Skip to content

Commit 28ff2cf

Browse files
committed
Smaller changes before merging
+ changed `getInputFile` to `getInputFiles` + added `clearInputFiles` to reset input file list + added test for `clearInputFiles` + small tweaks on `testInputFiles`
1 parent 993d7ee commit 28ff2cf

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/PHPGhostscript/Ghostscript.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,21 @@ public function setInputFile($file) : Ghostscript
342342
*
343343
* @return array
344344
*/
345-
public function getInputFile() : array
345+
public function getInputFiles() : array
346346
{
347347
return $this->files;
348348
}
349349

350+
/**
351+
* Clear inputfiles
352+
*
353+
* @return self
354+
*/
355+
public function clearInputFiles() : Ghostscript
356+
{
357+
$this->files = [];
358+
return $this;
359+
}
350360

351361
/**
352362
* Set output file

tests/PHPGhostscript/PHPGhostscriptTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ public function testInputFile()
9494
{
9595
$ghostscript = new Ghostscript();
9696
$ghostscript->setInputFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'Helicopter.ps');
97-
$this->assertEquals([__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'Helicopter.ps'], $ghostscript->getInputFile());
97+
$this->assertEquals([__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'Helicopter.ps'], $ghostscript->getInputFiles());
98+
$ghostscript->setInputFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'Helicopter.ps');
99+
$this->assertEquals([__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'Helicopter.ps', __DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'Helicopter.ps'], $ghostscript->getInputFiles());
98100
}
99101

100102
public function testOutputFile()
@@ -168,4 +170,14 @@ public function testMerging()
168170
$this->assertEquals("application/pdf", mime_content_type($outputFile));
169171
$this->assertTrue($result);
170172
}
173+
174+
public function testClearInputFiles()
175+
{
176+
$ghostscript = new Ghostscript();
177+
$ghostscript->setInputFile(__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'Helicopter.ps');
178+
$this->assertEquals([__DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'Helicopter.ps'], $ghostscript->getInputFiles());
179+
$ghostscript->clearInputFiles();
180+
$this->assertEquals([], $ghostscript->getInputFiles());
181+
}
182+
171183
}

0 commit comments

Comments
 (0)