Fix unit tests

This commit is contained in:
Romain Neutron
2012-09-26 15:24:05 +02:00
parent e483da5513
commit 25104a70fa
7 changed files with 24 additions and 17 deletions

View File

@@ -46,7 +46,6 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
*/ */
protected static $adminApplication; protected static $adminApplication;
protected static $databoxe_ids = array(); protected static $databoxe_ids = array();
protected static $useExceptionHandler = true;
abstract public function getParameters(array $parameters = array()); abstract public function getParameters(array $parameters = array());

View File

@@ -6,7 +6,12 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
protected $client; protected $client;
public static $createdCollections = array(); public static $createdCollections = array();
protected static $useExceptionHandler = true;
public function setUp()
{
parent::setUp();
self::$DI['app.use-exception-handler'] = true;
}
public function tearDown() public function tearDown()
{ {

View File

@@ -9,7 +9,12 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public static $account = null; public static $account = null;
public static $api = null; public static $api = null;
protected $client; protected $client;
protected static $useExceptionHandler = true;
public function setUp()
{
parent::setUp();
self::$DI['app.use-exception-handler'] = true;
}
public function testList() public function testList()
{ {
@@ -31,12 +36,6 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
{ {
$appbox = self::$DI['app']['phraseanet.appbox']; $appbox = self::$DI['app']['phraseanet.appbox'];
// foreach ($appbox->get_databoxes() as $databox) {
// foreach ($databox->get_collections() as $collection) {
// $base_id = $collection->get_base_id();
// break;
// }
// }
$feeds = Feed_Collection::load_all(self::$DI['app'], self::$DI['user']); $feeds = Feed_Collection::load_all(self::$DI['app'], self::$DI['user']);
$count = sizeof($feeds->get_feeds()); $count = sizeof($feeds->get_feeds());

View File

@@ -5,7 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class MustacheLoaderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract class MustacheLoaderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
protected $client; protected $client;
protected static $useExceptionHandler = false;
public function testRouteSlash() public function testRouteSlash()
{ {

View File

@@ -14,11 +14,11 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
protected $client; protected $client;
protected $tmpFile; protected $tmpFile;
protected static $need_records = false; protected static $need_records = false;
protected static $useExceptionHandler = false;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
self::$DI['app.use-exception-handler'] = true;
$this->tmpFile = sys_get_temp_dir() . '/' . time() . mt_rand(1000, 9999) . '.jpg'; $this->tmpFile = sys_get_temp_dir() . '/' . time() . mt_rand(1000, 9999) . '.jpg';
copy(__DIR__ . '/../../../../testfiles/cestlafete.jpg', $this->tmpFile); copy(__DIR__ . '/../../../../testfiles/cestlafete.jpg', $this->tmpFile);
} }

View File

@@ -72,11 +72,11 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract
protected static $feed_4_public_title = 'Feed 4 title'; protected static $feed_4_public_title = 'Feed 4 title';
protected static $feed_4_public_subtitle = 'Feed 4 subtitle'; protected static $feed_4_public_subtitle = 'Feed 4 subtitle';
protected $client; protected $client;
protected static $useExceptionHandler = true;
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
self::$DI['app.use-exception-handler'] = true;
self::$feed = Feed_Adapter::create(self::$DI['app'], self::$DI['user'], 'title', 'subtitle'); self::$feed = Feed_Adapter::create(self::$DI['app'], self::$DI['user'], 'title', 'subtitle');
self::$publisher = Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], self::$feed, self::$DI['user']); self::$publisher = Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], self::$feed, self::$DI['user']);
self::$entry = Feed_Entry_Adapter::create(self::$DI['app'], self::$feed, self::$publisher, 'title_entry', 'subtitle', 'hello', "test@mail.com"); self::$entry = Feed_Entry_Adapter::create(self::$DI['app'], self::$feed, self::$publisher, 'title_entry', 'subtitle', 'hello', "test@mail.com");
@@ -109,7 +109,9 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract
copy(__DIR__ . '/../../../../db-ref.sqlite', '/tmp/db.sqlite'); copy(__DIR__ . '/../../../../db-ref.sqlite', '/tmp/db.sqlite');
$appbox = $application['phraseanet.appbox']; $appbox = $application['phraseanet.appbox'];
$this->authenticate($application);
$application['session']->clear();
$application['session']->set('usr_id', self::$DI['user']->get_id());
self::$feed_1_private = Feed_Adapter::create($application, self::$DI['user'], self::$feed_1_private_title, self::$feed_1_private_subtitle); self::$feed_1_private = Feed_Adapter::create($application, self::$DI['user'], self::$feed_1_private_title, self::$feed_1_private_subtitle);
self::$feed_1_private->set_public(false); self::$feed_1_private->set_public(false);
@@ -162,7 +164,7 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract
self::$public_feeds = Feed_Collection::load_public_feeds($application); self::$public_feeds = Feed_Collection::load_public_feeds($application);
self::$private_feeds = Feed_Collection::load_all($application, self::$DI['user']); self::$private_feeds = Feed_Collection::load_all($application, self::$DI['user']);
$application->closeAccount(); $application['session']->clear();
} }
public static function tearDownAfterClass() public static function tearDownAfterClass()

View File

@@ -27,7 +27,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
protected static $testsTime = array(); protected static $testsTime = array();
protected static $records; protected static $records;
public static $recordsInitialized = false; public static $recordsInitialized = false;
protected static $useExceptionHandler = false;
/** /**
* Tell if tables were updated with new schemas * Tell if tables were updated with new schemas
@@ -106,17 +105,21 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
parent::setUp(); parent::setUp();
self::$DI['app.use-exception-handler'] = false;
\PHPUnit_Framework_Error_Warning::$enabled = true; \PHPUnit_Framework_Error_Warning::$enabled = true;
\PHPUnit_Framework_Error_Notice::$enabled = true; \PHPUnit_Framework_Error_Notice::$enabled = true;
self::$DI['app'] = self::$DI->share(function() { self::$DI['app'] = self::$DI->share(function($DI) {
$environment = 'test'; $environment = 'test';
$app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Root.php'; $app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Root.php';
$app['debug'] = true; $app['debug'] = true;
unset($app['exception_handler']); if (!$DI['app.use-exception-handler']) {
unset($app['exception_handler']);
}
$app['EM'] = $app->share($app->extend('EM', function($em) { $app['EM'] = $app->share($app->extend('EM', function($em) {
@unlink('/tmp/db.sqlite'); @unlink('/tmp/db.sqlite');