Fix ContentProxyTest

This commit is contained in:
Kévin Gomez 2015-10-11 22:27:47 +02:00
parent 1d7b350b25
commit f530f7f5e1

View file

@ -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();
}
}