From fc2b7bda53f4dd66d193383983d48ca92016b5b3 Mon Sep 17 00:00:00 2001 From: Jerome Charaoui Date: Fri, 2 Dec 2016 23:59:18 -0500 Subject: Fix ContentProxy tests --- .../CoreBundle/Helper/ContentProxyTest.php | 35 +++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index 33b3ff2a..55e4d506 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php @@ -1,14 +1,15 @@ '', ]); - $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); + $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); $entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80'); $this->assertEquals('http://user@:80', $entry->getUrl()); $this->assertEmpty($entry->getTitle()); - $this->assertEquals('

Unable to retrieve readable content.

', $entry->getContent()); + $this->assertEquals($this->fetchingErrorMessage, $entry->getContent()); $this->assertEmpty($entry->getPreviewPicture()); $this->assertEmpty($entry->getMimetype()); $this->assertEmpty($entry->getLanguage()); @@ -65,12 +66,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase 'language' => '', ]); - $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); + $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); $this->assertEquals('http://0.0.0.0', $entry->getUrl()); $this->assertEmpty($entry->getTitle()); - $this->assertEquals('

Unable to retrieve readable content.

', $entry->getContent()); + $this->assertEquals($this->fetchingErrorMessage, $entry->getContent()); $this->assertEmpty($entry->getPreviewPicture()); $this->assertEmpty($entry->getMimetype()); $this->assertEmpty($entry->getLanguage()); @@ -104,12 +105,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase ], ]); - $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); + $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); $this->assertEquals('http://domain.io', $entry->getUrl()); $this->assertEquals('my title', $entry->getTitle()); - $this->assertEquals('

Unable to retrieve readable content.

But we found a short description:

desc', $entry->getContent()); + $this->assertEquals($this->fetchingErrorMessage . '

But we found a short description:

desc', $entry->getContent()); $this->assertEmpty($entry->getPreviewPicture()); $this->assertEmpty($entry->getLanguage()); $this->assertEmpty($entry->getHttpStatus()); @@ -145,7 +146,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase ], ]); - $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); + $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); $this->assertEquals('http://1.1.1.1', $entry->getUrl()); @@ -167,7 +168,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase $graby = $this->getMockBuilder('Graby\Graby')->getMock(); - $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); + $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ 'html' => str_repeat('this is my content', 325), 'title' => 'this is my title', @@ -197,7 +198,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase ->will($this->throwException(new \Exception())); $tagRepo = $this->getTagRepositoryMock(); - $proxy = new ContentProxy($graby, $tagger, $tagRepo, $this->getLogger()); + $proxy = new ContentProxy($graby, $tagger, $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ 'html' => str_repeat('this is my content', 325), @@ -217,7 +218,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase ->getMock(); $tagRepo = $this->getTagRepositoryMock(); - $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); + $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); $entry = new Entry(new User()); @@ -235,7 +236,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase ->getMock(); $tagRepo = $this->getTagRepositoryMock(); - $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); + $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); $entry = new Entry(new User()); @@ -253,7 +254,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase ->getMock(); $tagRepo = $this->getTagRepositoryMock(); - $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); + $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); $entry = new Entry(new User()); @@ -269,7 +270,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase ->getMock(); $tagRepo = $this->getTagRepositoryMock(); - $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); + $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); $entry = new Entry(new User()); @@ -285,7 +286,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase ->getMock(); $tagRepo = $this->getTagRepositoryMock(); - $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); + $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); $tagEntity = new Tag(); $tagEntity->setLabel('tag1'); @@ -310,7 +311,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase $tagRepo->expects($this->never()) ->method('__call'); - $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); + $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); $tagEntity = new Tag(); $tagEntity->setLabel('tag1'); -- cgit v1.2.3 From dba1e0b1883e32005fc7f980b5206dc5eb078e29 Mon Sep 17 00:00:00 2001 From: Jerome Charaoui Date: Fri, 2 Dec 2016 23:59:43 -0500 Subject: Fix WallabagV1Controller test Account for URL redirection in refreshed entry. --- .../Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php index 2c370ed9..acc39997 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php @@ -112,7 +112,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') ->findByUrlAndUserId( - 'http://www.framablog.org/index.php/post/2014/02/05/Framabag-service-libre-gratuit-interview-developpeur', + 'https://framablog.org/2014/02/05/framabag-service-libre-gratuit-interview-developpeur/', $this->getLoggedInUserId() ); @@ -126,9 +126,9 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); $this->assertContains('flashes.import.notice.summary', $body[0]); - $this->assertEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok'); - $this->assertEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok'); - $this->assertEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok'); + $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok'); + $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok'); + $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok'); $this->assertEquals(1, count($content->getTags())); $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); } -- cgit v1.2.3 From cd82ace70a9fede70f44f7f11c05456118b36b04 Mon Sep 17 00:00:00 2001 From: Jerome Charaoui Date: Sat, 3 Dec 2016 00:26:57 -0500 Subject: Add missing CoreKernelTestCase class --- tests/Wallabag/CoreBundle/CoreKernelTestCase.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/Wallabag/CoreBundle/CoreKernelTestCase.php (limited to 'tests') diff --git a/tests/Wallabag/CoreBundle/CoreKernelTestCase.php b/tests/Wallabag/CoreBundle/CoreKernelTestCase.php new file mode 100644 index 00000000..d14421f1 --- /dev/null +++ b/tests/Wallabag/CoreBundle/CoreKernelTestCase.php @@ -0,0 +1,17 @@ +getContainer(); + $this->fetchingErrorMessage = $container->getParameter('wallabag_core.fetching_error_message'); + } +} -- cgit v1.2.3 From a2c1b94e8200260c1d6172ec2c36ef9a0e956d02 Mon Sep 17 00:00:00 2001 From: Jerome Charaoui Date: Sat, 3 Dec 2016 09:44:34 -0500 Subject: Revert switch to KernelTestCase for ContentProxyTest Define the error string manually inside the test class instead of fetching it from app config. --- tests/Wallabag/CoreBundle/CoreKernelTestCase.php | 17 ----------------- tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | 7 ++++--- 2 files changed, 4 insertions(+), 20 deletions(-) delete mode 100644 tests/Wallabag/CoreBundle/CoreKernelTestCase.php (limited to 'tests') diff --git a/tests/Wallabag/CoreBundle/CoreKernelTestCase.php b/tests/Wallabag/CoreBundle/CoreKernelTestCase.php deleted file mode 100644 index d14421f1..00000000 --- a/tests/Wallabag/CoreBundle/CoreKernelTestCase.php +++ /dev/null @@ -1,17 +0,0 @@ -getContainer(); - $this->fetchingErrorMessage = $container->getParameter('wallabag_core.fetching_error_message'); - } -} diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index 55e4d506..2ca13b91 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php @@ -1,16 +1,17 @@ troubleshoot this issue.'; + public function testWithBadUrl() { $tagger = $this->getTaggerMock(); -- cgit v1.2.3