From f530f7f5e19eb611ba79856d3ca3b7aebd2af367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sun, 11 Oct 2015 22:27:47 +0200 Subject: Fix ContentProxyTest --- .../CoreBundle/Tests/Helper/ContentProxyTest.php | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php index 4bce4708..1688a48a 100644 --- a/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php +++ b/src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php @@ -10,6 +10,10 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase { public function testWithEmptyContent() { + $tagger = $this->getTaggerMock(); + $tagger->expects($this->once()) + ->method('tag'); + $graby = $this->getMockBuilder('Graby\Graby') ->setMethods(array('fetchContent')) ->disableOriginalConstructor() @@ -25,7 +29,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase 'language' => '', )); - $proxy = new ContentProxy($graby); + $proxy = new ContentProxy($graby, $tagger); $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); $this->assertEquals('http://0.0.0.0', $entry->getUrl()); @@ -40,6 +44,10 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase public function testWithEmptyContentButOG() { + $tagger = $this->getTaggerMock(); + $tagger->expects($this->once()) + ->method('tag'); + $graby = $this->getMockBuilder('Graby\Graby') ->setMethods(array('fetchContent')) ->disableOriginalConstructor() @@ -59,7 +67,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase ), )); - $proxy = new ContentProxy($graby); + $proxy = new ContentProxy($graby, $tagger); $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); $this->assertEquals('http://domain.io', $entry->getUrl()); @@ -74,6 +82,10 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase public function testWithContent() { + $tagger = $this->getTaggerMock(); + $tagger->expects($this->once()) + ->method('tag'); + $graby = $this->getMockBuilder('Graby\Graby') ->setMethods(array('fetchContent')) ->disableOriginalConstructor() @@ -94,7 +106,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase ), )); - $proxy = new ContentProxy($graby); + $proxy = new ContentProxy($graby, $tagger); $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); $this->assertEquals('http://1.1.1.1', $entry->getUrl()); @@ -106,4 +118,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase $this->assertEquals(4.0, $entry->getReadingTime()); $this->assertEquals('1.1.1.1', $entry->getDomainName()); } + + private function getTaggerMock() + { + return $this->getMockBuilder('Wallabag\CoreBundle\Helper\RuleBasedTagger') + ->setMethods(array('tag')) + ->disableOriginalConstructor() + ->getMock(); + } } -- cgit v1.2.3