-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWeasyPrintWrapperFaker.php
298 lines (265 loc) · 8.36 KB
/
WeasyPrintWrapperFaker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<?php
namespace Fruitcake\WeasyPrint;
use Illuminate\View\View;
use PHPUnit\Framework\Assert as PHPUnit;
use Illuminate\Support\Facades\View as ViewFacade;
class WeasyPrintWrapperFaker extends WeasyPrintWrapper
{
protected $view;
protected $filename;
/**
* Load a View and convert to HTML
*
* @param string $view
* @param array $data
* @param array $mergeData
* @return $this
*/
public function loadView($view, $data = array(), $mergeData = array())
{
$this->view = ViewFacade::make($view, $data, $mergeData);
return parent::loadView($view, $data, $mergeData);
}
/**
* Ensure that the response has a view as its original content.
*
* @return $this
*/
protected function ensureResponseHasView()
{
if (! isset($this->view) || ! $this->view instanceof View) {
return PHPUnit::fail('The response is not a view.');
}
return $this;
}
public function assertViewIs($value)
{
PHPUnit::assertEquals($value, $this->view->getName());
return $this;
}
/**
* Assert that the response view has a given piece of bound data.
*
* @param string|array $key
* @param mixed $value
* @return $this
*/
public function assertViewHas($key, $value = null)
{
if (is_array($key)) {
return $this->assertViewHasAll($key);
}
$this->ensureResponseHasView();
if (is_null($value)) {
PHPUnit::assertArrayHasKey($key, $this->view->getData());
} elseif ($value instanceof \Closure) {
PHPUnit::assertTrue($value($this->view->$key));
} else {
PHPUnit::assertEquals($value, $this->view->$key);
}
return $this;
}
/**
* Assert that the response view has a given list of bound data.
*
* @param array $bindings
* @return $this
*/
public function assertViewHasAll(array $bindings)
{
foreach ($bindings as $key => $value) {
if (is_int($key)) {
$this->assertViewHas($value);
} else {
$this->assertViewHas($key, $value);
}
}
return $this;
}
/**
* Assert that the response view is missing a piece of bound data.
*
* @param string $key
* @return $this
*/
public function assertViewMissing($key)
{
$this->ensureResponseHasView();
PHPUnit::assertArrayNotHasKey($key, $this->view->getData());
return $this;
}
/**
* Assert that the given string is contained within the response.
*
* @param string $value
* @return $this
*/
public function assertSee($value)
{
PHPUnit::assertStringContainsString($value, $this->html);
return $this;
}
/**
* Assert that the given string is contained within the response text.
*
* @param string $value
* @return $this
*/
public function assertSeeText($value)
{
PHPUnit::assertStringContainsString($value, strip_tags($this->html));
return $this;
}
/**
* Assert that the given string is not contained within the response.
*
* @param string $value
* @return $this
*/
public function assertDontSee($value)
{
PHPUnit::assertStringNotContainsString($value, $this->html);
return $this;
}
/**
* Assert that the given string is not contained within the response text.
*
* @param string $value
* @return $this
*/
public function assertDontSeeText($value)
{
PHPUnit::assertStringNotContainsString($value, strip_tags($this->html));
return $this;
}
/**
* Assert that the given string is equal to the saved filename.
*
* @param string $value
* @return $this
*/
public function assertFileNameIs($value)
{
PHPUnit::assertEquals($value, $this->filename);
return $this;
}
public function output()
{
return '%PDF-1.3
%?????????
4 0 obj
<< /Length 5 0 R /Filter /FlateDecode >>
stream
x+T(T0BSKS=#
C=
K??T?p?<}?bC??bC0,N??5?34???05j1?7)N?
z/?
endstream
endobj
5 0 obj
73
endobj
2 0 obj
<< /Type /Page /Parent 3 0 R /Resources 6 0 R /Contents 4 0 R /MediaBox [0 0 595.28 841.89]
>>
endobj
6 0 obj
<< /ProcSet [ /PDF ] /ColorSpace << /Cs1 7 0 R >> >>
endobj
8 0 obj
<< /Length 9 0 R /N 3 /Alternate /DeviceRGB /Filter /FlateDecode >>
stream
x??wTS??Ͻ7??" %?z ?;HQ?I?P??&vDF)VdT?G?"cE
??b? ?P??QDE?k ?5?ޚ??Y?????g?}P???tX?4?X???\???X??ffG?D???=???HƳ??.?d??,?P&s???"7C$
E?6<~&??S??2????)2?12? ??"?įl???+?ɘ?&?Y??4???Pޚ%ᣌ?\?%?g?|e?TI???(????L0?_??&?l?2E???9?r??9h?x?g??Ib?טi???f??S?b1+??M?xL???
?0??o?E%Ym?h?????Y??h????~S?=?z?U?&?ϞA??Y?l?/??$Z????U?m@??O? ??ޜ??l^???
\'
???ls?k.+?7???oʿ?9?????V;???#I3eE妧?KD??
??d?????9i???,?????UQ? ??h??<?X?.d
???6\'~?khu_}?9P?I?o=C#$n?z}?[1
Ⱦ?h???s?2z???
\?n?LA"S??
?dr%?,?߄l??t?
?3p? ??H?.Hi@?A>?
p1?v?jpԁz?N?6p\W?
?G@
???ٰG???Dx????J?>???,?_@?FDB?X$!k?"??E????H?q???a???Y??bVa?bJ0c?VL?6f3????bձ?X\'??&?x?*???s?b|!??`[????a?;???p~?\2n5??????
ߏƿ\'? Zk?!? $l$???4Q??Ot"?y?\b)???A?I&N?I?$R$)???TIj"]&=&?!??:dGrY@^O?$? _%??P?n?X????ZO?D}J}/G?3???ɭ???k??{%O?חw?_.?\'_!J????Q?@?S???V?F??=?IE???b?b?b?b??5?Q%?????O?@??%?!BӥyҸ?M?:?e?0G7??ӓ????? e%e[?(????R?0`?3R????????4?????6?i^??)??*n*|?"?f????LUo?՝?m?O?0j&jaj?j??.??ϧ?w?ϝ_4????갺?z??j???=???U?4?5?n?ɚ??4ǴhZ
?Z?Z?^0????Tf%??9?????-?>?ݫ=?c??Xg?N??]?.[7A?\?SwBOK/X/_?Q?>Q?????G?[??? ?`?A???????a?a??c#????*?Z?;?8c?q??>?[&???I?I??MS???T`?ϴ?
k?h&4?5?Ǣ??YY?F֠9?<?|?y??+
=?X???_,?,S-?,Y)YXm?????Ěk]c}džj?c?Φ?浭?-?v??};?]???N????"?&?1=?x????tv(??}???????\'{\'??I?ߝY?Σ?
??-r?q?r?.d.?_xp??Uە?Z???M?v?m???=????+K?G?ǔ????
^???W?W????b?j?>:>?>?>?v??}/?a??v?????????O8? ?
?FV>
2 u?????/?_$\?B?Cv?< 5
]?s.,4?&?y?Ux~xw-bEDCĻH????G??KwF?G?E?GME{E?EK?X,Y??F?Z? ?=$vr????K????
??.3\????r???Ϯ?_?Yq*??©?L??_?w?ד??????+??]?e???????D??]?cI?II?OA??u?_?䩔???)3?ѩ?i?????B%a??+]3=\'?/?4?0C??i??U?@ёL(sYf????L?H?$?%?Y
?j??gGe??Q?????n?????~5f5wug?v????5?k??֮\۹Nw]??????m mH???Fˍen???Q?Q??`h????B?BQ?-?[l?ll??f??jۗ"^??b???O%ܒ??Y}W???????????w?w????X?bY^?Ю?]?????W?Va[q`i?d??2???J?jGէ??????{??????m???>???Pk?Am?a?????꺿g_D?H??G?G??u?;??7?7?6?Ʊ?q?o???C{??P3???8!9?????
<?y?}??\'?????Z?Z???։??6i{L{??ӝ?-???|??????gKϑ???9?w~?Bƅ??:Wt>???ҝ????ˁ??^?r?۽??U??g?9];}?}????????_?~i??m??p???㭎?}??]?/???}?????.?{?^?=?}????^??z8?h?c??\'
O*????????f?????`ϳ?g???C/????O?ϩ?+F?F?G?Gό???z????ˌ??ㅿ)????ѫ?~w??gb???k???Jި?9???m?d???wi獵?ޫ???????c?Ǒ??O?O????w| ??x&mf??????
endstream
endobj
9 0 obj
2612
endobj
7 0 obj
[ /ICCBased 8 0 R ]
endobj
3 0 obj
<< /Type /Pages /MediaBox [0 0 595.28 841.89] /Count 1 /Kids [ 2 0 R ] >>
endobj
10 0 obj
<< /Type /Catalog /Pages 3 0 R >>
endobj
11 0 obj
(Leeg)
endobj
12 0 obj
(Mac OS X 10.13.3 Quartz PDFContext)
endobj
13 0 obj
(Pages)
endobj
14 0 obj
(D:20180330091154Z00\'00\')
endobj
1 0 obj
<< /Title 11 0 R /Producer 12 0 R /Creator 13 0 R /CreationDate 14 0 R /ModDate
14 0 R >>
endobj
xref
0 15
0000000000 65535 f
0000003414 00000 n
0000000187 00000 n
0000003133 00000 n
0000000022 00000 n
0000000169 00000 n
0000000297 00000 n
0000003098 00000 n
0000000365 00000 n
0000003078 00000 n
0000003222 00000 n
0000003272 00000 n
0000003295 00000 n
0000003348 00000 n
0000003372 00000 n
trailer
<< /Size 15 /Root 10 0 R /Info 1 0 R /ID [ <ea5d2c625a19688ce1ff05174d8a0261>
<ea5d2c625a19688ce1ff05174d8a0261> ] >>
startxref
3519
%%EOF';
}
/**
* Save the PDF to a file
*
* @param $filename
* @return $this
*/
public function save($filename, $overwrite = false)
{
$this->filename = $filename;
return $this;
}
}