Fix unit tests

This commit is contained in:
Romain Neutron
2013-01-24 17:04:50 +01:00
parent 6dcdd4e892
commit 62a27940b9
29 changed files with 163 additions and 153 deletions

View File

@@ -100,8 +100,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
parent::setUp();
self::$DI['app.use-exception-handler'] = false;
\PHPUnit_Framework_Error_Warning::$enabled = true;
\PHPUnit_Framework_Error_Notice::$enabled = true;
@@ -112,10 +110,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$app['debug'] = true;
if (!$DI['app.use-exception-handler']) {
unset($app['exception_handler']);
}
$app['EM'] = $app->share($app->extend('EM', function($em) {
@unlink('/tmp/db.sqlite');
copy(__DIR__ . '/../db-ref.sqlite', '/tmp/db.sqlite');
@@ -169,6 +163,25 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
set_time_limit(0);
}
protected function assertForbiddenResponse(Response $response)
{
$this->assertEquals(403, $response->getStatusCode());
$this->assertTrue(false !== stripos($response->getContent(), 'forbidden'));
}
protected function assertBadResponse(Response $response)
{
$this->assertEquals(400, $response->getStatusCode());
$this->assertTrue(false !== stripos($response->getContent(), 'bad request'));
}
protected function assertNotFoundResponse(Response $response)
{
$this->assertEquals(404, $response->getStatusCode());
$this->assertTrue(false !== stripos($response->getContent(), 'not found'));
}
/**
* Insert fixture contained in the specified fixtureLoader
* into sqlLite test temporary database