@@ -93,47 +93,48 @@ public function testInexistentInputFile()
93
93
public function testInputFile ()
94
94
{
95
95
$ 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 ());
99
100
}
100
101
101
102
public function testOutputFile ()
102
- {
103
+ {
103
104
$ 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 ' );
105
106
$ this ->assertEquals (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'Helicopter.ps ' , $ ghostscript ->getOutputFile ());
106
107
}
107
108
108
109
public function testSettingPages ()
109
110
{
110
111
$ ghostscript = new Ghostscript ();
111
112
112
- $ this ->assertEquals (1 ,$ ghostscript ->getPageStart ());
113
+ $ this ->assertEquals (1 , $ ghostscript ->getPageStart ());
113
114
$ ghostscript ->setPageStart (20 );
114
- $ this ->assertEquals (20 ,$ ghostscript ->getPageStart ());
115
+ $ this ->assertEquals (20 , $ ghostscript ->getPageStart ());
115
116
116
- $ this ->assertEquals (1 ,$ ghostscript ->getPageEnd ());
117
+ $ this ->assertEquals (1 , $ ghostscript ->getPageEnd ());
117
118
$ ghostscript ->setPageEnd (99 );
118
- $ this ->assertEquals (99 ,$ ghostscript ->getPageEnd ());
119
+ $ this ->assertEquals (99 , $ ghostscript ->getPageEnd ());
119
120
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 ());
123
124
}
124
125
125
126
public function testSetBox ()
126
127
{
127
128
$ ghostscript = new Ghostscript ();
128
129
$ this ->assertNull ($ ghostscript ->getBox ());
129
130
$ ghostscript ->setBox (Ghostscript::BOX_CROP );
130
- $ this ->assertEquals (Ghostscript::BOX_CROP ,$ ghostscript ->getBox ());
131
+ $ this ->assertEquals (Ghostscript::BOX_CROP , $ ghostscript ->getBox ());
131
132
$ ghostscript ->setBox (Ghostscript::BOX_ART );
132
- $ this ->assertEquals (Ghostscript::BOX_ART ,$ ghostscript ->getBox ());
133
+ $ this ->assertEquals (Ghostscript::BOX_ART , $ ghostscript ->getBox ());
133
134
$ ghostscript ->setBox (Ghostscript::BOX_ART );
134
- $ this ->assertEquals (Ghostscript::BOX_ART ,$ ghostscript ->getBox ());
135
+ $ this ->assertEquals (Ghostscript::BOX_ART , $ ghostscript ->getBox ());
135
136
$ ghostscript ->setBox (Ghostscript::BOX_BLEED );
136
- $ this ->assertEquals (Ghostscript::BOX_BLEED ,$ ghostscript ->getBox ());
137
+ $ this ->assertEquals (Ghostscript::BOX_BLEED , $ ghostscript ->getBox ());
137
138
$ ghostscript ->setBox (Ghostscript::BOX_NONE );
138
139
$ this ->assertNull ($ ghostscript ->getBox ());
139
140
$ ghostscript ->setBox ('BOX_NOT_HERE ' );
@@ -147,11 +148,36 @@ public function testRender()
147
148
$ ghostscript
148
149
->setBinaryPath ($ this ->binaryPath )
149
150
->setInputFile (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'MultiPageHorizontal.pdf ' )
150
- ->setOutputFile ($ outputFile );
151
+ ->setOutputFile ($ outputFile );
151
152
$ result = $ ghostscript ->render ();
152
153
$ this ->assertTrue (file_exists ($ outputFile ));
153
154
$ this ->assertEquals ("image/jpeg " , mime_content_type ($ outputFile ));
154
155
$ this ->assertTrue ($ result );
155
156
}
156
157
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