mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-23 09:31:04 +00:00
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.
This commit is contained in:
parent
0d42217e4e
commit
4f9cf232f8
3 changed files with 18 additions and 16 deletions
|
@ -210,7 +210,7 @@ class ConfigController extends Controller
|
||||||
public function deleteTaggingRuleAction(TaggingRule $rule)
|
public function deleteTaggingRuleAction(TaggingRule $rule)
|
||||||
{
|
{
|
||||||
if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) {
|
if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) {
|
||||||
throw $this->createAccessDeniedException('You can not access this tagging ryle.');
|
throw $this->createAccessDeniedException('You can not access this tagging rule.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
|
@ -418,11 +418,6 @@ class ConfigControllerTest extends WallabagCoreTestCase
|
||||||
|
|
||||||
$crawler = $client->request('GET', '/config');
|
$crawler = $client->request('GET', '/config');
|
||||||
|
|
||||||
if (500 == $client->getResponse()->getStatusCode()) {
|
|
||||||
var_export($client->getResponse()->getContent());
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
$form = $crawler->filter('button[id=rss_config_save]')->form();
|
$form = $crawler->filter('button[id=rss_config_save]')->form();
|
||||||
|
@ -556,12 +551,14 @@ class ConfigControllerTest extends WallabagCoreTestCase
|
||||||
|
|
||||||
$form = $crawler->filter('button[id=tagging_rule_save]')->form();
|
$form = $crawler->filter('button[id=tagging_rule_save]')->form();
|
||||||
|
|
||||||
$client->submit($form, $data);
|
$crawler = $client->submit($form, $data);
|
||||||
|
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
|
||||||
|
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as $message) {
|
||||||
$this->assertContains($message, $client->getResponse()->getContent());
|
$this->assertContains($message, $body[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,9 +571,11 @@ class ConfigControllerTest extends WallabagCoreTestCase
|
||||||
->getRepository('WallabagCoreBundle:TaggingRule')
|
->getRepository('WallabagCoreBundle:TaggingRule')
|
||||||
->findAll()[0];
|
->findAll()[0];
|
||||||
|
|
||||||
$client->request('GET', '/tagging-rule/delete/'.$rule->getId());
|
$crawler = $client->request('GET', '/tagging-rule/delete/'.$rule->getId());
|
||||||
|
|
||||||
$this->assertEquals(403, $client->getResponse()->getStatusCode());
|
$this->assertEquals(403, $client->getResponse()->getStatusCode());
|
||||||
$this->assertContains('You can not access this tagging ryle', $client->getResponse()->getContent());
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
|
||||||
|
$this->assertContains('You can not access this tagging rule', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDemoMode()
|
public function testDemoMode()
|
||||||
|
|
|
@ -25,10 +25,11 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||||
$client = $this->getClient();
|
$client = $this->getClient();
|
||||||
|
|
||||||
$client->request('GET', '/unread/list');
|
$client->request('GET', '/unread/list');
|
||||||
$client->followRedirect();
|
$crawler = $client->followRedirect();
|
||||||
|
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
$this->assertContains('quickstart.intro.paragraph_1', $client->getResponse()->getContent());
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
|
||||||
|
$this->assertContains('quickstart.intro.paragraph_1', $body[0]);
|
||||||
|
|
||||||
// Test if quickstart is disabled when user has 1 entry
|
// Test if quickstart is disabled when user has 1 entry
|
||||||
$crawler = $client->request('GET', '/new');
|
$crawler = $client->request('GET', '/new');
|
||||||
|
@ -45,8 +46,9 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||||
$client->followRedirect();
|
$client->followRedirect();
|
||||||
|
|
||||||
$client->request('GET', '/unread/list');
|
$crawler = $client->request('GET', '/unread/list');
|
||||||
$this->assertContains('entry.list.number_on_the_page', $client->getResponse()->getContent());
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
|
||||||
|
$this->assertContains('entry.list.number_on_the_page', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetNew()
|
public function testGetNew()
|
||||||
|
@ -240,10 +242,11 @@ class EntryControllerTest extends WallabagCoreTestCase
|
||||||
->getRepository('WallabagCoreBundle:Entry')
|
->getRepository('WallabagCoreBundle:Entry')
|
||||||
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
|
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
|
||||||
|
|
||||||
$client->request('GET', '/view/'.$content->getId());
|
$crawler = $client->request('GET', '/view/'.$content->getId());
|
||||||
|
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
$this->assertContains($content->getTitle(), $client->getResponse()->getContent());
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text')));
|
||||||
|
$this->assertContains($content->getTitle(), $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue