diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2019-05-28 14:00:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-28 14:00:22 +0200 |
commit | 48d136d3a08d7f4ca8e0d434d8104c746d31957d (patch) | |
tree | 308e15326adc658702f257693338f101d36e1af8 /tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | |
parent | 92a66835624acf6fd14f5adc5f8aab399658592e (diff) | |
parent | 6e68417f0356d0045d7a2aa3832507d362ddcfe8 (diff) | |
download | wallabag-48d136d3a08d7f4ca8e0d434d8104c746d31957d.tar.gz wallabag-48d136d3a08d7f4ca8e0d434d8104c746d31957d.tar.zst wallabag-48d136d3a08d7f4ca8e0d434d8104c746d31957d.zip |
Merge pull request #3390 from aaa2000/httplug
Use httplug and graby 2.0
Diffstat (limited to 'tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php')
-rw-r--r-- | tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | 137 |
1 files changed, 79 insertions, 58 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index c7caac1d..9ce72c79 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | |||
@@ -36,7 +36,9 @@ class ContentProxyTest extends TestCase | |||
36 | 'html' => false, | 36 | 'html' => false, |
37 | 'title' => '', | 37 | 'title' => '', |
38 | 'url' => '', | 38 | 'url' => '', |
39 | 'content_type' => '', | 39 | 'headers' => [ |
40 | 'content-type' => '', | ||
41 | ], | ||
40 | 'language' => '', | 42 | 'language' => '', |
41 | ]); | 43 | ]); |
42 | 44 | ||
@@ -71,7 +73,9 @@ class ContentProxyTest extends TestCase | |||
71 | 'html' => false, | 73 | 'html' => false, |
72 | 'title' => '', | 74 | 'title' => '', |
73 | 'url' => '', | 75 | 'url' => '', |
74 | 'content_type' => '', | 76 | 'headers' => [ |
77 | 'content-type' => '', | ||
78 | ], | ||
75 | 'language' => '', | 79 | 'language' => '', |
76 | ]); | 80 | ]); |
77 | 81 | ||
@@ -104,15 +108,14 @@ class ContentProxyTest extends TestCase | |||
104 | ->method('fetchContent') | 108 | ->method('fetchContent') |
105 | ->willReturn([ | 109 | ->willReturn([ |
106 | 'html' => false, | 110 | 'html' => false, |
107 | 'title' => '', | 111 | 'title' => 'my title', |
108 | 'url' => '', | 112 | 'url' => '', |
109 | 'content_type' => '', | 113 | 'headers' => [ |
114 | 'content-type' => '', | ||
115 | ], | ||
110 | 'language' => '', | 116 | 'language' => '', |
111 | 'status' => '', | 117 | 'status' => '', |
112 | 'open_graph' => [ | 118 | 'description' => 'desc', |
113 | 'og_title' => 'my title', | ||
114 | 'og_description' => 'desc', | ||
115 | ], | ||
116 | ]); | 119 | ]); |
117 | 120 | ||
118 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); | 121 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); |
@@ -147,13 +150,12 @@ class ContentProxyTest extends TestCase | |||
147 | 'html' => str_repeat('this is my content', 325), | 150 | 'html' => str_repeat('this is my content', 325), |
148 | 'title' => 'this is my title', | 151 | 'title' => 'this is my title', |
149 | 'url' => 'http://1.1.1.1', | 152 | 'url' => 'http://1.1.1.1', |
150 | 'content_type' => 'text/html', | ||
151 | 'language' => 'fr', | 153 | 'language' => 'fr', |
152 | 'status' => '200', | 154 | 'status' => '200', |
153 | 'open_graph' => [ | 155 | 'description' => 'OG desc', |
154 | 'og_title' => 'my OG title', | 156 | 'image' => 'http://3.3.3.3/cover.jpg', |
155 | 'og_description' => 'OG desc', | 157 | 'headers' => [ |
156 | 'og_image' => 'http://3.3.3.3/cover.jpg', | 158 | 'content-type' => 'text/html', |
157 | ], | 159 | ], |
158 | ]); | 160 | ]); |
159 | 161 | ||
@@ -189,13 +191,12 @@ class ContentProxyTest extends TestCase | |||
189 | 'html' => str_repeat('this is my content', 325), | 191 | 'html' => str_repeat('this is my content', 325), |
190 | 'title' => 'this is my title', | 192 | 'title' => 'this is my title', |
191 | 'url' => 'http://1.1.1.1', | 193 | 'url' => 'http://1.1.1.1', |
192 | 'content_type' => 'text/html', | ||
193 | 'language' => 'fr', | 194 | 'language' => 'fr', |
194 | 'status' => '200', | 195 | 'status' => '200', |
195 | 'open_graph' => [ | 196 | 'description' => 'OG desc', |
196 | 'og_title' => 'my OG title', | 197 | 'image' => null, |
197 | 'og_description' => 'OG desc', | 198 | 'headers' => [ |
198 | 'og_image' => null, | 199 | 'content-type' => 'text/html', |
199 | ], | 200 | ], |
200 | ]); | 201 | ]); |
201 | 202 | ||
@@ -231,14 +232,12 @@ class ContentProxyTest extends TestCase | |||
231 | 'html' => "<h1>Test</h1><p><img src='http://3.3.3.3/cover.jpg'/></p>", | 232 | 'html' => "<h1>Test</h1><p><img src='http://3.3.3.3/cover.jpg'/></p>", |
232 | 'title' => 'this is my title', | 233 | 'title' => 'this is my title', |
233 | 'url' => 'http://1.1.1.1', | 234 | 'url' => 'http://1.1.1.1', |
234 | 'content_type' => 'text/html', | 235 | 'headers' => [ |
236 | 'content-type' => 'text/html', | ||
237 | ], | ||
235 | 'language' => 'fr', | 238 | 'language' => 'fr', |
236 | 'status' => '200', | 239 | 'status' => '200', |
237 | 'open_graph' => [ | 240 | 'image' => null, |
238 | 'og_title' => 'my OG title', | ||
239 | 'og_description' => 'OG desc', | ||
240 | 'og_image' => null, | ||
241 | ], | ||
242 | ]); | 241 | ]); |
243 | 242 | ||
244 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); | 243 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); |
@@ -273,14 +272,12 @@ class ContentProxyTest extends TestCase | |||
273 | 'html' => "<h1>Test</h1><p><img src='http://3.3.3.3/nevermind.jpg'/></p>", | 272 | 'html' => "<h1>Test</h1><p><img src='http://3.3.3.3/nevermind.jpg'/></p>", |
274 | 'title' => 'this is my title', | 273 | 'title' => 'this is my title', |
275 | 'url' => 'http://1.1.1.1', | 274 | 'url' => 'http://1.1.1.1', |
276 | 'content_type' => 'text/html', | 275 | 'headers' => [ |
276 | 'content-type' => 'text/html', | ||
277 | ], | ||
277 | 'language' => 'fr', | 278 | 'language' => 'fr', |
278 | 'status' => '200', | 279 | 'status' => '200', |
279 | 'open_graph' => [ | 280 | 'image' => 'http://3.3.3.3/cover.jpg', |
280 | 'og_title' => 'my OG title', | ||
281 | 'og_description' => 'OG desc', | ||
282 | 'og_image' => 'http://3.3.3.3/cover.jpg', | ||
283 | ], | ||
284 | ]); | 281 | ]); |
285 | 282 | ||
286 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); | 283 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); |
@@ -320,9 +317,11 @@ class ContentProxyTest extends TestCase | |||
320 | 'html' => str_repeat('this is my content', 325), | 317 | 'html' => str_repeat('this is my content', 325), |
321 | 'title' => 'this is my title', | 318 | 'title' => 'this is my title', |
322 | 'url' => 'http://1.1.1.1', | 319 | 'url' => 'http://1.1.1.1', |
323 | 'content_type' => 'text/html', | ||
324 | 'language' => 'dontexist', | 320 | 'language' => 'dontexist', |
325 | 'status' => '200', | 321 | 'status' => '200', |
322 | 'headers' => [ | ||
323 | 'content-type' => 'text/html', | ||
324 | ], | ||
326 | ]); | 325 | ]); |
327 | 326 | ||
328 | $proxy = new ContentProxy($graby, $tagger, $validator, $this->getLogger(), $this->fetchingErrorMessage); | 327 | $proxy = new ContentProxy($graby, $tagger, $validator, $this->getLogger(), $this->fetchingErrorMessage); |
@@ -364,14 +363,13 @@ class ContentProxyTest extends TestCase | |||
364 | 'html' => str_repeat('this is my content', 325), | 363 | 'html' => str_repeat('this is my content', 325), |
365 | 'title' => 'this is my title', | 364 | 'title' => 'this is my title', |
366 | 'url' => 'http://1.1.1.1', | 365 | 'url' => 'http://1.1.1.1', |
367 | 'content_type' => 'text/html', | 366 | 'headers' => [ |
367 | 'content-type' => 'text/html', | ||
368 | ], | ||
368 | 'language' => 'fr', | 369 | 'language' => 'fr', |
369 | 'status' => '200', | 370 | 'status' => '200', |
370 | 'open_graph' => [ | 371 | 'description' => 'OG desc', |
371 | 'og_title' => 'my OG title', | 372 | 'image' => 'https://', |
372 | 'og_description' => 'OG desc', | ||
373 | 'og_image' => 'https://', | ||
374 | ], | ||
375 | ]); | 373 | ]); |
376 | 374 | ||
377 | $proxy = new ContentProxy($graby, $tagger, $validator, $this->getLogger(), $this->fetchingErrorMessage); | 375 | $proxy = new ContentProxy($graby, $tagger, $validator, $this->getLogger(), $this->fetchingErrorMessage); |
@@ -404,12 +402,12 @@ class ContentProxyTest extends TestCase | |||
404 | 'html' => str_repeat('this is my content', 325), | 402 | 'html' => str_repeat('this is my content', 325), |
405 | 'title' => 'this is my title', | 403 | 'title' => 'this is my title', |
406 | 'url' => 'http://1.1.1.1', | 404 | 'url' => 'http://1.1.1.1', |
407 | 'content_type' => 'text/html', | ||
408 | 'language' => 'fr', | 405 | 'language' => 'fr', |
409 | 'date' => '1395635872', | 406 | 'date' => '1395635872', |
410 | 'authors' => ['Jeremy', 'Nico', 'Thomas'], | 407 | 'authors' => ['Jeremy', 'Nico', 'Thomas'], |
411 | 'all_headers' => [ | 408 | 'headers' => [ |
412 | 'Cache-Control' => 'no-cache', | 409 | 'cache-control' => 'no-cache', |
410 | 'content-type' => 'text/html', | ||
413 | ], | 411 | ], |
414 | ] | 412 | ] |
415 | ); | 413 | ); |
@@ -447,9 +445,11 @@ class ContentProxyTest extends TestCase | |||
447 | 'html' => str_repeat('this is my content', 325), | 445 | 'html' => str_repeat('this is my content', 325), |
448 | 'title' => 'this is my title', | 446 | 'title' => 'this is my title', |
449 | 'url' => 'http://1.1.1.1', | 447 | 'url' => 'http://1.1.1.1', |
450 | 'content_type' => 'text/html', | ||
451 | 'language' => 'fr', | 448 | 'language' => 'fr', |
452 | 'date' => '2016-09-08T11:55:58+0200', | 449 | 'date' => '2016-09-08T11:55:58+0200', |
450 | 'headers' => [ | ||
451 | 'content-type' => 'text/html', | ||
452 | ], | ||
453 | ] | 453 | ] |
454 | ); | 454 | ); |
455 | 455 | ||
@@ -482,9 +482,11 @@ class ContentProxyTest extends TestCase | |||
482 | 'html' => str_repeat('this is my content', 325), | 482 | 'html' => str_repeat('this is my content', 325), |
483 | 'title' => 'this is my title', | 483 | 'title' => 'this is my title', |
484 | 'url' => 'http://1.1.1.1', | 484 | 'url' => 'http://1.1.1.1', |
485 | 'content_type' => 'text/html', | ||
486 | 'language' => 'fr', | 485 | 'language' => 'fr', |
487 | 'date' => '01 02 2012', | 486 | 'date' => '01 02 2012', |
487 | 'headers' => [ | ||
488 | 'content-type' => 'text/html', | ||
489 | ], | ||
488 | ] | 490 | ] |
489 | ); | 491 | ); |
490 | 492 | ||
@@ -519,8 +521,10 @@ class ContentProxyTest extends TestCase | |||
519 | 'html' => str_repeat('this is my content', 325), | 521 | 'html' => str_repeat('this is my content', 325), |
520 | 'title' => 'this is my title', | 522 | 'title' => 'this is my title', |
521 | 'url' => 'http://1.1.1.1', | 523 | 'url' => 'http://1.1.1.1', |
522 | 'content_type' => 'text/html', | ||
523 | 'language' => 'fr', | 524 | 'language' => 'fr', |
525 | 'headers' => [ | ||
526 | 'content-type' => 'text/html', | ||
527 | ], | ||
524 | ] | 528 | ] |
525 | ); | 529 | ); |
526 | 530 | ||
@@ -559,13 +563,13 @@ class ContentProxyTest extends TestCase | |||
559 | 'html' => $html, | 563 | 'html' => $html, |
560 | 'title' => 'this is my title', | 564 | 'title' => 'this is my title', |
561 | 'url' => 'http://1.1.1.1', | 565 | 'url' => 'http://1.1.1.1', |
562 | 'content_type' => 'text/html', | ||
563 | 'language' => 'fr', | 566 | 'language' => 'fr', |
564 | 'status' => '200', | 567 | 'status' => '200', |
565 | 'open_graph' => [ | 568 | //'og_title' => 'my OG title', |
566 | 'og_title' => 'my OG title', | 569 | 'description' => 'OG desc', |
567 | 'og_description' => 'OG desc', | 570 | 'image' => 'http://3.3.3.3/cover.jpg', |
568 | 'og_image' => 'http://3.3.3.3/cover.jpg', | 571 | 'headers' => [ |
572 | 'content-type' => 'text/html', | ||
569 | ], | 573 | ], |
570 | ] | 574 | ] |
571 | ); | 575 | ); |
@@ -597,9 +601,10 @@ class ContentProxyTest extends TestCase | |||
597 | 'html' => '<p><img src="http://1.1.1.1/image.jpg" /></p>', | 601 | 'html' => '<p><img src="http://1.1.1.1/image.jpg" /></p>', |
598 | 'title' => 'this is my title', | 602 | 'title' => 'this is my title', |
599 | 'url' => 'http://1.1.1.1/image.jpg', | 603 | 'url' => 'http://1.1.1.1/image.jpg', |
600 | 'content_type' => 'image/jpeg', | ||
601 | 'status' => '200', | 604 | 'status' => '200', |
602 | 'open_graph' => [], | 605 | 'headers' => [ |
606 | 'content-type' => 'image/jpeg', | ||
607 | ], | ||
603 | ]); | 608 | ]); |
604 | 609 | ||
605 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); | 610 | $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); |
@@ -637,7 +642,9 @@ class ContentProxyTest extends TestCase | |||
637 | 'html' => false, | 642 | 'html' => false, |
638 | 'title' => $actualTitle, | 643 | 'title' => $actualTitle, |
639 | 'url' => '', | 644 | 'url' => '', |
640 | 'content_type' => 'text/html', | 645 | 'headers' => [ |
646 | 'content-type' => 'text/html', | ||
647 | ], | ||
641 | 'language' => '', | 648 | 'language' => '', |
642 | ]); | 649 | ]); |
643 | 650 | ||
@@ -672,7 +679,9 @@ class ContentProxyTest extends TestCase | |||
672 | 'html' => false, | 679 | 'html' => false, |
673 | 'title' => $actualTitle, | 680 | 'title' => $actualTitle, |
674 | 'url' => '', | 681 | 'url' => '', |
675 | 'content_type' => 'text/html', | 682 | 'headers' => [ |
683 | 'content-type' => 'text/html', | ||
684 | ], | ||
676 | 'language' => '', | 685 | 'language' => '', |
677 | ]); | 686 | ]); |
678 | 687 | ||
@@ -706,7 +715,9 @@ class ContentProxyTest extends TestCase | |||
706 | 'html' => false, | 715 | 'html' => false, |
707 | 'title' => $actualTitle, | 716 | 'title' => $actualTitle, |
708 | 'url' => '', | 717 | 'url' => '', |
709 | 'content_type' => 'application/pdf', | 718 | 'headers' => [ |
719 | 'content-type' => 'application/pdf', | ||
720 | ], | ||
710 | 'language' => '', | 721 | 'language' => '', |
711 | ]); | 722 | ]); |
712 | 723 | ||
@@ -740,7 +751,9 @@ class ContentProxyTest extends TestCase | |||
740 | 'html' => false, | 751 | 'html' => false, |
741 | 'title' => $actualTitle, | 752 | 'title' => $actualTitle, |
742 | 'url' => '', | 753 | 'url' => '', |
743 | 'content_type' => 'application/pdf', | 754 | 'headers' => [ |
755 | 'content-type' => 'application/pdf', | ||
756 | ], | ||
744 | 'language' => '', | 757 | 'language' => '', |
745 | ]); | 758 | ]); |
746 | 759 | ||
@@ -774,7 +787,9 @@ class ContentProxyTest extends TestCase | |||
774 | 'html' => false, | 787 | 'html' => false, |
775 | 'title' => $actualTitle, | 788 | 'title' => $actualTitle, |
776 | 'url' => '', | 789 | 'url' => '', |
777 | 'content_type' => 'application/pdf', | 790 | 'headers' => [ |
791 | 'content-type' => 'application/pdf', | ||
792 | ], | ||
778 | 'language' => '', | 793 | 'language' => '', |
779 | ]); | 794 | ]); |
780 | 795 | ||
@@ -809,7 +824,9 @@ class ContentProxyTest extends TestCase | |||
809 | 'html' => false, | 824 | 'html' => false, |
810 | 'title' => $actualTitle, | 825 | 'title' => $actualTitle, |
811 | 'url' => '', | 826 | 'url' => '', |
812 | 'content_type' => 'application/pdf', | 827 | 'headers' => [ |
828 | 'content-type' => 'application/pdf', | ||
829 | ], | ||
813 | 'language' => '', | 830 | 'language' => '', |
814 | ]); | 831 | ]); |
815 | 832 | ||
@@ -939,7 +956,9 @@ class ContentProxyTest extends TestCase | |||
939 | 'html' => false, | 956 | 'html' => false, |
940 | 'title' => '', | 957 | 'title' => '', |
941 | 'url' => $content_url, | 958 | 'url' => $content_url, |
942 | 'content_type' => '', | 959 | 'headers' => [ |
960 | 'content-type' => '', | ||
961 | ], | ||
943 | 'language' => '', | 962 | 'language' => '', |
944 | ], | 963 | ], |
945 | true | 964 | true |
@@ -970,7 +989,9 @@ class ContentProxyTest extends TestCase | |||
970 | } | 989 | } |
971 | 990 | ||
972 | /** | 991 | /** |
973 | * https://stackoverflow.com/a/18506801. | 992 | * Convert hex to string. |
993 | * | ||
994 | * @see https://stackoverflow.com/a/18506801 | ||
974 | * | 995 | * |
975 | * @param $hex | 996 | * @param $hex |
976 | * | 997 | * |