5
5
use Monolog \Handler \TestHandler ;
6
6
use Monolog \Logger ;
7
7
use Psr \Log \LoggerInterface ;
8
- use Readability \JSLikeHTMLElement ;
9
8
use Readability \Readability ;
10
9
11
10
class ReadabilityTest extends \PHPUnit \Framework \TestCase
@@ -80,8 +79,6 @@ public function testInitNoContent(): void
80
79
$ res = $ readability ->init ();
81
80
82
81
$ this ->assertFalse ($ res );
83
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
84
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
85
82
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
86
83
$ this ->assertStringContainsString ('Sorry, Readability was unable to parse this page for content. ' , $ readability ->getContent ()->getInnerHtml ());
87
84
}
@@ -92,8 +89,6 @@ public function testInitP(): void
92
89
$ res = $ readability ->init ();
93
90
94
91
$ this ->assertTrue ($ res );
95
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
96
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
97
92
$ this ->assertStringContainsString ('<div readability= ' , $ readability ->getContent ()->getInnerHtml ());
98
93
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
99
94
$ this ->assertStringContainsString ('This is the awesome content :) ' , $ readability ->getContent ()->getInnerHtml ());
@@ -105,8 +100,6 @@ public function testInitDivP(): void
105
100
$ res = $ readability ->init ();
106
101
107
102
$ this ->assertTrue ($ res );
108
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
109
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
110
103
$ this ->assertStringContainsString ('<div readability= ' , $ readability ->getContent ()->getInnerHtml ());
111
104
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
112
105
$ this ->assertStringContainsString ('This is the awesome content :) ' , $ readability ->getContent ()->getInnerHtml ());
@@ -119,8 +112,6 @@ public function testInitDiv(): void
119
112
$ res = $ readability ->init ();
120
113
121
114
$ this ->assertTrue ($ res );
122
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
123
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
124
115
$ this ->assertStringContainsString ('<div readability= ' , $ readability ->getContent ()->getInnerHtml ());
125
116
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
126
117
$ this ->assertStringContainsString ('This is the awesome content :) ' , $ readability ->getContent ()->getInnerHtml ());
@@ -134,8 +125,6 @@ public function testWithFootnotes(): void
134
125
$ res = $ readability ->init ();
135
126
136
127
$ this ->assertTrue ($ res );
137
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
138
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
139
128
$ this ->assertStringContainsString ('<div readability= ' , $ readability ->getContent ()->getInnerHtml ());
140
129
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
141
130
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
@@ -151,8 +140,6 @@ public function testStandardClean(): void
151
140
$ res = $ readability ->init ();
152
141
153
142
$ this ->assertTrue ($ res );
154
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
155
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
156
143
$ this ->assertStringContainsString ('<div readability= ' , $ readability ->getContent ()->getInnerHtml ());
157
144
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
158
145
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
@@ -167,8 +154,6 @@ public function testWithIframe(): void
167
154
$ res = $ readability ->init ();
168
155
169
156
$ this ->assertTrue ($ res );
170
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
171
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
172
157
$ this ->assertStringContainsString ('<div readability= ' , $ readability ->getContent ()->getInnerHtml ());
173
158
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
174
159
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
@@ -182,8 +167,6 @@ public function testWithArticle(): void
182
167
$ res = $ readability ->init ();
183
168
184
169
$ this ->assertTrue ($ res );
185
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
186
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
187
170
$ this ->assertStringContainsString ('alt="article" ' , $ readability ->getContent ()->getInnerHtml ());
188
171
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
189
172
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
@@ -197,8 +180,6 @@ public function testWithAside(): void
197
180
$ res = $ readability ->init ();
198
181
199
182
$ this ->assertTrue ($ res );
200
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
201
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
202
183
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
203
184
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
204
185
$ this ->assertStringNotContainsString ('<aside> ' , $ readability ->getContent ()->getInnerHtml ());
@@ -212,8 +193,6 @@ public function testWithClasses(): void
212
193
$ res = $ readability ->init ();
213
194
214
195
$ this ->assertTrue ($ res );
215
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
216
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
217
196
$ this ->assertStringContainsString ('alt="article" ' , $ readability ->getContent ()->getInnerHtml ());
218
197
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
219
198
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
@@ -228,8 +207,6 @@ public function testWithClassesWithoutLightClean(): void
228
207
$ res = $ readability ->init ();
229
208
230
209
$ this ->assertTrue ($ res );
231
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
232
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
233
210
$ this ->assertStringContainsString ('alt="article" ' , $ readability ->getContent ()->getInnerHtml ());
234
211
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
235
212
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
@@ -243,8 +220,6 @@ public function testWithTd(): void
243
220
$ res = $ readability ->init ();
244
221
245
222
$ this ->assertTrue ($ res );
246
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
247
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
248
223
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
249
224
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
250
225
}
@@ -256,8 +231,6 @@ public function testWithSameClasses(): void
256
231
$ res = $ readability ->init ();
257
232
258
233
$ this ->assertTrue ($ res );
259
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
260
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
261
234
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
262
235
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
263
236
$ this ->assertStringContainsString ('This text is also an awesome text and you should know that ' , $ readability ->getContent ()->getInnerHtml ());
@@ -270,8 +243,6 @@ public function testWithScript(): void
270
243
$ res = $ readability ->init ();
271
244
272
245
$ this ->assertTrue ($ res );
273
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
274
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
275
246
$ this ->assertEmpty ($ readability ->getTitle ()->getInnerHtml ());
276
247
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
277
248
$ this ->assertStringNotContainsString ('This text is also an awesome text and you should know that ' , $ readability ->getContent ()->getInnerHtml ());
@@ -284,8 +255,6 @@ public function testTitle(): void
284
255
$ res = $ readability ->init ();
285
256
286
257
$ this ->assertTrue ($ res );
287
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
288
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
289
258
$ this ->assertSame ('this is my title ' , $ readability ->getTitle ()->getInnerHtml ());
290
259
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
291
260
$ this ->assertStringNotContainsString ('This text is also an awesome text and you should know that ' , $ readability ->getContent ()->getInnerHtml ());
@@ -298,8 +267,6 @@ public function testTitleWithDash(): void
298
267
$ res = $ readability ->init ();
299
268
300
269
$ this ->assertTrue ($ res );
301
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
302
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
303
270
$ this ->assertSame ('title2 - title3 ' , $ readability ->getTitle ()->getInnerHtml ());
304
271
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
305
272
$ this ->assertStringNotContainsString ('This text is also an awesome text and you should know that ' , $ readability ->getContent ()->getInnerHtml ());
@@ -312,8 +279,6 @@ public function testTitleWithDoubleDot(): void
312
279
$ res = $ readability ->init ();
313
280
314
281
$ this ->assertTrue ($ res );
315
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
316
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
317
282
$ this ->assertSame ('title2 : title3 ' , $ readability ->getTitle ()->getInnerHtml ());
318
283
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
319
284
$ this ->assertStringNotContainsString ('This text is also an awesome text and you should know that ' , $ readability ->getContent ()->getInnerHtml ());
@@ -326,8 +291,6 @@ public function testTitleTooShortUseH1(): void
326
291
$ res = $ readability ->init ();
327
292
328
293
$ this ->assertTrue ($ res );
329
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
330
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
331
294
$ this ->assertSame ('this is my h1 title ! ' , $ readability ->getTitle ()->getInnerHtml ());
332
295
$ this ->assertStringContainsString ('This is an awesome text with some links, here there are ' , $ readability ->getContent ()->getInnerHtml ());
333
296
$ this ->assertStringNotContainsString ('This text is also an awesome text and you should know that ' , $ readability ->getContent ()->getInnerHtml ());
@@ -374,8 +337,6 @@ public function testAutoClosingIframeNotThrowingException(): void
374
337
$ res = $ readability ->init ();
375
338
376
339
$ this ->assertTrue ($ res );
377
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
378
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
379
340
$ this ->assertStringContainsString ('<iframe src="https://www.youtube.com/embed/PUep6xNeKjA" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"> </iframe> ' , $ readability ->getContent ()->getInnerHtml ());
380
341
$ this ->assertStringContainsString ('3D Touch ' , $ readability ->getTitle ()->getInnerHtml ());
381
342
} finally {
@@ -442,8 +403,6 @@ public function testAppendIdAlreadyHere(): void
442
403
$ res = $ readability ->init ();
443
404
444
405
$ this ->assertTrue ($ res );
445
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getContent ());
446
- $ this ->assertInstanceOf (JSLikeHTMLElement::class, $ readability ->getTitle ());
447
406
}
448
407
449
408
public function testPostFilters (): void
0 commit comments