@@ -93,47 +93,48 @@ public function testInexistentInputFile()
9393 public function testInputFile ()
9494 {
9595 $ ghostscript = new Ghostscript ();
96- $ ghostscript ->setInputFile ( __DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'Helicopter.ps ' );
97- $ this ->assertEquals (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'Helicopter.ps ' , $ ghostscript ->getInputFile ());
98-
96+ $ ghostscript ->setInputFile (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'Helicopter.ps ' );
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 ());
99100 }
100101
101102 public function testOutputFile ()
102- {
103+ {
103104 $ ghostscript = new Ghostscript ();
104- $ ghostscript ->setOutputFile ( __DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'Helicopter.ps ' );
105+ $ ghostscript ->setOutputFile (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'Helicopter.ps ' );
105106 $ this ->assertEquals (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'Helicopter.ps ' , $ ghostscript ->getOutputFile ());
106107 }
107108
108109 public function testSettingPages ()
109110 {
110111 $ ghostscript = new Ghostscript ();
111112
112- $ this ->assertEquals (1 ,$ ghostscript ->getPageStart ());
113+ $ this ->assertEquals (1 , $ ghostscript ->getPageStart ());
113114 $ ghostscript ->setPageStart (20 );
114- $ this ->assertEquals (20 ,$ ghostscript ->getPageStart ());
115+ $ this ->assertEquals (20 , $ ghostscript ->getPageStart ());
115116
116- $ this ->assertEquals (1 ,$ ghostscript ->getPageEnd ());
117+ $ this ->assertEquals (1 , $ ghostscript ->getPageEnd ());
117118 $ ghostscript ->setPageEnd (99 );
118- $ this ->assertEquals (99 ,$ ghostscript ->getPageEnd ());
119+ $ this ->assertEquals (99 , $ ghostscript ->getPageEnd ());
119120
120- $ ghostscript ->setPages (44 ,88 );
121- $ this ->assertEquals (44 ,$ ghostscript ->getPageStart ());
122- $ this ->assertEquals (88 ,$ ghostscript ->getPageEnd ());
121+ $ ghostscript ->setPages (44 , 88 );
122+ $ this ->assertEquals (44 , $ ghostscript ->getPageStart ());
123+ $ this ->assertEquals (88 , $ ghostscript ->getPageEnd ());
123124 }
124125
125126 public function testSetBox ()
126127 {
127128 $ ghostscript = new Ghostscript ();
128129 $ this ->assertNull ($ ghostscript ->getBox ());
129130 $ ghostscript ->setBox (Ghostscript::BOX_CROP );
130- $ this ->assertEquals (Ghostscript::BOX_CROP ,$ ghostscript ->getBox ());
131+ $ this ->assertEquals (Ghostscript::BOX_CROP , $ ghostscript ->getBox ());
131132 $ ghostscript ->setBox (Ghostscript::BOX_ART );
132- $ this ->assertEquals (Ghostscript::BOX_ART ,$ ghostscript ->getBox ());
133+ $ this ->assertEquals (Ghostscript::BOX_ART , $ ghostscript ->getBox ());
133134 $ ghostscript ->setBox (Ghostscript::BOX_ART );
134- $ this ->assertEquals (Ghostscript::BOX_ART ,$ ghostscript ->getBox ());
135+ $ this ->assertEquals (Ghostscript::BOX_ART , $ ghostscript ->getBox ());
135136 $ ghostscript ->setBox (Ghostscript::BOX_BLEED );
136- $ this ->assertEquals (Ghostscript::BOX_BLEED ,$ ghostscript ->getBox ());
137+ $ this ->assertEquals (Ghostscript::BOX_BLEED , $ ghostscript ->getBox ());
137138 $ ghostscript ->setBox (Ghostscript::BOX_NONE );
138139 $ this ->assertNull ($ ghostscript ->getBox ());
139140 $ ghostscript ->setBox ('BOX_NOT_HERE ' );
@@ -147,11 +148,36 @@ public function testRender()
147148 $ ghostscript
148149 ->setBinaryPath ($ this ->binaryPath )
149150 ->setInputFile (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'MultiPageHorizontal.pdf ' )
150- ->setOutputFile ($ outputFile );
151+ ->setOutputFile ($ outputFile );
151152 $ result = $ ghostscript ->render ();
152153 $ this ->assertTrue (file_exists ($ outputFile ));
153154 $ this ->assertEquals ("image/jpeg " , mime_content_type ($ outputFile ));
154155 $ this ->assertTrue ($ result );
155156 }
156157
157- }
158+ public function testMerging ()
159+ {
160+ $ outputFile = __DIR__ . DIRECTORY_SEPARATOR . 'output ' . DIRECTORY_SEPARATOR . 'merge.pdf ' ;
161+ $ ghostscript = new Ghostscript ();
162+ $ ghostscript
163+ ->setBinaryPath ($ this ->binaryPath )
164+ ->setDevice (DeviceTypes::PDF )
165+ ->setInputFile (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'lorem.pdf ' )
166+ ->setInputFile (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'ipsum.pdf ' )
167+ ->setOutputFile ($ outputFile );
168+ $ result = $ ghostscript ->render ();
169+ $ this ->assertTrue (file_exists ($ outputFile ));
170+ $ this ->assertEquals ("application/pdf " , mime_content_type ($ outputFile ));
171+ $ this ->assertTrue ($ result );
172+ }
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+
183+ }
0 commit comments