diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-03-11 09:42:08 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-03-20 21:12:22 +0100 |
commit | 4f9cf232f8d4d750d39aca83406b8a6d5e17a6c9 (patch) | |
tree | a8ee572196670730c593bc2781fad82ee7bce6d6 /src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | |
parent | 0d42217e4e8210dd2cf86f35ba9662ca02c8a2dc (diff) | |
download | wallabag-4f9cf232f8d4d750d39aca83406b8a6d5e17a6c9.tar.gz wallabag-4f9cf232f8d4d750d39aca83406b8a6d5e17a6c9.tar.zst wallabag-4f9cf232f8d4d750d39aca83406b8a6d5e17a6c9.zip |
Improve test failure readability
If the response content isn't the one expected, instead of checking into the whole DOM (with node tag, etc ..) we only check the text.
So if it fails, phpunit will display only the text, not all node tag. It'll be easier to read.
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 0fcf323c..46fbaf91 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | |||
@@ -25,10 +25,11 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
25 | $client = $this->getClient(); | 25 | $client = $this->getClient(); |
26 | 26 | ||
27 | $client->request('GET', '/unread/list'); | 27 | $client->request('GET', '/unread/list'); |
28 | $client->followRedirect(); | 28 | $crawler = $client->followRedirect(); |
29 | 29 | ||
30 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 30 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
31 | $this->assertContains('quickstart.intro.paragraph_1', $client->getResponse()->getContent()); | 31 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); |
32 | $this->assertContains('quickstart.intro.paragraph_1', $body[0]); | ||
32 | 33 | ||
33 | // Test if quickstart is disabled when user has 1 entry | 34 | // Test if quickstart is disabled when user has 1 entry |
34 | $crawler = $client->request('GET', '/new'); | 35 | $crawler = $client->request('GET', '/new'); |
@@ -45,8 +46,9 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
45 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 46 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
46 | $client->followRedirect(); | 47 | $client->followRedirect(); |
47 | 48 | ||
48 | $client->request('GET', '/unread/list'); | 49 | $crawler = $client->request('GET', '/unread/list'); |
49 | $this->assertContains('entry.list.number_on_the_page', $client->getResponse()->getContent()); | 50 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); |
51 | $this->assertContains('entry.list.number_on_the_page', $body[0]); | ||
50 | } | 52 | } |
51 | 53 | ||
52 | public function testGetNew() | 54 | public function testGetNew() |
@@ -240,10 +242,11 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
240 | ->getRepository('WallabagCoreBundle:Entry') | 242 | ->getRepository('WallabagCoreBundle:Entry') |
241 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | 243 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
242 | 244 | ||
243 | $client->request('GET', '/view/'.$content->getId()); | 245 | $crawler = $client->request('GET', '/view/'.$content->getId()); |
244 | 246 | ||
245 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 247 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
246 | $this->assertContains($content->getTitle(), $client->getResponse()->getContent()); | 248 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); |
249 | $this->assertContains($content->getTitle(), $body[0]); | ||
247 | } | 250 | } |
248 | 251 | ||
249 | /** | 252 | /** |