Refactor Appbox

This commit is contained in:
Romain Neutron
2012-02-21 16:19:38 +01:00
parent 7d41a36694
commit dc51dd295d
20 changed files with 57 additions and 57 deletions

View File

@@ -29,7 +29,7 @@ class Feed_Entry_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$auth = new Session_Authentication_None(self::$user);
$appbox->get_session()->authenticate($auth);
@@ -148,7 +148,7 @@ class Feed_Entry_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testLoad_from_id()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$test_entry = Feed_Entry_Adapter::load_from_id($appbox, self::$object->get_id());
$this->assertInstanceOf('Feed_Entry_Adapter', $test_entry);

View File

@@ -39,7 +39,7 @@ class Feed_Entry_CollectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$auth = new Session_Authentication_None(self::$user);
$appbox->get_session()->authenticate($auth);

View File

@@ -35,7 +35,7 @@ class Feed_Entry_ItemTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$auth = new Session_Authentication_None(self::$user);
$appbox->get_session()->authenticate($auth);

View File

@@ -20,7 +20,7 @@ class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$auth = new Session_Authentication_None(self::$user);
$appbox->get_session()->authenticate($auth);
self::$object = Feed_Adapter::create($appbox, self::$user, self::$title, self::$subtitle);
@@ -77,7 +77,7 @@ class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertTrue(self::$object->is_public());
$coll = null;
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
foreach ($appbox->get_databoxes() as $databox)
{
foreach ($databox->get_collections() as $collection)
@@ -125,7 +125,7 @@ class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
$coll = null;
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
foreach ($appbox->get_databoxes() as $databox)
{
foreach ($databox->get_collections() as $collection)
@@ -208,7 +208,7 @@ class Feed_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testLoad_with_user()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$this->assertEquals(Feed_Adapter::load_with_user($appbox, self::$user, self::$object->get_id())->get_id(), self::$object->get_id());
}

View File

@@ -20,7 +20,7 @@ class Feed_AggregateTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$auth = new Session_Authentication_None(self::$user);
$appbox->get_session()->authenticate($auth);
$objects[] = Feed_Adapter::create($appbox, self::$user, self::$title, self::$subtitle);

View File

@@ -20,7 +20,7 @@ class Feed_CollectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$auth = new Session_Authentication_None(self::$user);
$appbox->get_session()->authenticate($auth);
self::$object = Feed_Adapter::create($appbox, self::$user, self::$title, self::$subtitle);
@@ -34,7 +34,7 @@ class Feed_CollectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testLoad_all()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$coll = Feed_Collection::load_all($appbox, self::$user);
foreach ($coll->get_feeds() as $feed)
@@ -45,7 +45,7 @@ class Feed_CollectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_feeds()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$coll = Feed_Collection::load_public_feeds($appbox);
foreach ($coll->get_feeds() as $feed)
@@ -56,7 +56,7 @@ class Feed_CollectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_aggregate()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$coll = Feed_Collection::load_public_feeds($appbox);
$this->assertInstanceOf('Feed_Aggregate', $coll->get_aggregate());
@@ -64,7 +64,7 @@ class Feed_CollectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testLoad_public_feeds()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$coll = Feed_Collection::load_public_feeds($appbox);
foreach ($coll->get_feeds() as $feed)

View File

@@ -23,7 +23,7 @@ class Feed_Publisher_AdapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$auth = new Session_Authentication_None(self::$user);
$appbox->get_session()->authenticate($auth);
self::$feed = Feed_Adapter::create($appbox, self::$user, self::$title, self::$subtitle);

View File

@@ -20,7 +20,7 @@ class Session_Authentication_GuestTest extends PhraseanetPHPUnitAbstract
*/
public function setUp()
{
$this->object = new Session_Authentication_Guest(appbox::get_instance());
$this->object = new Session_Authentication_Guest(appbox::get_instance(\bootstrap::getCore()));
}
/**

View File

@@ -26,13 +26,13 @@ class Session_Authentication_NativeTest extends PhraseanetPHPUnitAbstract
$usr_id = User_Adapter::get_usr_id_from_login($login);
if ($usr_id)
{
$this->local_user = User_Adapter::getInstance($usr_id, appbox::get_instance());
$this->local_user = User_Adapter::getInstance($usr_id, appbox::get_instance(\bootstrap::getCore()));
}
else
{
$this->local_user = User_Adapter::create(appbox::get_instance(), $login, $password, null, false);
$this->local_user = User_Adapter::create(appbox::get_instance(\bootstrap::getCore()), $login, $password, null, false);
}
$this->object = new Session_Authentication_Native(appbox::get_instance(), $login, $password);
$this->object = new Session_Authentication_Native(appbox::get_instance(\bootstrap::getCore()), $login, $password);
}
public function tearDown()

View File

@@ -20,7 +20,7 @@ class Session_HandlerTest extends PhraseanetPHPUnitAbstract
*/
public function setUp()
{
$this->object = Session_Handler::getInstance(appbox::get_instance());
$this->object = Session_Handler::getInstance(appbox::get_instance(\bootstrap::getCore()));
}
/**

View File

@@ -44,7 +44,7 @@ class Session_LoggerTest extends PhraseanetPHPUnitAbstract
protected function feed_datas()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$this->session = $appbox->get_session();
$user = self::$user;
$auth = new Session_Authentication_None($user);

View File

@@ -16,7 +16,7 @@ class Setup_UpgradeTest extends PhraseanetPHPUnitAbstract
public function setUp()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$this->object = new Setup_Upgrade($appbox);
}

View File

@@ -15,7 +15,7 @@ class API_OAuth2_AuthCodeTest extends PhraseanetPHPUnitAbstract
public function setUp()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
$this->account = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
@@ -73,8 +73,8 @@ class API_OAuth2_AuthCodeTest extends PhraseanetPHPUnitAbstract
public function testLoad_codes_by_account()
{
$this->assertTrue(is_array(API_OAuth2_AuthCode::load_codes_by_account(appbox::get_instance(), $this->account)));
$this->assertTrue(count(API_OAuth2_AuthCode::load_codes_by_account(appbox::get_instance(), $this->account)) > 0);
$this->assertTrue(is_array(API_OAuth2_AuthCode::load_codes_by_account(appbox::get_instance(\bootstrap::getCore()), $this->account)));
$this->assertTrue(count(API_OAuth2_AuthCode::load_codes_by_account(appbox::get_instance(\bootstrap::getCore()), $this->account)) > 0);
}
}

View File

@@ -16,7 +16,7 @@ class API_OAuth2_RefreshTokenTest extends PhraseanetPHPUnitAbstract
public function setUp()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
$this->account = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);

View File

@@ -17,7 +17,7 @@ class API_OAuth2_AccountTest extends PhraseanetPHPUnitAbstract
public function setUp()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
$this->object = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
}
@@ -75,7 +75,7 @@ class API_OAuth2_AccountTest extends PhraseanetPHPUnitAbstract
public function testLoad_with_user()
{
$loaded = API_OAuth2_Account::load_with_user(appbox::get_instance(), $this->application, self::$user);
$loaded = API_OAuth2_Account::load_with_user(appbox::get_instance(\bootstrap::getCore()), $this->application, self::$user);
$this->assertInstanceOf('API_OAuth2_Account', $loaded);
$this->assertEquals($this->object, $loaded);
}

View File

@@ -12,7 +12,7 @@ class API_OAuth2_ApplicationTest extends PhraseanetPHPUnitAbstract
public function setUp()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$this->object = API_OAuth2_Application::create($appbox, self::$user, 'test app');
}
@@ -24,14 +24,14 @@ class API_OAuth2_ApplicationTest extends PhraseanetPHPUnitAbstract
public function testLoad_from_client_id()
{
$client_id = $this->object->get_client_id();
$loaded = API_OAuth2_Application::load_from_client_id(appbox::get_instance(), $client_id);
$loaded = API_OAuth2_Application::load_from_client_id(appbox::get_instance(\bootstrap::getCore()), $client_id);
$this->assertInstanceOf('API_OAuth2_Application', $loaded);
$this->assertEquals($this->object, $loaded);
}
public function testLoad_dev_app_by_user()
{
$apps = API_OAuth2_Application::load_dev_app_by_user(appbox::get_instance(), self::$user);
$apps = API_OAuth2_Application::load_dev_app_by_user(appbox::get_instance(\bootstrap::getCore()), self::$user);
$this->assertTrue(is_array($apps));
$this->assertTrue(count($apps) > 0);
$found = false;
@@ -48,7 +48,7 @@ class API_OAuth2_ApplicationTest extends PhraseanetPHPUnitAbstract
public function testLoad_app_by_user()
{
$apps = API_OAuth2_Application::load_app_by_user(appbox::get_instance(), self::$user);
$apps = API_OAuth2_Application::load_app_by_user(appbox::get_instance(\bootstrap::getCore()), self::$user);
$this->assertTrue(is_array($apps));
$this->assertTrue(count($apps) > 0);
$found = false;

View File

@@ -17,7 +17,7 @@ class API_OAuth2_TokenTest extends PhraseanetPHPUnitAbstract
public function setUp()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
$account = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
@@ -110,7 +110,7 @@ class API_OAuth2_TokenTest extends PhraseanetPHPUnitAbstract
public function testLoad_by_oauth_token()
{
$token = $this->object->get_value();
$loaded = API_OAuth2_Token::load_by_oauth_token(appbox::get_instance(), $token);
$loaded = API_OAuth2_Token::load_by_oauth_token(appbox::get_instance(\bootstrap::getCore()), $token);
$this->assertInstanceOf('API_OAuth2_Token', $loaded);
$this->assertEquals($this->object, $loaded);
}

View File

@@ -21,7 +21,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function setUp()
{
parent::setUp();
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$this->object = new API_V1_adapter(FALSE, $appbox, self::$core);
}
@@ -109,7 +109,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_databox_collections()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$request = new Request();
foreach ($appbox->get_databoxes() as $databox)
{
@@ -122,7 +122,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_record()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
$result = $this->object->get_record($request, self::$record_1->get_sbas_id(), "-40");
@@ -137,7 +137,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_databox_status()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
foreach ($appbox->get_databoxes() as $databox)
{
@@ -150,7 +150,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_databox_metadatas()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
foreach ($appbox->get_databoxes() as $databox)
{
@@ -163,7 +163,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_databox_terms()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
foreach ($appbox->get_databoxes() as $databox)
{
@@ -185,7 +185,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_record_related()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
$result = $this->object->get_record_related($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
@@ -196,7 +196,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_record_metadatas()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
$result = $this->object->get_record_metadatas($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
@@ -207,7 +207,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_record_status()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$request = new Request();
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
@@ -219,7 +219,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_record_embed()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
$result = $this->object->get_record_embed($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
@@ -230,7 +230,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testSet_record_metadatas()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$databox = self::$record_1->get_databox();
$request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
$result = $this->object->set_record_metadatas($request, self::$record_1->get_sbas_id(), self::$record_1->get_record_id());
@@ -284,9 +284,9 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
*/
public function testSet_record_status()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$stub = $this->getMock("API_V1_adapter", array("list_record_status"), array(false, &$appbox, bootstrap::getCore()));
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$databox = self::$record_1->get_databox();
$statusbit = null;
@@ -321,7 +321,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
*/
public function testSet_record_collection()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$stub = $this->getMock("API_V1_adapter", array("list_record"), array(false, &$appbox, bootstrap::getCore()));
$databox = self::$record_1->get_databox();
@@ -382,7 +382,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
}
$this->assertEquals(1, $n);
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$usr_id = $session->get_usr_id();
@@ -399,7 +399,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testDelete_basket()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$usr_id = $appbox->get_session()->get_usr_id();
$user = User_Adapter::getInstance($usr_id, $appbox);
@@ -435,7 +435,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_basket()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$usr_id = $appbox->get_session()->get_usr_id();
$basket = $this->insertOneBasket();
@@ -449,7 +449,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testSet_basket_title()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$usr_id = $appbox->get_session()->get_usr_id();
$basket = $this->insertOneBasket();
@@ -469,7 +469,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testSet_basket_description()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$usr_id = $appbox->get_session()->get_usr_id();
$basket = $this->insertOneBasket();
@@ -489,7 +489,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testSearch_publications()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$stub = $this->getMock("API_V1_adapter", array("list_publication"), array(false, &$appbox, bootstrap::getCore()));
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
$feed = Feed_Adapter::create($appbox, self::$user, "hello", "salut");
@@ -508,7 +508,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_publication()
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance(\bootstrap::getCore());
$date = new DateTime();
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));

View File

@@ -21,7 +21,7 @@ class module_console_schedulerStateTest extends PHPUnit_Framework_TestCase
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName()));
$task_manager = new task_manager(appbox::get_instance());
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
$state = $task_manager->get_scheduler_state();
$sentence = sprintf('Scheduler is %s', $state['schedstatus']);

View File

@@ -25,7 +25,7 @@ class module_console_tasklistTest extends PHPUnit_Framework_TestCase
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName()));
$task_manager = new task_manager(appbox::get_instance());
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
$lines = explode("\n", trim($commandTester->getDisplay()));
if(count($task_manager->get_tasks()) > 0)