aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
diff options
context:
space:
mode:
authorKévin Gomez <contact@kevingomez.fr>2015-10-11 22:27:47 +0200
committerKévin Gomez <contact@kevingomez.fr>2015-11-11 16:23:49 +0100
commitf530f7f5e19eb611ba79856d3ca3b7aebd2af367 (patch)
treefa260185d89abbf4ef0f74071093f390115c8654 /src/Wallabag/CoreBundle
parent1d7b350b259ccc0110318a377ae3b3752ec6b9fb (diff)
downloadwallabag-f530f7f5e19eb611ba79856d3ca3b7aebd2af367.tar.gz
wallabag-f530f7f5e19eb611ba79856d3ca3b7aebd2af367.tar.zst
wallabag-f530f7f5e19eb611ba79856d3ca3b7aebd2af367.zip
Fix ContentProxyTest
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Helper/ContentProxyTest.php26
1 files changed, 23 insertions, 3 deletions
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
10{ 10{
11 public function testWithEmptyContent() 11 public function testWithEmptyContent()
12 { 12 {
13 $tagger = $this->getTaggerMock();
14 $tagger->expects($this->once())
15 ->method('tag');
16
13 $graby = $this->getMockBuilder('Graby\Graby') 17 $graby = $this->getMockBuilder('Graby\Graby')
14 ->setMethods(array('fetchContent')) 18 ->setMethods(array('fetchContent'))
15 ->disableOriginalConstructor() 19 ->disableOriginalConstructor()
@@ -25,7 +29,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
25 'language' => '', 29 'language' => '',
26 )); 30 ));
27 31
28 $proxy = new ContentProxy($graby); 32 $proxy = new ContentProxy($graby, $tagger);
29 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 33 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
30 34
31 $this->assertEquals('http://0.0.0.0', $entry->getUrl()); 35 $this->assertEquals('http://0.0.0.0', $entry->getUrl());
@@ -40,6 +44,10 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
40 44
41 public function testWithEmptyContentButOG() 45 public function testWithEmptyContentButOG()
42 { 46 {
47 $tagger = $this->getTaggerMock();
48 $tagger->expects($this->once())
49 ->method('tag');
50
43 $graby = $this->getMockBuilder('Graby\Graby') 51 $graby = $this->getMockBuilder('Graby\Graby')
44 ->setMethods(array('fetchContent')) 52 ->setMethods(array('fetchContent'))
45 ->disableOriginalConstructor() 53 ->disableOriginalConstructor()
@@ -59,7 +67,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
59 ), 67 ),
60 )); 68 ));
61 69
62 $proxy = new ContentProxy($graby); 70 $proxy = new ContentProxy($graby, $tagger);
63 $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); 71 $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io');
64 72
65 $this->assertEquals('http://domain.io', $entry->getUrl()); 73 $this->assertEquals('http://domain.io', $entry->getUrl());
@@ -74,6 +82,10 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
74 82
75 public function testWithContent() 83 public function testWithContent()
76 { 84 {
85 $tagger = $this->getTaggerMock();
86 $tagger->expects($this->once())
87 ->method('tag');
88
77 $graby = $this->getMockBuilder('Graby\Graby') 89 $graby = $this->getMockBuilder('Graby\Graby')
78 ->setMethods(array('fetchContent')) 90 ->setMethods(array('fetchContent'))
79 ->disableOriginalConstructor() 91 ->disableOriginalConstructor()
@@ -94,7 +106,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
94 ), 106 ),
95 )); 107 ));
96 108
97 $proxy = new ContentProxy($graby); 109 $proxy = new ContentProxy($graby, $tagger);
98 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 110 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
99 111
100 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 112 $this->assertEquals('http://1.1.1.1', $entry->getUrl());
@@ -106,4 +118,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
106 $this->assertEquals(4.0, $entry->getReadingTime()); 118 $this->assertEquals(4.0, $entry->getReadingTime());
107 $this->assertEquals('1.1.1.1', $entry->getDomainName()); 119 $this->assertEquals('1.1.1.1', $entry->getDomainName());
108 } 120 }
121
122 private function getTaggerMock()
123 {
124 return $this->getMockBuilder('Wallabag\CoreBundle\Helper\RuleBasedTagger')
125 ->setMethods(array('tag'))
126 ->disableOriginalConstructor()
127 ->getMock();
128 }
109} 129}