aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php')
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 5c99e461..398592e1 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -5,6 +5,7 @@ namespace Tests\Wallabag\CoreBundle\Helper;
5use Graby\Graby; 5use Graby\Graby;
6use Monolog\Handler\TestHandler; 6use Monolog\Handler\TestHandler;
7use Monolog\Logger; 7use Monolog\Logger;
8use PHPUnit\Framework\TestCase;
8use Psr\Log\NullLogger; 9use Psr\Log\NullLogger;
9use Symfony\Component\Validator\ConstraintViolation; 10use Symfony\Component\Validator\ConstraintViolation;
10use Symfony\Component\Validator\ConstraintViolationList; 11use Symfony\Component\Validator\ConstraintViolationList;
@@ -15,7 +16,7 @@ use Wallabag\CoreBundle\Helper\ContentProxy;
15use Wallabag\CoreBundle\Helper\RuleBasedTagger; 16use Wallabag\CoreBundle\Helper\RuleBasedTagger;
16use Wallabag\UserBundle\Entity\User; 17use Wallabag\UserBundle\Entity\User;
17 18
18class ContentProxyTest extends \PHPUnit_Framework_TestCase 19class ContentProxyTest extends TestCase
19{ 20{
20 private $fetchingErrorMessage = 'wallabag can\'t retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>.'; 21 private $fetchingErrorMessage = 'wallabag can\'t retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>.';
21 22
@@ -220,7 +221,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
220 $tagger->expects($this->once()) 221 $tagger->expects($this->once())
221 ->method('tag'); 222 ->method('tag');
222 223
223 $validator = $this->getValidator(); 224 $validator = $this->getValidator(false);
224 $validator->expects($this->once()) 225 $validator->expects($this->once())
225 ->method('validate') 226 ->method('validate')
226 ->willReturn(new ConstraintViolationList([new ConstraintViolation('oops', 'oops', [], 'oops', 'language', 'dontexist')])); 227 ->willReturn(new ConstraintViolationList([new ConstraintViolation('oops', 'oops', [], 'oops', 'language', 'dontexist')]));
@@ -261,7 +262,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
261 $tagger->expects($this->once()) 262 $tagger->expects($this->once())
262 ->method('tag'); 263 ->method('tag');
263 264
264 $validator = $this->getValidator(); 265 $validator = $this->getValidator(false);
265 $validator->expects($this->exactly(2)) 266 $validator->expects($this->exactly(2))
266 ->method('validate') 267 ->method('validate')
267 ->will($this->onConsecutiveCalls( 268 ->will($this->onConsecutiveCalls(
@@ -544,11 +545,19 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
544 return new NullLogger(); 545 return new NullLogger();
545 } 546 }
546 547
547 private function getValidator() 548 private function getValidator($withDefaultMock = true)
548 { 549 {
549 return $this->getMockBuilder(RecursiveValidator::class) 550 $mock = $this->getMockBuilder(RecursiveValidator::class)
550 ->setMethods(['validate']) 551 ->setMethods(['validate'])
551 ->disableOriginalConstructor() 552 ->disableOriginalConstructor()
552 ->getMock(); 553 ->getMock();
554
555 if ($withDefaultMock) {
556 $mock->expects($this->any())
557 ->method('validate')
558 ->willReturn(new ConstraintViolationList());
559 }
560
561 return $mock;
553 } 562 }
554} 563}