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