aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorKevin Decherf <kevin@kdecherf.com>2019-08-11 23:55:52 +0200
committerKevin Decherf <kevin@kdecherf.com>2020-04-25 15:59:23 +0200
commitb22eb276232b5c15a6fbadc9dd10144e709faec3 (patch)
tree7c5b96a42f5b7d926c90b74b1bd949889dce5f70 /tests
parent2495b197614d82b99eed6bbec4562078f4429ad7 (diff)
downloadwallabag-b22eb276232b5c15a6fbadc9dd10144e709faec3.tar.gz
wallabag-b22eb276232b5c15a6fbadc9dd10144e709faec3.tar.zst
wallabag-b22eb276232b5c15a6fbadc9dd10144e709faec3.zip
ContentProxy: replace ignoreUrl with new RuleBasedIgnoreOriginProcessor
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php127
1 files changed, 104 insertions, 23 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 9ce72c79..a65ac17c 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -12,6 +12,7 @@ use Symfony\Component\Validator\ConstraintViolationList;
12use Symfony\Component\Validator\Validator\RecursiveValidator; 12use Symfony\Component\Validator\Validator\RecursiveValidator;
13use Wallabag\CoreBundle\Entity\Entry; 13use Wallabag\CoreBundle\Entity\Entry;
14use Wallabag\CoreBundle\Helper\ContentProxy; 14use Wallabag\CoreBundle\Helper\ContentProxy;
15use Wallabag\CoreBundle\Helper\RuleBasedIgnoreOriginProcessor;
15use Wallabag\CoreBundle\Helper\RuleBasedTagger; 16use Wallabag\CoreBundle\Helper\RuleBasedTagger;
16use Wallabag\UserBundle\Entity\User; 17use Wallabag\UserBundle\Entity\User;
17 18
@@ -25,6 +26,8 @@ class ContentProxyTest extends TestCase
25 $tagger->expects($this->once()) 26 $tagger->expects($this->once())
26 ->method('tag'); 27 ->method('tag');
27 28
29 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
30
28 $graby = $this->getMockBuilder('Graby\Graby') 31 $graby = $this->getMockBuilder('Graby\Graby')
29 ->setMethods(['fetchContent']) 32 ->setMethods(['fetchContent'])
30 ->disableOriginalConstructor() 33 ->disableOriginalConstructor()
@@ -42,7 +45,7 @@ class ContentProxyTest extends TestCase
42 'language' => '', 45 'language' => '',
43 ]); 46 ]);
44 47
45 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 48 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
46 $entry = new Entry(new User()); 49 $entry = new Entry(new User());
47 $proxy->updateEntry($entry, 'http://user@:80'); 50 $proxy->updateEntry($entry, 'http://user@:80');
48 51
@@ -62,6 +65,8 @@ class ContentProxyTest extends TestCase
62 $tagger->expects($this->once()) 65 $tagger->expects($this->once())
63 ->method('tag'); 66 ->method('tag');
64 67
68 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
69
65 $graby = $this->getMockBuilder('Graby\Graby') 70 $graby = $this->getMockBuilder('Graby\Graby')
66 ->setMethods(['fetchContent']) 71 ->setMethods(['fetchContent'])
67 ->disableOriginalConstructor() 72 ->disableOriginalConstructor()
@@ -79,7 +84,7 @@ class ContentProxyTest extends TestCase
79 'language' => '', 84 'language' => '',
80 ]); 85 ]);
81 86
82 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 87 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
83 $entry = new Entry(new User()); 88 $entry = new Entry(new User());
84 $proxy->updateEntry($entry, 'http://0.0.0.0'); 89 $proxy->updateEntry($entry, 'http://0.0.0.0');
85 90
@@ -99,6 +104,8 @@ class ContentProxyTest extends TestCase
99 $tagger->expects($this->once()) 104 $tagger->expects($this->once())
100 ->method('tag'); 105 ->method('tag');
101 106
107 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
108
102 $graby = $this->getMockBuilder('Graby\Graby') 109 $graby = $this->getMockBuilder('Graby\Graby')
103 ->setMethods(['fetchContent']) 110 ->setMethods(['fetchContent'])
104 ->disableOriginalConstructor() 111 ->disableOriginalConstructor()
@@ -118,7 +125,7 @@ class ContentProxyTest extends TestCase
118 'description' => 'desc', 125 'description' => 'desc',
119 ]); 126 ]);
120 127
121 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 128 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
122 $entry = new Entry(new User()); 129 $entry = new Entry(new User());
123 $proxy->updateEntry($entry, 'http://domain.io'); 130 $proxy->updateEntry($entry, 'http://domain.io');
124 131
@@ -139,6 +146,10 @@ class ContentProxyTest extends TestCase
139 $tagger->expects($this->once()) 146 $tagger->expects($this->once())
140 ->method('tag'); 147 ->method('tag');
141 148
149 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
150 $ruleBasedIgnoreOriginProcessor->expects($this->once())
151 ->method('process');
152
142 $graby = $this->getMockBuilder('Graby\Graby') 153 $graby = $this->getMockBuilder('Graby\Graby')
143 ->setMethods(['fetchContent']) 154 ->setMethods(['fetchContent'])
144 ->disableOriginalConstructor() 155 ->disableOriginalConstructor()
@@ -159,7 +170,7 @@ class ContentProxyTest extends TestCase
159 ], 170 ],
160 ]); 171 ]);
161 172
162 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 173 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
163 $entry = new Entry(new User()); 174 $entry = new Entry(new User());
164 $proxy->updateEntry($entry, 'http://0.0.0.0'); 175 $proxy->updateEntry($entry, 'http://0.0.0.0');
165 176
@@ -180,6 +191,10 @@ class ContentProxyTest extends TestCase
180 $tagger->expects($this->once()) 191 $tagger->expects($this->once())
181 ->method('tag'); 192 ->method('tag');
182 193
194 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
195 $ruleBasedIgnoreOriginProcessor->expects($this->once())
196 ->method('process');
197
183 $graby = $this->getMockBuilder('Graby\Graby') 198 $graby = $this->getMockBuilder('Graby\Graby')
184 ->setMethods(['fetchContent']) 199 ->setMethods(['fetchContent'])
185 ->disableOriginalConstructor() 200 ->disableOriginalConstructor()
@@ -200,7 +215,7 @@ class ContentProxyTest extends TestCase
200 ], 215 ],
201 ]); 216 ]);
202 217
203 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 218 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
204 $entry = new Entry(new User()); 219 $entry = new Entry(new User());
205 $proxy->updateEntry($entry, 'http://0.0.0.0'); 220 $proxy->updateEntry($entry, 'http://0.0.0.0');
206 221
@@ -221,6 +236,10 @@ class ContentProxyTest extends TestCase
221 $tagger->expects($this->once()) 236 $tagger->expects($this->once())
222 ->method('tag'); 237 ->method('tag');
223 238
239 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
240 $ruleBasedIgnoreOriginProcessor->expects($this->once())
241 ->method('process');
242
224 $graby = $this->getMockBuilder('Graby\Graby') 243 $graby = $this->getMockBuilder('Graby\Graby')
225 ->setMethods(['fetchContent']) 244 ->setMethods(['fetchContent'])
226 ->disableOriginalConstructor() 245 ->disableOriginalConstructor()
@@ -240,7 +259,7 @@ class ContentProxyTest extends TestCase
240 'image' => null, 259 'image' => null,
241 ]); 260 ]);
242 261
243 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 262 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
244 $entry = new Entry(new User()); 263 $entry = new Entry(new User());
245 $proxy->updateEntry($entry, 'http://0.0.0.0'); 264 $proxy->updateEntry($entry, 'http://0.0.0.0');
246 265
@@ -261,6 +280,10 @@ class ContentProxyTest extends TestCase
261 $tagger->expects($this->once()) 280 $tagger->expects($this->once())
262 ->method('tag'); 281 ->method('tag');
263 282
283 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
284 $ruleBasedIgnoreOriginProcessor->expects($this->once())
285 ->method('process');
286
264 $graby = $this->getMockBuilder('Graby\Graby') 287 $graby = $this->getMockBuilder('Graby\Graby')
265 ->setMethods(['fetchContent']) 288 ->setMethods(['fetchContent'])
266 ->disableOriginalConstructor() 289 ->disableOriginalConstructor()
@@ -280,7 +303,7 @@ class ContentProxyTest extends TestCase
280 'image' => 'http://3.3.3.3/cover.jpg', 303 'image' => 'http://3.3.3.3/cover.jpg',
281 ]); 304 ]);
282 305
283 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 306 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
284 $entry = new Entry(new User()); 307 $entry = new Entry(new User());
285 $proxy->updateEntry($entry, 'http://0.0.0.0'); 308 $proxy->updateEntry($entry, 'http://0.0.0.0');
286 309
@@ -301,6 +324,10 @@ class ContentProxyTest extends TestCase
301 $tagger->expects($this->once()) 324 $tagger->expects($this->once())
302 ->method('tag'); 325 ->method('tag');
303 326
327 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
328 $ruleBasedIgnoreOriginProcessor->expects($this->once())
329 ->method('process');
330
304 $validator = $this->getValidator(false); 331 $validator = $this->getValidator(false);
305 $validator->expects($this->once()) 332 $validator->expects($this->once())
306 ->method('validate') 333 ->method('validate')
@@ -324,7 +351,7 @@ class ContentProxyTest extends TestCase
324 ], 351 ],
325 ]); 352 ]);
326 353
327 $proxy = new ContentProxy($graby, $tagger, $validator, $this->getLogger(), $this->fetchingErrorMessage); 354 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $validator, $this->getLogger(), $this->fetchingErrorMessage);
328 $entry = new Entry(new User()); 355 $entry = new Entry(new User());
329 $proxy->updateEntry($entry, 'http://0.0.0.0'); 356 $proxy->updateEntry($entry, 'http://0.0.0.0');
330 357
@@ -344,6 +371,10 @@ class ContentProxyTest extends TestCase
344 $tagger->expects($this->once()) 371 $tagger->expects($this->once())
345 ->method('tag'); 372 ->method('tag');
346 373
374 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
375 $ruleBasedIgnoreOriginProcessor->expects($this->once())
376 ->method('process');
377
347 $validator = $this->getValidator(false); 378 $validator = $this->getValidator(false);
348 $validator->expects($this->exactly(2)) 379 $validator->expects($this->exactly(2))
349 ->method('validate') 380 ->method('validate')
@@ -372,7 +403,7 @@ class ContentProxyTest extends TestCase
372 'image' => 'https://', 403 'image' => 'https://',
373 ]); 404 ]);
374 405
375 $proxy = new ContentProxy($graby, $tagger, $validator, $this->getLogger(), $this->fetchingErrorMessage); 406 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $validator, $this->getLogger(), $this->fetchingErrorMessage);
376 $entry = new Entry(new User()); 407 $entry = new Entry(new User());
377 $proxy->updateEntry($entry, 'http://0.0.0.0'); 408 $proxy->updateEntry($entry, 'http://0.0.0.0');
378 409
@@ -393,7 +424,11 @@ class ContentProxyTest extends TestCase
393 $tagger->expects($this->once()) 424 $tagger->expects($this->once())
394 ->method('tag'); 425 ->method('tag');
395 426
396 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage, true); 427 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
428 $ruleBasedIgnoreOriginProcessor->expects($this->once())
429 ->method('process');
430
431 $proxy = new ContentProxy((new Graby()), $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage, true);
397 $entry = new Entry(new User()); 432 $entry = new Entry(new User());
398 $proxy->updateEntry( 433 $proxy->updateEntry(
399 $entry, 434 $entry,
@@ -433,10 +468,12 @@ class ContentProxyTest extends TestCase
433 $tagger->expects($this->once()) 468 $tagger->expects($this->once())
434 ->method('tag'); 469 ->method('tag');
435 470
471 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
472
436 $logHandler = new TestHandler(); 473 $logHandler = new TestHandler();
437 $logger = new Logger('test', [$logHandler]); 474 $logger = new Logger('test', [$logHandler]);
438 475
439 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $logger, $this->fetchingErrorMessage); 476 $proxy = new ContentProxy((new Graby()), $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $logger, $this->fetchingErrorMessage);
440 $entry = new Entry(new User()); 477 $entry = new Entry(new User());
441 $proxy->updateEntry( 478 $proxy->updateEntry(
442 $entry, 479 $entry,
@@ -469,11 +506,13 @@ class ContentProxyTest extends TestCase
469 $tagger->expects($this->once()) 506 $tagger->expects($this->once())
470 ->method('tag'); 507 ->method('tag');
471 508
509 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
510
472 $logger = new Logger('foo'); 511 $logger = new Logger('foo');
473 $handler = new TestHandler(); 512 $handler = new TestHandler();
474 $logger->pushHandler($handler); 513 $logger->pushHandler($handler);
475 514
476 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $logger, $this->fetchingErrorMessage); 515 $proxy = new ContentProxy((new Graby()), $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $logger, $this->fetchingErrorMessage);
477 $entry = new Entry(new User()); 516 $entry = new Entry(new User());
478 $proxy->updateEntry( 517 $proxy->updateEntry(
479 $entry, 518 $entry,
@@ -512,7 +551,9 @@ class ContentProxyTest extends TestCase
512 ->method('tag') 551 ->method('tag')
513 ->will($this->throwException(new \Exception())); 552 ->will($this->throwException(new \Exception()));
514 553
515 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 554 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
555
556 $proxy = new ContentProxy((new Graby()), $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
516 $entry = new Entry(new User()); 557 $entry = new Entry(new User());
517 $proxy->updateEntry( 558 $proxy->updateEntry(
518 $entry, 559 $entry,
@@ -554,7 +595,9 @@ class ContentProxyTest extends TestCase
554 $tagger->expects($this->once()) 595 $tagger->expects($this->once())
555 ->method('tag'); 596 ->method('tag');
556 597
557 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 598 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
599
600 $proxy = new ContentProxy((new Graby()), $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
558 $entry = new Entry(new User()); 601 $entry = new Entry(new User());
559 $proxy->updateEntry( 602 $proxy->updateEntry(
560 $entry, 603 $entry,
@@ -590,6 +633,8 @@ class ContentProxyTest extends TestCase
590 $tagger->expects($this->once()) 633 $tagger->expects($this->once())
591 ->method('tag'); 634 ->method('tag');
592 635
636 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
637
593 $graby = $this->getMockBuilder('Graby\Graby') 638 $graby = $this->getMockBuilder('Graby\Graby')
594 ->setMethods(['fetchContent']) 639 ->setMethods(['fetchContent'])
595 ->disableOriginalConstructor() 640 ->disableOriginalConstructor()
@@ -607,7 +652,7 @@ class ContentProxyTest extends TestCase
607 ], 652 ],
608 ]); 653 ]);
609 654
610 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 655 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
611 $entry = new Entry(new User()); 656 $entry = new Entry(new User());
612 $proxy->updateEntry($entry, 'http://0.0.0.0'); 657 $proxy->updateEntry($entry, 'http://0.0.0.0');
613 658
@@ -631,6 +676,8 @@ class ContentProxyTest extends TestCase
631 $tagger->expects($this->once()) 676 $tagger->expects($this->once())
632 ->method('tag'); 677 ->method('tag');
633 678
679 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
680
634 $graby = $this->getMockBuilder('Graby\Graby') 681 $graby = $this->getMockBuilder('Graby\Graby')
635 ->setMethods(['fetchContent']) 682 ->setMethods(['fetchContent'])
636 ->disableOriginalConstructor() 683 ->disableOriginalConstructor()
@@ -648,7 +695,7 @@ class ContentProxyTest extends TestCase
648 'language' => '', 695 'language' => '',
649 ]); 696 ]);
650 697
651 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 698 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
652 $entry = new Entry(new User()); 699 $entry = new Entry(new User());
653 $proxy->updateEntry($entry, 'http://0.0.0.0'); 700 $proxy->updateEntry($entry, 'http://0.0.0.0');
654 701
@@ -668,6 +715,8 @@ class ContentProxyTest extends TestCase
668 $tagger->expects($this->once()) 715 $tagger->expects($this->once())
669 ->method('tag'); 716 ->method('tag');
670 717
718 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
719
671 $graby = $this->getMockBuilder('Graby\Graby') 720 $graby = $this->getMockBuilder('Graby\Graby')
672 ->setMethods(['fetchContent']) 721 ->setMethods(['fetchContent'])
673 ->disableOriginalConstructor() 722 ->disableOriginalConstructor()
@@ -685,7 +734,7 @@ class ContentProxyTest extends TestCase
685 'language' => '', 734 'language' => '',
686 ]); 735 ]);
687 736
688 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 737 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
689 $entry = new Entry(new User()); 738 $entry = new Entry(new User());
690 $proxy->updateEntry($entry, 'http://0.0.0.0'); 739 $proxy->updateEntry($entry, 'http://0.0.0.0');
691 740
@@ -704,6 +753,8 @@ class ContentProxyTest extends TestCase
704 $tagger->expects($this->once()) 753 $tagger->expects($this->once())
705 ->method('tag'); 754 ->method('tag');
706 755
756 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
757
707 $graby = $this->getMockBuilder('Graby\Graby') 758 $graby = $this->getMockBuilder('Graby\Graby')
708 ->setMethods(['fetchContent']) 759 ->setMethods(['fetchContent'])
709 ->disableOriginalConstructor() 760 ->disableOriginalConstructor()
@@ -721,7 +772,7 @@ class ContentProxyTest extends TestCase
721 'language' => '', 772 'language' => '',
722 ]); 773 ]);
723 774
724 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 775 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
725 $entry = new Entry(new User()); 776 $entry = new Entry(new User());
726 $proxy->updateEntry($entry, 'http://0.0.0.0'); 777 $proxy->updateEntry($entry, 'http://0.0.0.0');
727 778
@@ -740,6 +791,8 @@ class ContentProxyTest extends TestCase
740 $tagger->expects($this->once()) 791 $tagger->expects($this->once())
741 ->method('tag'); 792 ->method('tag');
742 793
794 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
795
743 $graby = $this->getMockBuilder('Graby\Graby') 796 $graby = $this->getMockBuilder('Graby\Graby')
744 ->setMethods(['fetchContent']) 797 ->setMethods(['fetchContent'])
745 ->disableOriginalConstructor() 798 ->disableOriginalConstructor()
@@ -757,7 +810,7 @@ class ContentProxyTest extends TestCase
757 'language' => '', 810 'language' => '',
758 ]); 811 ]);
759 812
760 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 813 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
761 $entry = new Entry(new User()); 814 $entry = new Entry(new User());
762 $proxy->updateEntry($entry, 'http://0.0.0.0'); 815 $proxy->updateEntry($entry, 'http://0.0.0.0');
763 816
@@ -776,6 +829,8 @@ class ContentProxyTest extends TestCase
776 $tagger->expects($this->once()) 829 $tagger->expects($this->once())
777 ->method('tag'); 830 ->method('tag');
778 831
832 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
833
779 $graby = $this->getMockBuilder('Graby\Graby') 834 $graby = $this->getMockBuilder('Graby\Graby')
780 ->setMethods(['fetchContent']) 835 ->setMethods(['fetchContent'])
781 ->disableOriginalConstructor() 836 ->disableOriginalConstructor()
@@ -793,7 +848,7 @@ class ContentProxyTest extends TestCase
793 'language' => '', 848 'language' => '',
794 ]); 849 ]);
795 850
796 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 851 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
797 $entry = new Entry(new User()); 852 $entry = new Entry(new User());
798 $proxy->updateEntry($entry, 'http://0.0.0.0'); 853 $proxy->updateEntry($entry, 'http://0.0.0.0');
799 854
@@ -813,6 +868,8 @@ class ContentProxyTest extends TestCase
813 $tagger->expects($this->once()) 868 $tagger->expects($this->once())
814 ->method('tag'); 869 ->method('tag');
815 870
871 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
872
816 $graby = $this->getMockBuilder('Graby\Graby') 873 $graby = $this->getMockBuilder('Graby\Graby')
817 ->setMethods(['fetchContent']) 874 ->setMethods(['fetchContent'])
818 ->disableOriginalConstructor() 875 ->disableOriginalConstructor()
@@ -830,7 +887,7 @@ class ContentProxyTest extends TestCase
830 'language' => '', 887 'language' => '',
831 ]); 888 ]);
832 889
833 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage); 890 $proxy = new ContentProxy($graby, $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
834 $entry = new Entry(new User()); 891 $entry = new Entry(new User());
835 $proxy->updateEntry($entry, 'http://0.0.0.0'); 892 $proxy->updateEntry($entry, 'http://0.0.0.0');
836 893
@@ -850,6 +907,7 @@ class ContentProxyTest extends TestCase
850 * $expected_entry_url 907 * $expected_entry_url
851 * $expected_origin_url 908 * $expected_origin_url
852 * $expected_domain 909 * $expected_domain
910 * $processor_result
853 */ 911 */
854 public function dataForChangedUrl() 912 public function dataForChangedUrl()
855 { 913 {
@@ -861,6 +919,7 @@ class ContentProxyTest extends TestCase
861 'http://1.1.1.1', 919 'http://1.1.1.1',
862 'http://0.0.0.0', 920 'http://0.0.0.0',
863 '1.1.1.1', 921 '1.1.1.1',
922 false,
864 ], 923 ],
865 'origin already set' => [ 924 'origin already set' => [
866 'http://0.0.0.0', 925 'http://0.0.0.0',
@@ -869,6 +928,7 @@ class ContentProxyTest extends TestCase
869 'http://1.1.1.1', 928 'http://1.1.1.1',
870 'http://hello', 929 'http://hello',
871 '1.1.1.1', 930 '1.1.1.1',
931 false,
872 ], 932 ],
873 'trailing slash' => [ 933 'trailing slash' => [
874 'https://example.com/hello-world', 934 'https://example.com/hello-world',
@@ -877,6 +937,7 @@ class ContentProxyTest extends TestCase
877 'https://example.com/hello-world/', 937 'https://example.com/hello-world/',
878 null, 938 null,
879 'example.com', 939 'example.com',
940 false,
880 ], 941 ],
881 'query string in fetched content' => [ 942 'query string in fetched content' => [
882 'https://example.org/hello', 943 'https://example.org/hello',
@@ -885,6 +946,7 @@ class ContentProxyTest extends TestCase
885 'https://example.org/hello?world=1', 946 'https://example.org/hello?world=1',
886 'https://example.org/hello', 947 'https://example.org/hello',
887 'example.org', 948 'example.org',
949 false,
888 ], 950 ],
889 'fragment in fetched content' => [ 951 'fragment in fetched content' => [
890 'https://example.org/hello', 952 'https://example.org/hello',
@@ -893,6 +955,7 @@ class ContentProxyTest extends TestCase
893 'https://example.org/hello', 955 'https://example.org/hello',
894 null, 956 null,
895 'example.org', 957 'example.org',
958 false,
896 ], 959 ],
897 'fragment and query string in fetched content' => [ 960 'fragment and query string in fetched content' => [
898 'https://example.org/hello', 961 'https://example.org/hello',
@@ -901,6 +964,7 @@ class ContentProxyTest extends TestCase
901 'https://example.org/hello?foo#world', 964 'https://example.org/hello?foo#world',
902 'https://example.org/hello', 965 'https://example.org/hello',
903 'example.org', 966 'example.org',
967 false,
904 ], 968 ],
905 'different path and query string in fetch content' => [ 969 'different path and query string in fetch content' => [
906 'https://example.org/hello', 970 'https://example.org/hello',
@@ -909,6 +973,7 @@ class ContentProxyTest extends TestCase
909 'https://example.org/world?foo', 973 'https://example.org/world?foo',
910 'https://example.org/hello', 974 'https://example.org/hello',
911 'example.org', 975 'example.org',
976 false,
912 ], 977 ],
913 'feedproxy ignore list test' => [ 978 'feedproxy ignore list test' => [
914 'http://feedproxy.google.com/~r/Wallabag/~3/helloworld', 979 'http://feedproxy.google.com/~r/Wallabag/~3/helloworld',
@@ -917,6 +982,7 @@ class ContentProxyTest extends TestCase
917 'https://example.org/hello-wallabag', 982 'https://example.org/hello-wallabag',
918 null, 983 null,
919 'example.org', 984 'example.org',
985 true,
920 ], 986 ],
921 'feedproxy ignore list test with origin url already set' => [ 987 'feedproxy ignore list test with origin url already set' => [
922 'http://feedproxy.google.com/~r/Wallabag/~3/helloworld', 988 'http://feedproxy.google.com/~r/Wallabag/~3/helloworld',
@@ -925,6 +991,7 @@ class ContentProxyTest extends TestCase
925 'https://example.org/hello-wallabag', 991 'https://example.org/hello-wallabag',
926 'https://example.org/this-is-source', 992 'https://example.org/this-is-source',
927 'example.org', 993 'example.org',
994 true,
928 ], 995 ],
929 'lemonde ignore pattern test' => [ 996 'lemonde ignore pattern test' => [
930 'http://www.lemonde.fr/tiny/url', 997 'http://www.lemonde.fr/tiny/url',
@@ -933,6 +1000,7 @@ class ContentProxyTest extends TestCase
933 'http://example.com/hello-world', 1000 'http://example.com/hello-world',
934 null, 1001 null,
935 'example.com', 1002 'example.com',
1003 true,
936 ], 1004 ],
937 ]; 1005 ];
938 } 1006 }
@@ -940,13 +1008,18 @@ class ContentProxyTest extends TestCase
940 /** 1008 /**
941 * @dataProvider dataForChangedUrl 1009 * @dataProvider dataForChangedUrl
942 */ 1010 */
943 public function testWithChangedUrl($entry_url, $origin_url, $content_url, $expected_entry_url, $expected_origin_url, $expected_domain) 1011 public function testWithChangedUrl($entry_url, $origin_url, $content_url, $expected_entry_url, $expected_origin_url, $expected_domain, $processor_result)
944 { 1012 {
945 $tagger = $this->getTaggerMock(); 1013 $tagger = $this->getTaggerMock();
946 $tagger->expects($this->once()) 1014 $tagger->expects($this->once())
947 ->method('tag'); 1015 ->method('tag');
948 1016
949 $proxy = new ContentProxy((new Graby()), $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage, true); 1017 $ruleBasedIgnoreOriginProcessor = $this->getRuleBasedIgnoreOriginProcessorMock();
1018 $ruleBasedIgnoreOriginProcessor->expects($this->once())
1019 ->method('process')
1020 ->willReturn($processor_result);
1021
1022 $proxy = new ContentProxy((new Graby()), $tagger, $ruleBasedIgnoreOriginProcessor, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage, true);
950 $entry = new Entry(new User()); 1023 $entry = new Entry(new User());
951 $entry->setOriginUrl($origin_url); 1024 $entry->setOriginUrl($origin_url);
952 $proxy->updateEntry( 1025 $proxy->updateEntry(
@@ -1015,6 +1088,14 @@ class ContentProxyTest extends TestCase
1015 ->getMock(); 1088 ->getMock();
1016 } 1089 }
1017 1090
1091 private function getRuleBasedIgnoreOriginProcessorMock()
1092 {
1093 return $this->getMockBuilder(RuleBasedIgnoreOriginProcessor::class)
1094 ->setMethods(['process'])
1095 ->disableOriginalConstructor()
1096 ->getMock();
1097 }
1098
1018 private function getLogger() 1099 private function getLogger()
1019 { 1100 {
1020 return new NullLogger(); 1101 return new NullLogger();