aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-03-11 09:42:08 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-03-20 21:12:22 +0100
commit4f9cf232f8d4d750d39aca83406b8a6d5e17a6c9 (patch)
treea8ee572196670730c593bc2781fad82ee7bce6d6 /src
parent0d42217e4e8210dd2cf86f35ba9662ca02c8a2dc (diff)
downloadwallabag-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')
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php2
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php17
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php15
3 files changed, 18 insertions, 16 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index 1930a2ae..d24066b3 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -210,7 +210,7 @@ class ConfigController extends Controller
210 public function deleteTaggingRuleAction(TaggingRule $rule) 210 public function deleteTaggingRuleAction(TaggingRule $rule)
211 { 211 {
212 if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) { 212 if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) {
213 throw $this->createAccessDeniedException('You can not access this tagging ryle.'); 213 throw $this->createAccessDeniedException('You can not access this tagging rule.');
214 } 214 }
215 215
216 $em = $this->getDoctrine()->getManager(); 216 $em = $this->getDoctrine()->getManager();
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
index bf455f32..884e740e 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
@@ -418,11 +418,6 @@ class ConfigControllerTest extends WallabagCoreTestCase
418 418
419 $crawler = $client->request('GET', '/config'); 419 $crawler = $client->request('GET', '/config');
420 420
421 if (500 == $client->getResponse()->getStatusCode()) {
422 var_export($client->getResponse()->getContent());
423 die();
424 }
425
426 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 421 $this->assertEquals(200, $client->getResponse()->getStatusCode());
427 422
428 $form = $crawler->filter('button[id=rss_config_save]')->form(); 423 $form = $crawler->filter('button[id=rss_config_save]')->form();
@@ -556,12 +551,14 @@ class ConfigControllerTest extends WallabagCoreTestCase
556 551
557 $form = $crawler->filter('button[id=tagging_rule_save]')->form(); 552 $form = $crawler->filter('button[id=tagging_rule_save]')->form();
558 553
559 $client->submit($form, $data); 554 $crawler = $client->submit($form, $data);
560 555
561 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 556 $this->assertEquals(200, $client->getResponse()->getStatusCode());
562 557
558 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
559
563 foreach ($messages as $message) { 560 foreach ($messages as $message) {
564 $this->assertContains($message, $client->getResponse()->getContent()); 561 $this->assertContains($message, $body[0]);
565 } 562 }
566 } 563 }
567 564
@@ -574,9 +571,11 @@ class ConfigControllerTest extends WallabagCoreTestCase
574 ->getRepository('WallabagCoreBundle:TaggingRule') 571 ->getRepository('WallabagCoreBundle:TaggingRule')
575 ->findAll()[0]; 572 ->findAll()[0];
576 573
577 $client->request('GET', '/tagging-rule/delete/'.$rule->getId()); 574 $crawler = $client->request('GET', '/tagging-rule/delete/'.$rule->getId());
575
578 $this->assertEquals(403, $client->getResponse()->getStatusCode()); 576 $this->assertEquals(403, $client->getResponse()->getStatusCode());
579 $this->assertContains('You can not access this tagging ryle', $client->getResponse()->getContent()); 577 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
578 $this->assertContains('You can not access this tagging rule', $body[0]);
580 } 579 }
581 580
582 public function testDemoMode() 581 public function testDemoMode()
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 /**