mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 21:13:26 +00:00
Update unit tests
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
|
|
||||||
require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
|
require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
|
||||||
|
|
||||||
class Setup_UpgradeTest extends PhraseanetPHPUnitAbstract
|
class Setup_UpgradeTest extends PhraseanetPHPUnitAbstract
|
||||||
@@ -12,8 +14,8 @@ class Setup_UpgradeTest extends PhraseanetPHPUnitAbstract
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$this->object = new Setup_Upgrade($appbox);
|
$this->object = new Setup_Upgrade(self::$application);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
|
require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
|
||||||
|
|
||||||
class API_OAuth2_AuthCodeTest extends PhraseanetPHPUnitAbstract
|
class API_OAuth2_AuthCodeTest extends PhraseanetPHPUnitAbstract
|
||||||
@@ -9,20 +11,20 @@ class API_OAuth2_AuthCodeTest extends PhraseanetPHPUnitAbstract
|
|||||||
*/
|
*/
|
||||||
protected $object;
|
protected $object;
|
||||||
protected $code;
|
protected $code;
|
||||||
protected $application;
|
|
||||||
protected $account;
|
protected $account;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
|
$this->application = API_OAuth2_Application::create(self::$application, self::$user, 'test app');
|
||||||
$this->account = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
|
$this->account = API_OAuth2_Account::load_with_user(self::$application, $this->application, self::$user);
|
||||||
|
|
||||||
$expires = time() + 100;
|
$expires = time() + 100;
|
||||||
$this->code = random::generatePassword(8);
|
$this->code = random::generatePassword(8);
|
||||||
|
|
||||||
$this->object = API_OAuth2_AuthCode::create($appbox, $this->account, $this->code, $expires);
|
$this->object = API_OAuth2_AuthCode::create(self::$application, $this->account, $this->code, $expires);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
@@ -74,7 +76,7 @@ class API_OAuth2_AuthCodeTest extends PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
public function testLoad_codes_by_account()
|
public function testLoad_codes_by_account()
|
||||||
{
|
{
|
||||||
$this->assertTrue(is_array(API_OAuth2_AuthCode::load_codes_by_account(appbox::get_instance(\bootstrap::getCore()), $this->account)));
|
$this->assertTrue(is_array(API_OAuth2_AuthCode::load_codes_by_account(self::$application, $this->account)));
|
||||||
$this->assertTrue(count(API_OAuth2_AuthCode::load_codes_by_account(appbox::get_instance(\bootstrap::getCore()), $this->account)) > 0);
|
$this->assertTrue(count(API_OAuth2_AuthCode::load_codes_by_account(self::$application, $this->account)) > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
|
require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
|
||||||
|
|
||||||
class API_OAuth2_RefreshTokenTest extends PhraseanetPHPUnitAbstract
|
class API_OAuth2_RefreshTokenTest extends PhraseanetPHPUnitAbstract
|
||||||
@@ -10,21 +12,21 @@ class API_OAuth2_RefreshTokenTest extends PhraseanetPHPUnitAbstract
|
|||||||
protected $object;
|
protected $object;
|
||||||
protected $token;
|
protected $token;
|
||||||
protected $scope;
|
protected $scope;
|
||||||
protected $application;
|
|
||||||
protected $account;
|
protected $account;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
|
$this->application = API_OAuth2_Application::create(self::$application, self::$user, 'test app');
|
||||||
$this->account = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
|
$this->account = API_OAuth2_Account::load_with_user(self::$application, $this->application, self::$user);
|
||||||
|
|
||||||
$expires = time() + 100;
|
$expires = time() + 100;
|
||||||
$this->token = random::generatePassword(8);
|
$this->token = random::generatePassword(8);
|
||||||
$this->scope = 'scopidou';
|
$this->scope = 'scopidou';
|
||||||
|
|
||||||
$this->object = API_OAuth2_RefreshToken::create($appbox, $this->account, $expires, $this->token, $this->scope);
|
$this->object = API_OAuth2_RefreshToken::create(self::$application, $this->account, $expires, $this->token, $this->scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
|
@@ -1,13 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
|
require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
|
||||||
|
|
||||||
class API_OAuth2_AccountTest extends PhraseanetPHPUnitAbstract
|
class API_OAuth2_AccountTest extends PhraseanetPHPUnitAbstract
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var API_OAuth2_Application
|
|
||||||
*/
|
|
||||||
protected $application;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var API_OAuth2_Account
|
* @var API_OAuth2_Account
|
||||||
@@ -17,9 +15,9 @@ class API_OAuth2_AccountTest extends PhraseanetPHPUnitAbstract
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
|
$this->application = API_OAuth2_Application::create(self::$application, self::$user, 'test app');
|
||||||
$this->object = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
|
$this->object = API_OAuth2_Account::load_with_user(self::$application, $this->application, self::$user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
@@ -76,7 +74,7 @@ class API_OAuth2_AccountTest extends PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
public function testLoad_with_user()
|
public function testLoad_with_user()
|
||||||
{
|
{
|
||||||
$loaded = API_OAuth2_Account::load_with_user(appbox::get_instance(\bootstrap::getCore()), $this->application, self::$user);
|
$loaded = API_OAuth2_Account::load_with_user(self::$application, $this->application, self::$user);
|
||||||
$this->assertInstanceOf('API_OAuth2_Account', $loaded);
|
$this->assertInstanceOf('API_OAuth2_Account', $loaded);
|
||||||
$this->assertEquals($this->object, $loaded);
|
$this->assertEquals($this->object, $loaded);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
|
require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
|
||||||
|
|
||||||
class API_OAuth2_ApplicationTest extends PhraseanetPHPUnitAbstract
|
class API_OAuth2_ApplicationTest extends PhraseanetPHPUnitAbstract
|
||||||
@@ -12,8 +14,8 @@ class API_OAuth2_ApplicationTest extends PhraseanetPHPUnitAbstract
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$this->object = API_OAuth2_Application::create($appbox, self::$user, 'test app');
|
$this->object = API_OAuth2_Application::create(self::$application, self::$user, 'test app');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
@@ -25,14 +27,14 @@ class API_OAuth2_ApplicationTest extends PhraseanetPHPUnitAbstract
|
|||||||
public function testLoad_from_client_id()
|
public function testLoad_from_client_id()
|
||||||
{
|
{
|
||||||
$client_id = $this->object->get_client_id();
|
$client_id = $this->object->get_client_id();
|
||||||
$loaded = API_OAuth2_Application::load_from_client_id(appbox::get_instance(\bootstrap::getCore()), $client_id);
|
$loaded = API_OAuth2_Application::load_from_client_id(self::$application, $client_id);
|
||||||
$this->assertInstanceOf('API_OAuth2_Application', $loaded);
|
$this->assertInstanceOf('API_OAuth2_Application', $loaded);
|
||||||
$this->assertEquals($this->object, $loaded);
|
$this->assertEquals($this->object, $loaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoad_dev_app_by_user()
|
public function testLoad_dev_app_by_user()
|
||||||
{
|
{
|
||||||
$apps = API_OAuth2_Application::load_dev_app_by_user(appbox::get_instance(\bootstrap::getCore()), self::$user);
|
$apps = API_OAuth2_Application::load_dev_app_by_user(self::$application, self::$user);
|
||||||
$this->assertTrue(is_array($apps));
|
$this->assertTrue(is_array($apps));
|
||||||
$this->assertTrue(count($apps) > 0);
|
$this->assertTrue(count($apps) > 0);
|
||||||
$found = false;
|
$found = false;
|
||||||
@@ -48,7 +50,7 @@ class API_OAuth2_ApplicationTest extends PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
public function testLoad_app_by_user()
|
public function testLoad_app_by_user()
|
||||||
{
|
{
|
||||||
$apps = API_OAuth2_Application::load_app_by_user(appbox::get_instance(\bootstrap::getCore()), self::$user);
|
$apps = API_OAuth2_Application::load_app_by_user(self::$application, self::$user);
|
||||||
$this->assertTrue(is_array($apps));
|
$this->assertTrue(is_array($apps));
|
||||||
$this->assertTrue(count($apps) > 0);
|
$this->assertTrue(count($apps) > 0);
|
||||||
$found = false;
|
$found = false;
|
||||||
|
@@ -1,13 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
|
require_once __DIR__ . '/../../PhraseanetPHPUnitAbstract.class.inc';
|
||||||
|
|
||||||
class API_OAuth2_TokenTest extends PhraseanetPHPUnitAbstract
|
class API_OAuth2_TokenTest extends PhraseanetPHPUnitAbstract
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var API_OAuth2_Application
|
|
||||||
*/
|
|
||||||
protected $application;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var API_OAuth2_Token
|
* @var API_OAuth2_Token
|
||||||
@@ -17,9 +15,9 @@ class API_OAuth2_TokenTest extends PhraseanetPHPUnitAbstract
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$this->application = API_OAuth2_Application::create($appbox, self::$user, 'test app');
|
$this->application = API_OAuth2_Application::create(self::$application, self::$user, 'test app');
|
||||||
$account = API_OAuth2_Account::load_with_user($appbox, $this->application, self::$user);
|
$account = API_OAuth2_Account::load_with_user(self::$application, $this->application, self::$user);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new API_OAuth2_Token($appbox, $account);
|
new API_OAuth2_Token($appbox, $account);
|
||||||
@@ -111,7 +109,7 @@ class API_OAuth2_TokenTest extends PhraseanetPHPUnitAbstract
|
|||||||
public function testLoad_by_oauth_token()
|
public function testLoad_by_oauth_token()
|
||||||
{
|
{
|
||||||
$token = $this->object->get_value();
|
$token = $this->object->get_value();
|
||||||
$loaded = API_OAuth2_Token::load_by_oauth_token(appbox::get_instance(\bootstrap::getCore()), $token);
|
$loaded = API_OAuth2_Token::load_by_oauth_token(self::$application, $token);
|
||||||
$this->assertInstanceOf('API_OAuth2_Token', $loaded);
|
$this->assertInstanceOf('API_OAuth2_Token', $loaded);
|
||||||
$this->assertEquals($this->object, $loaded);
|
$this->assertEquals($this->object, $loaded);
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
|
require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||||
@@ -14,8 +16,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$this->object = new API_V1_adapter(new Application('test'));
|
||||||
$this->object = new API_V1_adapter($appbox, self::$core);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGet_error_code()
|
public function testGet_error_code()
|
||||||
@@ -102,7 +103,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testGet_databox_collections()
|
public function testGet_databox_collections()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
foreach ($appbox->get_databoxes() as $databox) {
|
foreach ($appbox->get_databoxes() as $databox) {
|
||||||
$result = $this->object->get_databox_collections($request, $databox->get_sbas_id());
|
$result = $this->object->get_databox_collections($request, $databox->get_sbas_id());
|
||||||
@@ -114,7 +115,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testGet_record()
|
public function testGet_record()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
|
|
||||||
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||||
$result = $this->object->get_record($request, static::$records['record_1']->get_sbas_id(), "-40");
|
$result = $this->object->get_record($request, static::$records['record_1']->get_sbas_id(), "-40");
|
||||||
@@ -129,7 +130,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testGet_databox_status()
|
public function testGet_databox_status()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||||
foreach ($appbox->get_databoxes() as $databox) {
|
foreach ($appbox->get_databoxes() as $databox) {
|
||||||
$result = $this->object->get_databox_status($request, $databox->get_sbas_id());
|
$result = $this->object->get_databox_status($request, $databox->get_sbas_id());
|
||||||
@@ -141,7 +142,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testGet_databox_metadatas()
|
public function testGet_databox_metadatas()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||||
foreach ($appbox->get_databoxes() as $databox) {
|
foreach ($appbox->get_databoxes() as $databox) {
|
||||||
$result = $this->object->get_databox_metadatas($request, $databox->get_sbas_id());
|
$result = $this->object->get_databox_metadatas($request, $databox->get_sbas_id());
|
||||||
@@ -153,7 +154,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testGet_databox_terms()
|
public function testGet_databox_terms()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||||
foreach ($appbox->get_databoxes() as $databox) {
|
foreach ($appbox->get_databoxes() as $databox) {
|
||||||
$result = $this->object->get_databox_terms($request, $databox->get_sbas_id());
|
$result = $this->object->get_databox_terms($request, $databox->get_sbas_id());
|
||||||
@@ -174,7 +175,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testGet_record_related()
|
public function testGet_record_related()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
|
|
||||||
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||||
$result = $this->object->get_record_related($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
|
$result = $this->object->get_record_related($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
|
||||||
@@ -185,7 +186,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testGet_record_metadatas()
|
public function testGet_record_metadatas()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
|
|
||||||
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||||
$result = $this->object->get_record_metadatas($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
|
$result = $this->object->get_record_metadatas($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
|
||||||
@@ -196,7 +197,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testGet_record_status()
|
public function testGet_record_status()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
|
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||||
@@ -208,7 +209,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testGet_record_embed()
|
public function testGet_record_embed()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
|
|
||||||
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||||
$result = $this->object->get_record_embed($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
|
$result = $this->object->get_record_embed($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
|
||||||
@@ -219,7 +220,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testSet_record_metadatas()
|
public function testSet_record_metadatas()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$databox = static::$records['record_1']->get_databox();
|
$databox = static::$records['record_1']->get_databox();
|
||||||
$request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$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, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
|
$result = $this->object->set_record_metadatas($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
|
||||||
@@ -230,7 +231,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
$this->assertEquals(400, $result->get_http_code());
|
$this->assertEquals(400, $result->get_http_code());
|
||||||
|
|
||||||
if (sizeof(static::$records['record_1']->get_caption()->get_fields()) == 0) {
|
if (sizeof(static::$records['record_1']->get_caption()->get_fields()) == 0) {
|
||||||
$caption_field_value = caption_Field_Value::create(databox_field::get_instance($databox, 1), static::$records['record_1'], 'my value');
|
$caption_field_value = caption_Field_Value::create(self::$application, databox_field::get_instance(self::$application, $databox, 1), static::$records['record_1'], 'my value');
|
||||||
}
|
}
|
||||||
|
|
||||||
//valide metas
|
//valide metas
|
||||||
@@ -265,9 +266,8 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testSet_record_status()
|
public function testSet_record_status()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$app = new Application('test');
|
||||||
$stub = $this->getMock("API_V1_adapter", array("list_record_status"), array(&$appbox, bootstrap::getCore()));
|
$stub = $this->getMock("API_V1_adapter", array("list_record_status"), array($app));
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
|
||||||
$databox = static::$records['record_1']->get_databox();
|
$databox = static::$records['record_1']->get_databox();
|
||||||
|
|
||||||
$statusbit = null;
|
$statusbit = null;
|
||||||
@@ -302,15 +302,15 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testSet_record_collection()
|
public function testSet_record_collection()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$app = new Application('test');
|
||||||
$stub = $this->getMock("API_V1_adapter", array("list_record"), array(&$appbox, bootstrap::getCore()));
|
$stub = $this->getMock("API_V1_adapter", array("list_record"), array($app));
|
||||||
$databox = static::$records['record_1']->get_databox();
|
$databox = static::$records['record_1']->get_databox();
|
||||||
|
|
||||||
$request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||||
$result = $stub->set_record_collection($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
|
$result = $stub->set_record_collection($request, static::$records['record_1']->get_sbas_id(), static::$records['record_1']->get_record_id());
|
||||||
$this->assertEquals(400, $result->get_http_code());
|
$this->assertEquals(400, $result->get_http_code());
|
||||||
|
|
||||||
foreach ($appbox->get_databoxes() as $databox) {
|
foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) {
|
||||||
$collections = $databox->get_collections();
|
$collections = $databox->get_collections();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -358,15 +358,12 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
$n = 0;
|
$n = 0;
|
||||||
$response = json_decode($result->format(), true);
|
$response = json_decode($result->format(), true);
|
||||||
$this->assertArrayHasKey('basket', $response['response']);
|
$this->assertArrayHasKey('basket', $response['response']);
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
|
||||||
$session = $appbox->get_session();
|
|
||||||
$usr_id = $session->get_usr_id();
|
|
||||||
|
|
||||||
$em = self::$core->getEntityManager();
|
$em = self::$application['EM'];
|
||||||
$repo = $em->getRepository('\Entities\Basket');
|
$repo = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
/* @var $repo \Repositories\BasketRepository */
|
/* @var $repo \Repositories\BasketRepository */
|
||||||
$basket = $repo->findUserBasket($response['response']['basket']['basket_id'], self::$core->getAuthenticatedUser(), true);
|
$basket = $repo->findUserBasket(self::$application, $response['response']['basket']['basket_id'], self::$application['phraseanet.user'], true);
|
||||||
|
|
||||||
$this->assertTrue($basket instanceof \Entities\Basket);
|
$this->assertTrue($basket instanceof \Entities\Basket);
|
||||||
$em->remove($basket);
|
$em->remove($basket);
|
||||||
@@ -375,11 +372,11 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testDelete_basket()
|
public function testDelete_basket()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$usr_id = $appbox->get_session()->get_usr_id();
|
$usr_id = self::$application['phraseanet.user']->get_id();
|
||||||
$user = User_Adapter::getInstance($usr_id, $appbox);
|
$user = User_Adapter::getInstance($usr_id, self::$application);
|
||||||
|
|
||||||
$em = self::$core->getEntityManager();
|
$em = self::$application['EM'];
|
||||||
|
|
||||||
$Basket = new Entities\Basket();
|
$Basket = new Entities\Basket();
|
||||||
$Basket->setName('Delete test');
|
$Basket->setName('Delete test');
|
||||||
@@ -399,7 +396,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
$repo = $em->getRepository('\Entities\Basket');
|
$repo = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$repo->findUserBasket($ssel_id, $user, true);
|
$repo->findUserBasket(self::$application, $ssel_id, $user, true);
|
||||||
$this->fail('An exception should have been raised');
|
$this->fail('An exception should have been raised');
|
||||||
} catch (Exception_NotFound $e) {
|
} catch (Exception_NotFound $e) {
|
||||||
|
|
||||||
@@ -408,8 +405,8 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testGet_basket()
|
public function testGet_basket()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$usr_id = $appbox->get_session()->get_usr_id();
|
$usr_id = self::$application['phraseanet.user']->get_id();
|
||||||
|
|
||||||
$basket = $this->insertOneBasket();
|
$basket = $this->insertOneBasket();
|
||||||
|
|
||||||
@@ -422,8 +419,8 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testSet_basket_title()
|
public function testSet_basket_title()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$usr_id = $appbox->get_session()->get_usr_id();
|
$usr_id = self::$application['phraseanet.user']->get_id();
|
||||||
|
|
||||||
$basket = $this->insertOneBasket();
|
$basket = $this->insertOneBasket();
|
||||||
|
|
||||||
@@ -433,7 +430,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
$this->assertEquals('application/json', $result->get_content_type());
|
$this->assertEquals('application/json', $result->get_content_type());
|
||||||
$this->assertTrue(is_array(json_decode($result->format(), true)));
|
$this->assertTrue(is_array(json_decode($result->format(), true)));
|
||||||
|
|
||||||
$repository = self::$core->getEntityManager()->getRepository('\Entities\Basket');
|
$repository = self::$application['EM']->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
$ret_bask = $repository->find($basket->getId());
|
$ret_bask = $repository->find($basket->getId());
|
||||||
|
|
||||||
@@ -442,8 +439,8 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testSet_basket_description()
|
public function testSet_basket_description()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$usr_id = $appbox->get_session()->get_usr_id();
|
$usr_id = self::$application['phraseanet.user']->get_id();
|
||||||
|
|
||||||
$basket = $this->insertOneBasket();
|
$basket = $this->insertOneBasket();
|
||||||
|
|
||||||
@@ -453,7 +450,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
$this->assertEquals('application/json', $result->get_content_type());
|
$this->assertEquals('application/json', $result->get_content_type());
|
||||||
$this->assertTrue(is_array(json_decode($result->format(), true)));
|
$this->assertTrue(is_array(json_decode($result->format(), true)));
|
||||||
|
|
||||||
$repository = self::$core->getEntityManager()->getRepository('\Entities\Basket');
|
$repository = self::$application['EM']->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
$ret_bask = $repository->find($basket->getId());
|
$ret_bask = $repository->find($basket->getId());
|
||||||
|
|
||||||
@@ -462,9 +459,9 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testSearch_publications()
|
public function testSearch_publications()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||||
$feed = Feed_Adapter::create($appbox, self::$user, "hello", "salut");
|
$feed = Feed_Adapter::create(self::$application, self::$user, "hello", "salut");
|
||||||
$result = $this->object->search_publications($request, self::$user);
|
$result = $this->object->search_publications($request, self::$user);
|
||||||
$this->checkResponseField($result, "feeds", 'array');
|
$this->checkResponseField($result, "feeds", 'array');
|
||||||
$feed->delete();
|
$feed->delete();
|
||||||
@@ -480,15 +477,15 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testGet_publication()
|
public function testGet_publication()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = self::$application['phraseanet.appbox'];
|
||||||
|
|
||||||
$date = new DateTime();
|
$date = new DateTime();
|
||||||
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||||
$feed = Feed_Adapter::create($appbox, self::$user, "hello", "salut");
|
$feed = Feed_Adapter::create(self::$application, self::$user, "hello", "salut");
|
||||||
$feed_publisher = Feed_Publisher_Adapter::getPublisher($appbox, $feed, self::$user);
|
$feed_publisher = Feed_Publisher_Adapter::getPublisher(self::$application['phraseanet.appbox'], $feed, self::$user);
|
||||||
$feed_entry = Feed_Entry_Adapter::create($appbox, $feed, $feed_publisher, "coucou", "hello", "me", "my@email.com");
|
$feed_entry = Feed_Entry_Adapter::create(self::$application, $feed, $feed_publisher, "coucou", "hello", "me", "my@email.com");
|
||||||
$feed_entry_item = Feed_Entry_Item::create($appbox, $feed_entry, static::$records['record_1']);
|
$feed_entry_item = Feed_Entry_Item::create($appbox, $feed_entry, static::$records['record_1']);
|
||||||
$coll = Feed_Collection::load_all($appbox, self::$user);
|
$coll = Feed_Collection::load_all(self::$application, self::$user);
|
||||||
foreach ($coll->get_feeds() as $feed) {
|
foreach ($coll->get_feeds() as $feed) {
|
||||||
$result = $this->object->get_publication($request, $feed->get_id(), self::$user);
|
$result = $this->object->get_publication($request, $feed->get_id(), self::$user);
|
||||||
$this->checkResponseField($result, "feed", 'array');
|
$this->checkResponseField($result, "feed", 'array');
|
||||||
|
@@ -12,7 +12,7 @@ class caption_recordTest extends PhraseanetPHPUnitAbstract
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->object = new caption_record(static::$records['record_1'], static::$records['record_1']->get_databox());
|
$this->object = new caption_record(self::$application, static::$records['record_1'], static::$records['record_1']->get_databox());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,7 +25,7 @@ class caption_recordTest extends PhraseanetPHPUnitAbstract
|
|||||||
$n = $databox_field->is_multi() ? 3 : 1;
|
$n = $databox_field->is_multi() ? 3 : 1;
|
||||||
|
|
||||||
for ($i = 0; $i < $n; $i ++ ) {
|
for ($i = 0; $i < $n; $i ++ ) {
|
||||||
\caption_Field_Value::create($databox_field, static::$records['record_1'], \random::generatePassword());
|
\caption_Field_Value::create(self::$application, $databox_field, static::$records['record_1'], \random::generatePassword());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,10 +25,10 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
|
|||||||
$this->object_multi = $this->databox->get_meta_structure()->get_element_by_name($this->name_multi);
|
$this->object_multi = $this->databox->get_meta_structure()->get_element_by_name($this->name_multi);
|
||||||
|
|
||||||
if ( ! $this->object_mono instanceof databox_field) {
|
if ( ! $this->object_mono instanceof databox_field) {
|
||||||
$this->object_mono = databox_field::create($this->databox, $this->name_mono, false);
|
$this->object_mono = databox_field::create(self::$application, $this->databox, $this->name_mono, false);
|
||||||
}
|
}
|
||||||
if ( ! $this->object_multi instanceof databox_field) {
|
if ( ! $this->object_multi instanceof databox_field) {
|
||||||
$this->object_multi = databox_field::create($this->databox, $this->name_multi, true);
|
$this->object_multi = databox_field::create(self::$application, $this->databox, $this->name_multi, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,10 +51,10 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
public function testGet_instance()
|
public function testGet_instance()
|
||||||
{
|
{
|
||||||
$instance = databox_field::get_instance($this->databox, $this->object_mono->get_id());
|
$instance = databox_field::get_instance(self::$application, $this->databox, $this->object_mono->get_id());
|
||||||
$this->assertEquals($this->object_mono->get_id(), $instance->get_id());
|
$this->assertEquals($this->object_mono->get_id(), $instance->get_id());
|
||||||
|
|
||||||
$instance = databox_field::get_instance($this->databox, $this->object_multi->get_id());
|
$instance = databox_field::get_instance(self::$application, $this->databox, $this->object_multi->get_id());
|
||||||
$this->assertEquals($this->object_multi->get_id(), $instance->get_id());
|
$this->assertEquals($this->object_multi->get_id(), $instance->get_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,8 +163,8 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
public function testGet_tag()
|
public function testGet_tag()
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf('\\PHPExiftool\\Driver\\Tag', $this->object_mono->get_tag());
|
$this->assertInstanceOf('\\PHPExiftool\\Driver\\TagInterface', $this->object_mono->get_tag());
|
||||||
$this->assertInstanceOf('\\PHPExiftool\\Driver\\Tag', $this->object_multi->get_tag());
|
$this->assertInstanceOf('\\PHPExiftool\\Driver\\TagInterface', $this->object_multi->get_tag());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGet_dces_element()
|
public function testGet_dces_element()
|
||||||
|
@@ -112,39 +112,39 @@ class databox_statusTest extends PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
public function testOperation_and()
|
public function testOperation_and()
|
||||||
{
|
{
|
||||||
$this->assertEquals('0', databox_status::operation_and('0x001', '0x010'));
|
$this->assertEquals('0', databox_status::operation_and(self::$application, '0x001', '0x010'));
|
||||||
$this->assertEquals('1', databox_status::operation_and('01', '11'));
|
$this->assertEquals('1', databox_status::operation_and(self::$application, '01', '11'));
|
||||||
$this->assertEquals('0', databox_status::operation_and('01', '10'));
|
$this->assertEquals('0', databox_status::operation_and(self::$application, '01', '10'));
|
||||||
$this->assertEquals('10', databox_status::operation_and('11', '10'));
|
$this->assertEquals('10', databox_status::operation_and(self::$application, '11', '10'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOperation_and_not()
|
public function testOperation_and_not()
|
||||||
{
|
{
|
||||||
$this->assertEquals('0', databox_status::operation_and_not('0x001', '0x011'));
|
$this->assertEquals('0', databox_status::operation_and_not(self::$application, '0x001', '0x011'));
|
||||||
$this->assertEquals('0', databox_status::operation_and_not('01', '11'));
|
$this->assertEquals('0', databox_status::operation_and_not(self::$application, '01', '11'));
|
||||||
$this->assertEquals('1', databox_status::operation_and_not('01', '10'));
|
$this->assertEquals('1', databox_status::operation_and_not(self::$application, '01', '10'));
|
||||||
$this->assertEquals('1', databox_status::operation_and_not('11', '10'));
|
$this->assertEquals('1', databox_status::operation_and_not(self::$application, '11', '10'));
|
||||||
$this->assertEquals('10', databox_status::operation_and_not('10', '01'));
|
$this->assertEquals('10', databox_status::operation_and_not(self::$application, '10', '01'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOperation_or()
|
public function testOperation_or()
|
||||||
{
|
{
|
||||||
$this->assertEquals('10001', databox_status::operation_or('0x001', '0x011'));
|
$this->assertEquals('10001', databox_status::operation_or(self::$application, '0x001', '0x011'));
|
||||||
$this->assertEquals('11', databox_status::operation_or('01', '11'));
|
$this->assertEquals('11', databox_status::operation_or(self::$application, '01', '11'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDec2bin()
|
public function testDec2bin()
|
||||||
{
|
{
|
||||||
$this->assertEquals('1010', databox_status::dec2bin('10'));
|
$this->assertEquals('1010', databox_status::dec2bin(self::$application, '10'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHex2bin()
|
public function testHex2bin()
|
||||||
{
|
{
|
||||||
$this->assertEquals('10100001', databox_status::hex2bin('0x0A1'));
|
$this->assertEquals('10100001', databox_status::hex2bin(self::$application, '0x0A1'));
|
||||||
$this->assertEquals('10100001', databox_status::hex2bin('0A1'));
|
$this->assertEquals('10100001', databox_status::hex2bin(self::$application, '0A1'));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
databox_status::hex2bin('G1');
|
databox_status::hex2bin(self::$application, 'G1');
|
||||||
$this->fail('Should raise an exception');
|
$this->fail('Should raise an exception');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
||||||
|
|
||||||
use Alchemy\Phrasea\CLI;
|
use Alchemy\Phrasea\CLI;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
|
||||||
class module_console_schedulerStateTest extends PHPUnit_Framework_TestCase
|
class module_console_schedulerStateTest extends PHPUnit_Framework_TestCase
|
||||||
@@ -21,14 +22,14 @@ class module_console_schedulerStateTest extends PHPUnit_Framework_TestCase
|
|||||||
$commandTester = new CommandTester($command);
|
$commandTester = new CommandTester($command);
|
||||||
$commandTester->execute(array('command' => $command->getName()));
|
$commandTester->execute(array('command' => $command->getName()));
|
||||||
|
|
||||||
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
|
$task_manager = new task_manager(self::$application);
|
||||||
$state = $task_manager->getSchedulerState();
|
$state = $task_manager->getSchedulerState();
|
||||||
|
|
||||||
$sentence = sprintf('Scheduler is %s', $state['status']);
|
$sentence = sprintf('Scheduler is %s', $state['status']);
|
||||||
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
|
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
|
||||||
|
|
||||||
$commandTester->execute(array('command' => $command->getName(), '--short'=>true));
|
$commandTester->execute(array('command' => $command->getName(), '--short'=>true));
|
||||||
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
|
$task_manager = new task_manager(self::$application);
|
||||||
$state = $task_manager->getSchedulerState();
|
$state = $task_manager->getSchedulerState();
|
||||||
|
|
||||||
$sentence = sprintf('%s(%s)', $state['status'], $state['pid']);
|
$sentence = sprintf('%s(%s)', $state['status'], $state['pid']);
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
||||||
|
|
||||||
use Alchemy\Phrasea\CLI;
|
use Alchemy\Phrasea\CLI;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
|
||||||
class module_console_taskStateTest extends PhraseanetPHPUnitAbstract
|
class module_console_taskStateTest extends PhraseanetPHPUnitAbstract
|
||||||
@@ -30,12 +31,12 @@ class module_console_taskStateTest extends PhraseanetPHPUnitAbstract
|
|||||||
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
|
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
|
||||||
|
|
||||||
// test good tasks ids
|
// test good tasks ids
|
||||||
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
|
$task_manager = new task_manager(self::$application);
|
||||||
$tasks = $task_manager->getTasks($application);
|
$tasks = $task_manager->getTasks();
|
||||||
$tids = array(); // list known ids of tasks so we can generate a 'unknown id' later
|
$tids = array(); // list known ids of tasks so we can generate a 'unknown id' later
|
||||||
foreach ($tasks as $task) {
|
foreach ($tasks as $task) {
|
||||||
$tids[] = $task->getID();
|
$tids[] = $task->getID();
|
||||||
$task = $task_manager->getTask($application, $task->getID());
|
$task = $task_manager->getTask($task->getID());
|
||||||
$state = $task->getState();
|
$state = $task->getState();
|
||||||
$pid = $task->getPID();
|
$pid = $task->getPID();
|
||||||
|
|
||||||
@@ -63,5 +64,3 @@ class module_console_taskStateTest extends PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
||||||
|
|
||||||
use Alchemy\Phrasea\CLI;
|
use Alchemy\Phrasea\CLI;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
|
||||||
class module_console_tasklistTest extends PHPUnit_Framework_TestCase
|
class module_console_tasklistTest extends PHPUnit_Framework_TestCase
|
||||||
@@ -21,12 +22,12 @@ class module_console_tasklistTest extends PHPUnit_Framework_TestCase
|
|||||||
$commandTester = new CommandTester($command);
|
$commandTester = new CommandTester($command);
|
||||||
$commandTester->execute(array('command' => $command->getName()));
|
$commandTester->execute(array('command' => $command->getName()));
|
||||||
|
|
||||||
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
|
$task_manager = new task_manager(self::$application);
|
||||||
$lines = explode("\n", trim($commandTester->getDisplay()));
|
$lines = explode("\n", trim($commandTester->getDisplay()));
|
||||||
|
|
||||||
if (count($task_manager->getTasks($application)) > 0) {
|
if (count($task_manager->getTasks()) > 0) {
|
||||||
$this->assertEquals(count($task_manager->getTasks($application)), count($lines));
|
$this->assertEquals(count($task_manager->getTasks()), count($lines));
|
||||||
foreach ($task_manager->getTasks($application) as $task) {
|
foreach ($task_manager->getTasks() as $task) {
|
||||||
$this->assertTrue(strpos($commandTester->getDisplay(), $task->getTitle()) !== false);
|
$this->assertTrue(strpos($commandTester->getDisplay(), $task->getTitle()) !== false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user