Update Admin unit tests

This commit is contained in:
Romain Neutron
2012-09-18 00:39:19 +02:00
parent 8ea5078b57
commit c911f3eeb5
13 changed files with 316 additions and 471 deletions

View File

@@ -23,7 +23,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
} }
} }
self::$createdCollections = null; self::$createdCollections = null;
// /!\ re enable collection // /!\ re enable collection
self::$collection->enable(self::$application['phraseanet.appbox']); self::$collection->enable(self::$application['phraseanet.appbox']);
@@ -50,7 +49,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function createOneCollection() public function createOneCollection()
{ {
$collection = \collection::create(array_shift($this->app['phraseanet.appbox']->get_databoxes()), $this->app['phraseanet.appbox'], 'TESTTODELETE'); $collection = \collection::create(self::$application, array_shift(self::$application['phraseanet.appbox']->get_databoxes()), self::$application['phraseanet.appbox'], 'TESTTODELETE');
self::$createdCollections[] = $collection; self::$createdCollections[] = $collection;
@@ -90,7 +89,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $this->createOneCollection(); $collection = $this->createOneCollection();
$file = new \Alchemy\Phrasea\Border\File($this->app['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection); $file = new \Alchemy\Phrasea\Border\File(self::$application['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
\record_adapter::createFromFile($file, self::$application); \record_adapter::createFromFile($file, self::$application);
$this->client->request('GET', '/admin/collection/' . $collection->get_base_id() . '/informations/details/'); $this->client->request('GET', '/admin/collection/' . $collection->get_base_id() . '/informations/details/');
@@ -372,7 +371,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$json = $this->getJson($this->client->getResponse()); $json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success); $this->assertTrue($json->success);
$this->assertEquals($collection->get_name(), 'test_rename_coll'); $this->assertEquals($collection->get_name(), 'test_rename_coll');
$collection->unmount_collection($this->app); $collection->unmount_collection(self::$application);
$collection->delete(); $collection->delete();
} }
@@ -410,7 +409,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $this->createOneCollection(); $collection = $this->createOneCollection();
$file = new \Alchemy\Phrasea\Border\File($this->app['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection); $file = new \Alchemy\Phrasea\Border\File(self::$application['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
\record_adapter::createFromFile($file, self::$application); \record_adapter::createFromFile($file, self::$application);
if ($collection->get_record_amount() === 0) { if ($collection->get_record_amount() === 0) {
@@ -433,7 +432,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $this->createOneCollection(); $collection = $this->createOneCollection();
$databox = $this->app['phraseanet.appbox']->get_databox($collection->get_sbas_id()); $databox = self::$application['phraseanet.appbox']->get_databox($collection->get_sbas_id());
$sql = ' $sql = '
INSERT INTO record INSERT INTO record
(coll_id, record_id, parent_record_id, moddate, credate (coll_id, record_id, parent_record_id, moddate, credate
@@ -471,7 +470,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$json = $this->getJson($this->client->getResponse()); $json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success); $this->assertTrue($json->success);
$taskManager = new \task_manager($this->app); $taskManager = new \task_manager(self::$application);
$tasks = $taskManager->getTasks(); $tasks = $taskManager->getTasks();
$found = false; $found = false;
@@ -515,8 +514,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testSetWatermarkBadRequest() public function testSetWatermarkBadRequest()
{ {
$this->setAdmin(true);
$this->client->request('POST', '/admin/collection/' . self::$collection->get_base_id() . '/picture/watermark/'); $this->client->request('POST', '/admin/collection/' . self::$collection->get_base_id() . '/picture/watermark/');
} }
@@ -539,13 +536,13 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true); $this->setAdmin(true);
$target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg'; $target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg';
$this->app['filesystem']->copy(__DIR__ . '/../../../../testfiles/p4logo.jpg', $target); self::$application['filesystem']->copy(__DIR__ . '/../../../../testfiles/p4logo.jpg', $target);
$files = array( $files = array(
'newLogo' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg') 'newLogo' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg')
); );
$this->client->request('POST', '/admin/collection/' . self::$collection->get_base_id() . '/picture/mini-logo/', array(), $files); $this->client->request('POST', '/admin/collection/' . self::$collection->get_base_id() . '/picture/mini-logo/', array(), $files);
$this->checkRedirection($this->client->getResponse(), '/admin/collection/' . self::$collection->get_base_id() . '/?success=1'); $this->checkRedirection($this->client->getResponse(), '/admin/collection/' . self::$collection->get_base_id() . '/?success=1');
$this->assertEquals(1, count(\collection::getLogo(self::$collection->get_base_id()))); $this->assertEquals(1, count(\collection::getLogo(self::$application, self::$collection->get_base_id())));
} }
/** /**
@@ -567,7 +564,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testDeleteMiniLogo() public function testDeleteMiniLogo()
{ {
if (count(\collection::getLogo(self::$collection->get_base_id())) === 0) { if (count(\collection::getLogo(self::$application, self::$collection->get_base_id())) === 0) {
$this->markTestSkipped('No logo setted'); $this->markTestSkipped('No logo setted');
} }
@@ -586,7 +583,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true); $this->setAdmin(true);
$target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg'; $target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg';
$this->app['filesystem']->copy(__DIR__ . '/../../../../testfiles/p4logo.jpg', $target); self::$application['filesystem']->copy(__DIR__ . '/../../../../testfiles/p4logo.jpg', $target);
$files = array( $files = array(
'newWm' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg') 'newWm' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg')
); );
@@ -633,7 +630,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true); $this->setAdmin(true);
$target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg'; $target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg';
$this->app['filesystem']->copy(__DIR__ . '/../../../../testfiles/p4logo.jpg', $target); self::$application['filesystem']->copy(__DIR__ . '/../../../../testfiles/p4logo.jpg', $target);
$files = array( $files = array(
'newStamp' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg') 'newStamp' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg')
); );
@@ -681,7 +678,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true); $this->setAdmin(true);
$target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg'; $target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg';
$this->app['filesystem']->copy(__DIR__ . '/../../../../testfiles/p4logo.jpg', $target); self::$application['filesystem']->copy(__DIR__ . '/../../../../testfiles/p4logo.jpg', $target);
$files = array( $files = array(
'newBanner' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg') 'newBanner' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg')
); );
@@ -809,7 +806,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $this->createOneCollection(); $collection = $this->createOneCollection();
$file = new \Alchemy\Phrasea\Border\File($this->app['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection); $file = new \Alchemy\Phrasea\Border\File(self::$application['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
\record_adapter::createFromFile($file, self::$application); \record_adapter::createFromFile($file, self::$application);
if ($collection->get_record_amount() === 0) { if ($collection->get_record_amount() === 0) {

View File

@@ -90,7 +90,7 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$admins = array_keys(\User_Adapter::get_sys_admins()); $admins = array_keys(\User_Adapter::get_sys_admins(self::$application));
$user = \User_Adapter::create($this->app, uniqid('unit_test_user'), uniqid('unit_test_user'), uniqid('unit_test_user') ."@email.com", false); $user = \User_Adapter::create($this->app, uniqid('unit_test_user'), uniqid('unit_test_user'), uniqid('unit_test_user') ."@email.com", false);

View File

@@ -8,12 +8,6 @@ class ConnectedUserTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
protected $client; protected $client;
public function setUp()
{
parent::setUp();
$this->client = $this->createClient();
}
/** /**
* @covers \Alchemy\Phrasea\Controller\Admin\ConnectedUsers::connect * @covers \Alchemy\Phrasea\Controller\Admin\ConnectedUsers::connect
*/ */

View File

@@ -1,5 +1,6 @@
<?php <?php
use Alchemy\Phrasea\Core\Configuration;
use MediaAlchemyst\Alchemyst; use MediaAlchemyst\Alchemyst;
use MediaAlchemyst\DriversContainer; use MediaAlchemyst\DriversContainer;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
@@ -12,26 +13,23 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
protected static $createdCollections = array(); protected static $createdCollections = array();
protected static $createdDataboxes = array(); protected static $createdDataboxes = array();
public function createApplication() public static function setUpBeforeClass()
{ {
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php'; parent::setUpBeforeClass();
self::dropDatabase();
}
$app['debug'] = true; public function setUp()
unset($app['exception_handler']); {
self::dropDatabase();
return $app; parent::setUp();
} }
public static function tearDownAfterClass() public static function tearDownAfterClass()
{ {
$appbox = \appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$auth = new \Session_Authentication_None(self::$user);
$session->authenticate($auth);
foreach (self::$createdCollections as $collection) { foreach (self::$createdCollections as $collection) {
try { try {
$collection->unmount_collection($appbox); $collection->unmount_collection(self::$application);
} catch (\Exception $e) { } catch (\Exception $e) {
} }
@@ -43,33 +41,17 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
} }
} }
foreach (self::$createdDataboxes as $databox) { self::$createdCollections = null;
try {
$databox->unmount_databox($appbox);
} catch (\Exception $e) {
}
try {
$appbox->write_databox_pic(new Alchemyst(new DriversContainer(new Configuration())), new Filesystem(), $databox, null, \databox::PIC_PDF);
} catch (\Exception $e) {
}
try {
$databox->delete();
} catch (\Exception $e) {
}
}
self::$createdCollections = self::$createdDataboxes = null;
$session->logout();
parent::tearDownAfterClass(); parent::tearDownAfterClass();
} }
public function tearDown()
{
// self::dropDatabase();
parent::tearDown();
}
public function getJson($response) public function getJson($response)
{ {
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
@@ -84,55 +66,40 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function createOneCollection() public function createOneCollection()
{ {
$collection = \collection::create(array_shift($this->app['phraseanet.appbox']->get_databoxes()), $this->app['phraseanet.appbox'], 'TESTTODELETE'); $collection = \collection::create(self::$application, array_shift(self::$application['phraseanet.appbox']->get_databoxes()), self::$application['phraseanet.appbox'], 'TESTTODELETE');
self::$application['phraseanet.user']->ACL();
self::$createdCollections[] = $collection; self::$createdCollections[] = $collection;
return $collection; return $collection;
} }
public function createDatabox($dbName) public function createDatabox()
{ {
$registry = $this->app['phraseanet.core']['Registry']; $registry = self::$application['phraseanet.registry'];
try { $this->createDatabase();
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare(
'DROP DATABASE IF EXISTS `' . $dbName . '`'
);
$stmt->execute(); $configuration = self::$application['phraseanet.configuration'];
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare(
'CREATE DATABASE `' . $dbName . '` CHARACTER SET utf8 COLLATE utf8_unicode_ci'
);
$stmt->execute();
$stmt->closeCursor();
} catch (\Exception $e) {
$this->markTestSkipped('Could not create Databox ');
}
$configuration = $this->app['phraseanet.core']->getConfiguration();
$choosenConnexion = $configuration->getPhraseanet()->get('database'); $choosenConnexion = $configuration->getPhraseanet()->get('database');
$connexion = $configuration->getConnexion($choosenConnexion); $connexion = $configuration->getConnexion($choosenConnexion);
try { try {
$conn = new \connection_pdo('databox_creation', $connexion->get('host'), $connexion->get('port'), $connexion->get('user'), $connexion->get('password'), $dbName, array(), $registry); $conn = new \connection_pdo('databox_creation', $connexion->get('host'), $connexion->get('port'), $connexion->get('user'), $connexion->get('password'), 'unit_test_db', array(), $registry);
} catch (\PDOException $e) { } catch (\PDOException $e) {
$this->markTestSkipped('Could not reach DB'); $this->markTestSkipped('Could not reach DB');
} }
$databox = \databox::create( $databox = \databox::create(
$this->app['phraseanet.appbox'], $conn, new \SplFileInfo($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/fr-simple.xml'), $registry self::$application, $conn, new \SplFileInfo($registry->get('GV_RootPath') . 'lib/conf.d/data_templates/fr-simple.xml'), $registry
); );
self::$createdDataboxes[] = $databox; self::$createdDataboxes[] = $databox;
$databox->registerAdmin($this->app['phraseanet.core']->getAuthenticatedUser()); $databox->registerAdmin(self::$application['phraseanet.user']);
unset($stmt, $conn);
return $databox; return $databox;
} }
@@ -143,6 +110,30 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertEquals($location, $response->headers->get('location')); $this->assertEquals($location, $response->headers->get('location'));
} }
public static function dropDatabase()
{
$stmt = self::$application['phraseanet.appbox']
->get_connection()
->prepare('DROP DATABASE IF EXISTS `unit_test_db`');
$stmt->execute();
$stmt = self::$application['phraseanet.appbox']
->get_connection()
->prepare('DELETE FROM sbas WHERE dbname = "unit_test_db"');
$stmt->execute();
}
protected function createDatabase()
{
self::dropDatabase();
$stmt = self::$application['phraseanet.appbox']
->get_connection()
->prepare('CREATE DATABASE `unit_test_db`
CHARACTER SET utf8 COLLATE utf8_unicode_ci');
$stmt->execute();
$stmt->closeCursor();
}
/** /**
* @covers \Alchemy\Phrasea\Controller\Admin\Database::getDatabase * @covers \Alchemy\Phrasea\Controller\Admin\Database::getDatabase
* @covers \Alchemy\Phrasea\Controller\Admin\Database::connect * @covers \Alchemy\Phrasea\Controller\Admin\Database::connect
@@ -152,7 +143,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->client->request('GET', '/databox/' . self::$collection->get_sbas_id() . '/'); $this->client->request('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
@@ -163,7 +154,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->client->request('GET', '/databox/' . self::$collection->get_sbas_id() . '/collections/order/'); $this->client->request('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/collections/order/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
@@ -172,12 +163,13 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testSetReorder() public function testSetReorder()
{ {
$databox = $this->createDatabox('unit_test_db8'); $databox = $this->createDatabox();
$collection = \collection::create($databox, $this->app['phraseanet.appbox'], 'TESTTODELETE');
$this->setAdmin(true); $this->setAdmin(true);
$this->XMLHTTPRequest('POST', '/databox/' . $databox->get_sbas_id() . '/collections/order/', array( $collection = \collection::create(self::$application, $databox, self::$application['phraseanet.appbox'], 'TESTTODELETE');
$this->XMLHTTPRequest('POST', '/admin/databox/' . $databox->get_sbas_id() . '/collections/order/', array(
'order' => array( 'order' => array(
2 => $collection->get_base_id() 2 => $collection->get_base_id()
))); )));
@@ -202,7 +194,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true); $this->setAdmin(true);
$this->client->request('GET', '/databox/' . self::$collection->get_sbas_id() . '/cgus/'); $this->client->request('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/cgus/');
} }
/** /**
@@ -217,7 +209,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true); $this->setAdmin(true);
$this->client->request('GET', '/databox/' . self::$collection->get_sbas_id() . '/cgus/'); $this->client->request('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/cgus/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
@@ -230,7 +222,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $this->createOneCollection(); $collection = $this->createOneCollection();
$this->client->request('POST', '/databox/' . $collection->get_sbas_id() . '/cgus/', array( $this->client->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/cgus/', array(
'TOU' => array('fr_FR' => 'Test update CGUS') 'TOU' => array('fr_FR' => 'Test update CGUS')
)); ));
@@ -251,13 +243,13 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$cgusUpdate = 'Test update CGUS'; $cgusUpdate = 'Test update CGUS';
$this->XMLHTTPRequest('POST', '/databox/' . self::$collection->get_sbas_id() . '/cgus/', array( $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$collection->get_sbas_id() . '/cgus/', array(
'TOU' => array('fr_FR' => $cgusUpdate) 'TOU' => array('fr_FR' => $cgusUpdate)
)); ));
$this->checkRedirection($this->client->getResponse(), '/admin/databox/' . self::$collection->get_sbas_id() . '/cgus/?success=1'); $this->checkRedirection($this->client->getResponse(), '/admin/databox/' . self::$collection->get_sbas_id() . '/cgus/?success=1');
$databox = $this->app['phraseanet.appbox']->get_databox(self::$collection->get_sbas_id()); $databox = self::$application['phraseanet.appbox']->get_databox(self::$collection->get_sbas_id());
$cgus = $databox->get_cgus(); $cgus = $databox->get_cgus();
$this->assertEquals($cgus['fr_FR']['value'], $cgusUpdate); $this->assertEquals($cgus['fr_FR']['value'], $cgusUpdate);
unset($databox); unset($databox);
@@ -271,7 +263,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->client->request('GET', '/databox/' . self::$collection->get_sbas_id() . '/informations/documents/'); $this->client->request('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/informations/documents/');
} }
/** /**
@@ -281,7 +273,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->XMLHTTPRequest('GET', '/databox/' . self::$collection->get_sbas_id() . '/informations/documents/'); $this->XMLHTTPRequest('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/informations/documents/');
$json = $this->getJson($this->client->getResponse()); $json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success); $this->assertTrue($json->success);
@@ -301,7 +293,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->client->request('GET', '/databox/' . self::$collection->get_sbas_id() . '/informations/details/'); $this->client->request('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/informations/details/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
@@ -312,7 +304,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->client->request('GET', '/databox/' . self::$collection->get_sbas_id() . '/collection/'); $this->client->request('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/collection/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
@@ -324,7 +316,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(false); $this->setAdmin(false);
$this->client->request('GET', '/databox/' . self::$collection->get_sbas_id() . '/'); $this->client->request('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/');
} }
/** /**
@@ -335,7 +327,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(false); $this->setAdmin(false);
$this->client->request('GET', '/databox/' . self::$collection->get_sbas_id() . '/collections/order/'); $this->client->request('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/collections/order/');
} }
/** /**
@@ -346,7 +338,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(false); $this->setAdmin(false);
$this->client->request('GET', '/databox/' . self::$collection->get_sbas_id() . '/cgus/'); $this->client->request('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/cgus/');
} }
/** /**
@@ -358,7 +350,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(false); $this->setAdmin(false);
$this->XMLHTTPRequest('GET', '/databox/' . self::$collection->get_sbas_id() . '/informations/documents/'); $this->XMLHTTPRequest('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/informations/documents/');
} }
/** /**
@@ -369,7 +361,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(false); $this->setAdmin(false);
$this->client->request('GET', '/databox/' . self::$collection->get_sbas_id() . '/informations/details/'); $this->client->request('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/informations/details/');
} }
/** /**
@@ -380,7 +372,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(false); $this->setAdmin(false);
$this->client->request('GET', '/databox/' . self::$collection->get_sbas_id() . '/collection/'); $this->client->request('GET', '/admin/databox/' . self::$collection->get_sbas_id() . '/collection/');
} }
/** /**
@@ -388,11 +380,9 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testPostReindexNotJson() public function testPostReindexNotJson()
{ {
$this->setAdmin(true); $collection = $this->createOneCollection();
$collection = $this->createOnecollection(); $this->client->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/reindex/');
$this->client->request('POST', '/databox/' . $collection->get_sbas_id() . '/reindex/');
$this->assertTrue($this->client->getResponse()->isRedirect()); $this->assertTrue($this->client->getResponse()->isRedirect());
} }
@@ -404,7 +394,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->XMLHTTPRequest('POST', '/databox/' . self::$collection->get_sbas_id() . '/reindex/'); $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$collection->get_sbas_id() . '/reindex/');
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$this->assertEquals('application/json', $response->headers->get('Content-Type')); $this->assertEquals('application/json', $response->headers->get('Content-Type'));
@@ -422,7 +412,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $this->createOnecollection(); $collection = $this->createOnecollection();
$this->client->request('POST', '/databox/' . $collection->get_sbas_id() . '/indexable/'); $this->client->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/indexable/');
$this->assertTrue($this->client->getResponse()->isRedirect()); $this->assertTrue($this->client->getResponse()->isRedirect());
} }
@@ -434,7 +424,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->XMLHTTPRequest('POST', '/databox/' . self::$collection->get_sbas_id() . '/indexable/', array( $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$collection->get_sbas_id() . '/indexable/', array(
'indexable' => 1 'indexable' => 1
)); ));
@@ -445,7 +435,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertTrue(is_object($content)); $this->assertTrue(is_object($content));
$this->assertObjectHasAttribute('sbas_id', $content, $response->getContent()); $this->assertObjectHasAttribute('sbas_id', $content, $response->getContent());
$this->assertTrue( ! ! $this->app['phraseanet.appbox']->is_databox_indexable(new \databox(self::$collection->get_sbas_id()))); $this->assertTrue(!!self::$application['phraseanet.appbox']->is_databox_indexable(new \databox(self::$application, self::$collection->get_sbas_id())));
} }
/** /**
@@ -457,7 +447,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $this->createOnecollection(); $collection = $this->createOnecollection();
$this->client->request('POST', '/databox/' . $collection->get_sbas_id() . '/clear-logs/'); $this->client->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/clear-logs/');
$this->assertTrue($this->client->getResponse()->isRedirect()); $this->assertTrue($this->client->getResponse()->isRedirect());
} }
@@ -469,7 +459,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->XMLHTTPRequest('POST', '/databox/' . self::$collection->get_sbas_id() . '/clear-logs/'); $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$collection->get_sbas_id() . '/clear-logs/');
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
@@ -488,7 +478,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection = $this->createOnecollection(); $collection = $this->createOnecollection();
$this->client->request('POST', '/databox/' . $collection->get_sbas_id() . '/view-name/', array( $this->client->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/view-name/', array(
'viewname' => 'hello' 'viewname' => 'hello'
)); ));
@@ -503,7 +493,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->XMLHTTPRequest('POST', '/databox/' . self::$collection->get_sbas_id() . '/view-name/'); $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$collection->get_sbas_id() . '/view-name/');
} }
/** /**
@@ -513,7 +503,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->XMLHTTPRequest('POST', '/databox/' . self::$collection->get_sbas_id() . '/view-name/', array( $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$collection->get_sbas_id() . '/view-name/', array(
'viewname' => 'new_databox_name' 'viewname' => 'new_databox_name'
)); ));
@@ -524,7 +514,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertTrue(is_object($content)); $this->assertTrue(is_object($content));
$this->assertObjectHasAttribute('sbas_id', $content, $response->getContent()); $this->assertObjectHasAttribute('sbas_id', $content, $response->getContent());
$databox = new \databox(self::$collection->get_sbas_id()); $databox = new \databox(self::$application, self::$collection->get_sbas_id());
$this->assertEquals('new_databox_name', $databox->get_viewname()); $this->assertEquals('new_databox_name', $databox->get_viewname());
} }
@@ -535,7 +525,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->client->request('POST', '/databox/', array( $this->client->request('POST', '/admin/databox/', array(
'new_dbname' => '' 'new_dbname' => ''
)); ));
@@ -551,7 +541,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->client->request('POST', '/databox/', array( $this->client->request('POST', '/admin/databox/', array(
'new_dbname' => 'ééààèè' 'new_dbname' => 'ééààèè'
)); ));
@@ -567,22 +557,10 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$dbName = 'unit_test_db'; $this->createDatabase();
try { $this->client->request('POST', '/admin/databox/', array(
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare('DROP DATABASE IF EXISTS `' . $dbName . '`'); 'new_dbname' => 'unit_test_db',
$stmt->execute();
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare('CREATE DATABASE `' . $dbName . '`
CHARACTER SET utf8 COLLATE utf8_unicode_ci');
$stmt->execute();
$stmt->closeCursor();
} catch (\Exception $e) {
$this->markTestSkipped('Could not create Databox ');
}
$this->client->request('POST', '/databox/', array(
'new_dbname' => $dbName,
'new_data_template' => 'fr-simple', 'new_data_template' => 'fr-simple',
)); ));
@@ -592,8 +570,8 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertTrue(!!strrpos($uriRedirect, 'success=1')); $this->assertTrue(!!strrpos($uriRedirect, 'success=1'));
$explode = explode('/', $uriRedirect); $explode = explode('/', $uriRedirect);
$databoxId = $explode[3]; $databoxId = $explode[3];
$databox = $this->app['phraseanet.appbox']->get_databox($databoxId); $databox = self::$application['phraseanet.appbox']->get_databox($databoxId);
$databox->unmount_databox($this->app['phraseanet.appbox']); $databox->unmount_databox(self::$application['phraseanet.appbox']);
$databox->delete(); $databox->delete();
unset($stmt, $databox); unset($stmt, $databox);
@@ -606,16 +584,16 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$base = $this->createDatabox('unit_test_db2'); $base = $this->createDatabox();
$this->XMLHTTPRequest('POST', '/databox/' . $base->get_sbas_id() . '/delete/'); $this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/delete/');
$json = $this->getJson($this->client->getResponse()); $json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success); $this->assertTrue($json->success);
$this->assertObjectHasAttribute('sbas_id', $json); $this->assertObjectHasAttribute('sbas_id', $json);
try { try {
$this->app['phraseanet.appbox']->get_databox((int) $json->sbas_id); self::$application['phraseanet.appbox']->get_databox((int) $json->sbas_id);
$this->fail('Databox not deleted'); $this->fail('Databox not deleted');
} catch (\Exception_DataboxNotFound $e) { } catch (\Exception_DataboxNotFound $e) {
@@ -629,11 +607,11 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$base = $this->createDatabox('unit_test_db3'); $base = $this->createDatabox();
$base->unmount_databox($this->app['phraseanet.appbox']); $base->unmount_databox(self::$application['phraseanet.appbox']);
$this->client->request('POST', '/databox/mount/', array( $this->client->request('POST', '/admin/databox/mount/', array(
'new_dbname' => 'unit_test_db3' 'new_dbname' => 'unit_test_db'
)); ));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
@@ -647,8 +625,8 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$databoxId = $explode[3]; $databoxId = $explode[3];
try { try {
$databox = $this->app['phraseanet.appbox']->get_databox($databoxId); $databox = self::$application['phraseanet.appbox']->get_databox($databoxId);
$databox->unmount_databox($this->app['phraseanet.appbox']); $databox->unmount_databox(self::$application['phraseanet.appbox']);
$databox->delete(); $databox->delete();
} catch (\Exception_DataboxNotFound $e) { } catch (\Exception_DataboxNotFound $e) {
$this->fail('databox not mounted'); $this->fail('databox not mounted');
@@ -666,9 +644,9 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true); $this->setAdmin(true);
$collection = $this->createOneCollection(); $collection = $this->createOneCollection();
$collection->unmount_collection($this->app['phraseanet.appbox']); $collection->unmount_collection(self::$application);
$this->client->request('POST', '/databox/' . $collection->get_sbas_id() . '/collection/' . $collection->get_coll_id() . '/mount/', array( $this->client->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/collection/' . $collection->get_coll_id() . '/mount/', array(
'othcollsel' => self::$collection->get_base_id() 'othcollsel' => self::$collection->get_base_id()
)); ));
@@ -683,11 +661,11 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true); $this->setAdmin(true);
$target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg'; $target = tempnam(sys_get_temp_dir(), 'p4logo') . '.jpg';
$this->app['filesystem']->copy(__DIR__ . '/../../../../testfiles/p4logo.jpg', $target); self::$application['filesystem']->copy(__DIR__ . '/../../../../testfiles/p4logo.jpg', $target);
$files = array( $files = array(
'newLogoPdf' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg') 'newLogoPdf' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg')
); );
$this->client->request('POST', '/databox/' . self::$collection->get_sbas_id() . '/logo/', array(), $files); $this->client->request('POST', '/admin/databox/' . self::$collection->get_sbas_id() . '/logo/', array(), $files);
$this->checkRedirection($this->client->getResponse(), '/admin/databox/' . self::$collection->get_sbas_id() . '/?success=1'); $this->checkRedirection($this->client->getResponse(), '/admin/databox/' . self::$collection->get_sbas_id() . '/?success=1');
$this->assertNotEmpty(\databox::getPrintLogo(self::$collection->get_sbas_id())); $this->assertNotEmpty(\databox::getPrintLogo(self::$collection->get_sbas_id()));
} }
@@ -703,7 +681,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->markTestSkipped('No logo setted'); $this->markTestSkipped('No logo setted');
} }
$this->XMLHTTPRequest('POST', '/databox/' . self::$collection->get_sbas_id() . '/logo/delete/'); $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$collection->get_sbas_id() . '/logo/delete/');
$json = $this->getJson($this->client->getResponse()); $json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success); $this->assertTrue($json->success);
@@ -717,16 +695,16 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$base = $this->createDatabox('unit_test_db4'); $base = $this->createDatabox();
$this->XMLHTTPRequest('POST', '/databox/' . $base->get_sbas_id() . '/unmount/'); $this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/unmount/');
$json = $this->getJson($this->client->getResponse()); $json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success); $this->assertTrue($json->success);
$this->assertObjectHasAttribute('sbas_id', $json); $this->assertObjectHasAttribute('sbas_id', $json);
try { try {
$this->app['phraseanet.appbox']->get_databox((int) $json->sbas_id); self::$application['phraseanet.appbox']->get_databox((int) $json->sbas_id);
$this->fail('Databox not unmounted'); $this->fail('Databox not unmounted');
} catch (\Exception_DataboxNotFound $e) { } catch (\Exception_DataboxNotFound $e) {
@@ -743,17 +721,17 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$base = $this->createDatabox('unit_test_db6'); $base = $this->createDatabox();
$collection = \collection::create($base, $this->app['phraseanet.appbox'], 'TESTTODELETE'); $collection = \collection::create(self::$application, $base, self::$application['phraseanet.appbox'], 'TESTTODELETE');
self::$createdCollections[] = $collection; self::$createdCollections[] = $collection;
$file = new \Alchemy\Phrasea\Border\File($this->app['phraseanet.core']['mediavorus']->guess(new \SplFileInfo(__DIR__ . '/../../../../testfiles/test001.CR2')), $collection); $file = new \Alchemy\Phrasea\Border\File(self::$application['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
\record_adapter::createFromFile($file, new Filesystem()); \record_adapter::createFromFile($file, self::$application);
if ($collection->get_record_amount() === 0) { if ($collection->get_record_amount() === 0) {
$this->markTestSkipped('No record were added'); $this->markTestSkipped('No record were added');
} }
$this->XMLHTTPRequest('POST', '/databox/' . $base->get_sbas_id() . '/empty/'); $this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/empty/');
$json = $this->getJson($this->client->getResponse()); $json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success); $this->assertTrue($json->success);
@@ -767,8 +745,8 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$base = $this->createDatabox('unit_test_db7'); $base = $this->createDatabox();
$collection = \collection::create($base, $this->app['phraseanet.appbox'], 'TESTTODELETE'); $collection = \collection::create(self::$application, $base, self::$application['phraseanet.appbox'], 'TESTTODELETE');
self::$createdCollections[] = $collection; self::$createdCollections[] = $collection;
$sql = 'INSERT INTO record $sql = 'INSERT INTO record
@@ -800,13 +778,13 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->markTestSkipped('No enough records added'); $this->markTestSkipped('No enough records added');
} }
$this->XMLHTTPRequest('POST', '/databox/' . $base->get_sbas_id() . '/empty/'); $this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/empty/');
$json = $this->getJson($this->client->getResponse()); $json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success); $this->assertTrue($json->success);
$taskManager = new \task_manager($this->app['phraseanet.appbox']); $taskManager = new \task_manager(self::$application);
$tasks = $taskManager->getTasks($this->app); $tasks = $taskManager->getTasks();
$found = false; $found = false;
foreach ($tasks as $task) { foreach ($tasks as $task) {

View File

@@ -6,16 +6,6 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
protected $client; protected $client;
public function createApplication()
{
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
$app['debug'] = true;
unset($app['exception_handler']);
return $app;
}
/** /**
* @covers Alchemy\Phrasea\Controller\Admin\Databases::getDatabases * @covers Alchemy\Phrasea\Controller\Admin\Databases::getDatabases
* @covers Alchemy\Phrasea\Controller\Admin\Databases::connect * @covers Alchemy\Phrasea\Controller\Admin\Databases::connect
@@ -23,13 +13,7 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testGetSlash($type, $errorMsgId) public function testGetSlash($type, $errorMsgId)
{ {
$this->StubbedACL->expects($this->any()) $this->client->request('GET', '/admin/databoxes/', array(
->method('get_granted_sbas')
->will($this->returnValue(array(self::$collection->get_sbas_id())));
$this->setAdmin(true);
$this->client->request('GET', '/databoxes/', array(
$type => $errorMsgId $type => $errorMsgId
)); ));
@@ -61,7 +45,7 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(false); $this->setAdmin(false);
$this->client->request('GET', '/databoxes/'); $this->client->request('GET', '/admin/databoxes/');
} }
/** /**
@@ -71,7 +55,7 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->client->request('POST', '/databoxes/upgrade/'); $this->client->request('POST', '/admin/databoxes/upgrade/');
$this->assertTrue($this->client->getResponse()->isRedirect()); $this->assertTrue($this->client->getResponse()->isRedirect());
} }

View File

@@ -2,40 +2,24 @@
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
use Symfony\Component\HttpKernel\Client;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
protected $app;
protected $client; protected $client;
public function createApplication()
{
$this->app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
$this->app['debug'] = true;
unset($this->app['exception_handler']);
return $this->app;
}
public function setUp()
{
parent::setUp();
$this->client = $this->createClient();
}
/** /**
* Default route test * Default route test
*/ */
public function testRouteDescription() public function testRouteDescription()
{ {
$appbox = $this->app['phraseanet.appbox']; $appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes()); $databox = array_shift($appbox->get_databoxes());
$name = "testtest" . uniqid(); $name = "testtest" . uniqid();
$field = \databox_field::create($databox, $name, false); $field = \databox_field::create(self::$application, $databox, $name, false);
$id = $field->get_id(); $id = $field->get_id();
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( $this->client->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array(
'field_ids' => array($id) 'field_ids' => array($id)
, 'name_' . $id => $name , 'name_' . $id => $name
, 'multi_' . $id => 1 , 'multi_' . $id => 1
@@ -53,20 +37,20 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testPostDelete() public function testPostDelete()
{ {
$appbox = $this->app['phraseanet.appbox']; $appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes()); $databox = array_shift($appbox->get_databoxes());
$name = "test" . uniqid(); $name = "test" . uniqid();
$field = \databox_field::create($databox, $name, false); $field = \databox_field::create(self::$application, $databox, $name, false);
$id = $field->get_id(); $id = $field->get_id();
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( $this->client->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array(
'todelete_ids' => array($id) 'todelete_ids' => array($id)
)); ));
$this->assertTrue($this->client->getResponse()->isRedirect()); $this->assertTrue($this->client->getResponse()->isRedirect());
try { try {
$field = \databox_field::get_instance($databox, $id); $field = \databox_field::get_instance(self::$application, $databox, $id);
$field->delete(); $field->delete();
$this->fail("should raise an exception"); $this->fail("should raise an exception");
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -76,12 +60,12 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testPostCreate() public function testPostCreate()
{ {
$appbox = $this->app['phraseanet.appbox']; $appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes()); $databox = array_shift($appbox->get_databoxes());
$name = 'test' . uniqid(); $name = 'test' . uniqid();
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( $this->client->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array(
'newfield' => $name 'newfield' => $name
)); ));
@@ -104,19 +88,19 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testPostDescriptionException() public function testPostDescriptionException()
{ {
$appbox = $this->app['phraseanet.appbox']; $appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes()); $databox = array_shift($appbox->get_databoxes());
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( $this->client->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array(
'todelete_ids' => array('unknow_id') 'todelete_ids' => array('unknow_id')
)); ));
$this->assertTrue($this->client->getResponse()->isRedirect()); $this->assertTrue($this->client->getResponse()->isRedirect());
$name = "test" . uniqid(); $name = "test" . uniqid();
$field = \databox_field::create($databox, $name, false); $field = \databox_field::create(self::$application, $databox, $name, false);
$id = $field->get_id(); $id = $field->get_id();
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( $this->client->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array(
'field_ids' => array($id) 'field_ids' => array($id)
, 'name_' . $id => $name , 'name_' . $id => $name
, 'multi_' . $id => 1 , 'multi_' . $id => 1
@@ -132,9 +116,9 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$field->delete(); $field->delete();
$name = "test" . uniqid(); $name = "test" . uniqid();
$field = \databox_field::create($databox, $name, false); $field = \databox_field::create(self::$application, $databox, $name, false);
$id = $field->get_id(); $id = $field->get_id();
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( $this->client->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array(
'field_ids' => array($id) 'field_ids' => array($id)
, 'multi_' . $id => 1 , 'multi_' . $id => 1
, 'indexable_' . $id => 1 , 'indexable_' . $id => 1
@@ -149,12 +133,12 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$field->delete(); $field->delete();
$name = "test" . uniqid(); $name = "test" . uniqid();
$field = \databox_field::create($databox, $name, false); $field = \databox_field::create(self::$application, $databox, $name, false);
$field->set_indexable(false); $field->set_indexable(false);
$field->set_required(true); $field->set_required(true);
$field->set_readonly(true); $field->set_readonly(true);
$id = $field->get_id(); $id = $field->get_id();
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( $this->client->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array(
'field_ids' => array($id) 'field_ids' => array($id)
, 'name_' . $id => $name , 'name_' . $id => $name
, 'multi_' . $id => 1 , 'multi_' . $id => 1
@@ -175,9 +159,9 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$name = "test" . uniqid(); $name = "test" . uniqid();
$field = \databox_field::create($databox, $name, false); $field = \databox_field::create(self::$application, $databox, $name, false);
$id = $field->get_id(); $id = $field->get_id();
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( $this->client->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array(
'field_ids' => array('unknow_id') 'field_ids' => array('unknow_id')
, 'name_' . $id => $name , 'name_' . $id => $name
, 'multi_' . $id => 1 , 'multi_' . $id => 1
@@ -195,19 +179,15 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testPostDescriptionRights() public function testPostDescriptionRights()
{ {
$appbox = $this->app['phraseanet.appbox']; $this->setAdmin(false);
$session = $appbox->get_session(); $databox = array_shift(self::$application['phraseanet.appbox']->get_databoxes());
$auth = new Session_Authentication_None(\User_Adapter::getInstance(\User_Adapter::get_usr_id_from_login('invite'), $appbox));
$session->authenticate($auth);
$databox = array_shift($appbox->get_databoxes());
$name = "test" . uniqid(); $name = "test" . uniqid();
$field = \databox_field::create($databox, $name, false); $field = \databox_field::create(self::$application, $databox, $name, false);
$id = $field->get_id(); $id = $field->get_id();
try { try {
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array( $this->client->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array(
'field_ids' => array($id) 'field_ids' => array($id)
, 'name_' . $id => $name , 'name_' . $id => $name
, 'multi_' . $id => 1 , 'multi_' . $id => 1
@@ -218,6 +198,7 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
, 'type_' . $id => 'string' , 'type_' . $id => 'string'
, 'vocabulary_' . $id => 'User' , 'vocabulary_' . $id => 'User'
)); ));
print($this->client->getResponse()->getContent());
$this->fail('Should throw an AccessDeniedException'); $this->fail('Should throw an AccessDeniedException');
} catch (AccessDeniedHttpException $e) { } catch (AccessDeniedHttpException $e) {
@@ -228,16 +209,13 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testGetDescriptionException() public function testGetDescriptionException()
{ {
$appbox = $this->app['phraseanet.appbox']; $this->setAdmin(false);
$appbox = self::$application['phraseanet.appbox'];
$session = $appbox->get_session();
$auth = new Session_Authentication_None(\User_Adapter::getInstance(\User_Adapter::get_usr_id_from_login('invite'), $appbox));
$session->authenticate($auth);
$databox = array_shift($appbox->get_databoxes()); $databox = array_shift($appbox->get_databoxes());
try { try {
$this->client->request("GET", "/description/" . $databox->get_sbas_id() . "/"); $this->client->request("GET", "/admin/description/" . $databox->get_sbas_id() . "/");
$this->fail('Should throw an AccessDeniedException'); $this->fail('Should throw an AccessDeniedException');
} catch (AccessDeniedHttpException $e) { } catch (AccessDeniedHttpException $e) {
@@ -246,25 +224,25 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testGetDescription() public function testGetDescription()
{ {
$appbox = $this->app['phraseanet.appbox']; $appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes()); $databox = array_shift($appbox->get_databoxes());
$this->client->request("GET", "/description/" . $databox->get_sbas_id() . "/"); $this->client->request("GET", "/admin/description/" . $databox->get_sbas_id() . "/");
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
public function testGetMetadatas() public function testGetMetadatas()
{ {
$appbox = $this->app['phraseanet.appbox']; $appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes()); $databox = array_shift($appbox->get_databoxes());
$this->client->request("GET", "/description/metadatas/search/", array('term' => '')); $this->client->request("GET", "/admin/description/metadatas/search/", array('term' => ''));
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
$datas = json_decode($this->client->getResponse()->getContent(), true); $datas = json_decode($this->client->getResponse()->getContent(), true);
$this->assertEquals(array(), $datas); $this->assertEquals(array(), $datas);
$this->client->request("GET", "/description/metadatas/search/", array('term' => 'xmp')); $this->client->request("GET", "/admin/description/metadatas/search/", array('term' => 'xmp'));
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
$datas = json_decode($this->client->getResponse()->getContent(), true); $datas = json_decode($this->client->getResponse()->getContent(), true);

View File

@@ -1,41 +1,25 @@
<?php <?php
use Alchemy\Phrasea\Core\Configuration;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
protected $client;
public function createApplication()
{
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
$app['debug'] = true;
unset($app['exception_handler']);
return $app;
}
public function setUp()
{
parent::setUp();
$this->client = $this->createClient();
}
/** /**
* Default route test * Default route test
*/ */
public function testCheckMulti() public function testCheckMulti()
{ {
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes()); $databox = array_shift($appbox->get_databoxes());
$tag = new PHPExiftool\Driver\Tag\IPTC\ObjectName(); $tag = new PHPExiftool\Driver\Tag\IPTC\ObjectName();
$field = \databox_field::create($databox, "test" . time(), false); $field = \databox_field::create(self::$application, $databox, "test" . time(), false);
$field->set_tag($tag)->save(); $field->set_tag($tag)->save();
$this->client->request("GET", "/fields/checkmulti/", array( $this->client->request("GET", "/admin/fields/checkmulti/", array(
'source' => $tag->getTagname(), 'multi' => 'false')); 'source' => $tag->getTagname(), 'multi' => 'false'));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
@@ -49,15 +33,15 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testCheckReadOnly() public function testCheckReadOnly()
{ {
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes()); $databox = array_shift($appbox->get_databoxes());
$tag = new PHPExiftool\Driver\Tag\IPTC\ObjectName(); $tag = new PHPExiftool\Driver\Tag\IPTC\ObjectName();
$field = \databox_field::create($databox, "test" . time(), false); $field = \databox_field::create(self::$application, $databox, "test" . time(), false);
$field->set_tag($tag)->save(); $field->set_tag($tag)->save();
$this->client->request("GET", "/fields/checkreadonly/", array( $this->client->request("GET", "/admin/fields/checkreadonly/", array(
'source' => $tag->getTagname(), 'readonly' => 'false')); 'source' => $tag->getTagname(), 'readonly' => 'false'));
$response = $this->client->getResponse(); $response = $this->client->getResponse();

View File

@@ -1,9 +1,8 @@
<?php <?php
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; use Alchemy\Phrasea\Core\Configuration;
use Silex\WebTestCase; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
use Symfony\Component\HttpFoundation\Response;
class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthenticatedAbstract class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthenticatedAbstract
{ {
@@ -11,28 +10,12 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public static $api = null; public static $api = null;
protected $client; protected $client;
public function setUp()
{
parent::setUp();
$this->client = $this->createClient();
}
public function createApplication()
{
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
$app['debug'] = true;
unset($app['exception_handler']);
return $app;
}
public function testList() public function testList()
{ {
$crawler = $this->client->request('GET', '/publications/list/'); $crawler = $this->client->request('GET', '/admin/publications/list/');
$pageContent = $this->client->getResponse()->getContent(); $pageContent = $this->client->getResponse()->getContent();
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
$feeds = Feed_Collection::load_all(appbox::get_instance(\bootstrap::getCore()), self::$user); $feeds = Feed_Collection::load_all(self::$application, self::$user);
foreach ($feeds->get_feeds() as $feed) { foreach ($feeds->get_feeds() as $feed) {
$this->assertRegExp('/\/admin\/publications\/feed\/' . $feed->get_id() . '/', $pageContent); $this->assertRegExp('/\/admin\/publications\/feed\/' . $feed->get_id() . '/', $pageContent);
@@ -45,22 +28,22 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testCreate() public function testCreate()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
foreach ($appbox->get_databoxes() as $databox) { // foreach ($appbox->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) { // foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id(); // $base_id = $collection->get_base_id();
break; // break;
} // }
} // }
$feeds = Feed_Collection::load_all($appbox, self::$user); $feeds = Feed_Collection::load_all(self::$application, self::$user);
$count = sizeof($feeds->get_feeds()); $count = sizeof($feeds->get_feeds());
$crawler = $this->client->request('POST', '/publications/create/', array("title" => "hello", "subtitle" => "coucou", "base_id" => $base_id)); $crawler = $this->client->request('POST', '/admin/publications/create/', array("title" => "hello", "subtitle" => "coucou", "base_id" => self::$collection->get_base_id()));
$this->assertTrue($this->client->getResponse()->isRedirect('/admin/publications/list/')); $this->assertTrue($this->client->getResponse()->isRedirect('/admin/publications/list/'));
$feeds = Feed_Collection::load_all(appbox::get_instance(\bootstrap::getCore()), self::$user); $feeds = Feed_Collection::load_all(self::$application, self::$user);
$count_after = sizeof($feeds->get_feeds()); $count_after = sizeof($feeds->get_feeds());
$this->assertGreaterThan($count, $count_after); $this->assertGreaterThan($count, $count_after);
@@ -71,9 +54,9 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testGetFeed() public function testGetFeed()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou'); $feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$crawler = $this->client->request('GET', '/publications/feed/' . $feed->get_id() . '/'); $crawler = $this->client->request('GET', '/admin/publications/feed/' . $feed->get_id() . '/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
$this->assertEquals(1, $crawler->filterXPath("//form[@action='/admin/publications/feed/" . $feed->get_id() . "/update/']")->count()); $this->assertEquals(1, $crawler->filterXPath("//form[@action='/admin/publications/feed/" . $feed->get_id() . "/update/']")->count());
$this->assertEquals(1, $crawler->filterXPath("//input[@value='salut']")->count()); $this->assertEquals(1, $crawler->filterXPath("//input[@value='salut']")->count());
@@ -84,14 +67,14 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testUpdateFeedNotOwner() public function testUpdateFeedNotOwner()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
//is not owner //is not owner
$stub = $this->getMock("user_adapter", array(), array(), "", false); $stub = $this->getMock("user_adapter", array(), array(), "", false);
//return a different userid //return a different userid
$stub->expects($this->any())->method("get_id")->will($this->returnValue(99999999)); $stub->expects($this->any())->method("get_id")->will($this->returnValue(99999999));
$feed = Feed_Adapter::create($appbox, $stub, "salut", 'coucou'); $feed = Feed_Adapter::create(self::$application, $stub, "salut", 'coucou');
$this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/update/"); $this->client->request("POST", "/admin/publications/feed/" . $feed->get_id() . "/update/");
$this->assertTrue($this->client->getResponse()->isRedirect(), 'update fails, i\'m redirected'); $this->assertTrue($this->client->getResponse()->isRedirect(), 'update fails, i\'m redirected');
$this->assertTrue( $this->assertTrue(
strpos( strpos(
@@ -103,17 +86,17 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testUpdatedFeedException() public function testUpdatedFeedException()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou'); $feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/update/", array( $this->client->request("POST", "/admin/publications/feed/" . $feed->get_id() . "/update/", array(
'title' => 'test' 'title' => 'test'
, 'subtitle' => 'test' , 'subtitle' => 'test'
, 'public' => '1' , 'public' => '1'
)); ));
$feed = new Feed_Adapter($appbox, $feed->get_id()); $feed = new Feed_Adapter(self::$application, $feed->get_id());
$this->assertTrue( $this->assertTrue(
strpos( strpos(
@@ -131,11 +114,11 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testUpdatedFeedOwner() public function testUpdatedFeedOwner()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou'); $feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/update/", array( $this->client->request("POST", "/admin/publications/feed/" . $feed->get_id() . "/update/", array(
'title' => 'test' 'title' => 'test'
, 'subtitle' => 'test' , 'subtitle' => 'test'
, 'public' => '1' , 'public' => '1'
@@ -149,7 +132,7 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
) === 0); ) === 0);
$feed = new Feed_Adapter($appbox, $feed->get_id()); $feed = new Feed_Adapter(self::$application, $feed->get_id());
$collection = $feed->get_collection(); $collection = $feed->get_collection();
@@ -169,7 +152,7 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testIconUploadErrorOwner() public function testIconUploadErrorOwner()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
//is not owner //is not owner
$stub = $this->getMock("user_adapter", array(), array(), "", false); $stub = $this->getMock("user_adapter", array(), array(), "", false);
@@ -177,9 +160,9 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
$stub->expects($this->any())->method("get_id")->will($this->returnValue(99999999)); $stub->expects($this->any())->method("get_id")->will($this->returnValue(99999999));
$feed = Feed_Adapter::create($appbox, $stub, "salut", 'coucou'); $feed = Feed_Adapter::create(self::$application, $stub, "salut", 'coucou');
$this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/iconupload/", array(), array(), array('HTTP_ACCEPT'=>'application/json')); $this->client->request("POST", "/admin/publications/feed/" . $feed->get_id() . "/iconupload/", array(), array(), array('HTTP_ACCEPT'=>'application/json'));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
@@ -194,13 +177,13 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testIconUploadErrorFileData() public function testIconUploadErrorFileData()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou'); $feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$this->client->request( $this->client->request(
"POST" "POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/" , "/admin/publications/feed/" . $feed->get_id() . "/iconupload/"
, array() , array()
, array('Filedata' => array('error' => 1)) , array('Filedata' => array('error' => 1))
); );
@@ -216,13 +199,13 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testIconUploadErrorFileType() public function testIconUploadErrorFileType()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou'); $feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$this->client->request( $this->client->request(
"POST" "POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/" , "/admin/publications/feed/" . $feed->get_id() . "/iconupload/"
, array() , array()
, array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../testfiles/test007.ppt')) , array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../testfiles/test007.ppt'))
); );
@@ -238,11 +221,9 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testIconUpload() public function testIconUpload()
{ {
$core = \bootstrap::getCore(); $appbox = self::$application['phraseanet.appbox'];
$appbox = appbox::get_instance($core); $feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
$files = array( $files = array(
'files' => array( 'files' => array(
@@ -254,7 +235,7 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
$this->client->request( $this->client->request(
"POST" "POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/" , "/admin/publications/feed/" . $feed->get_id() . "/iconupload/"
, array() , array()
, $files , $files
); );
@@ -267,25 +248,25 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
$this->assertTrue($content->success); $this->assertTrue($content->success);
$feed = new Feed_Adapter($appbox, $feed->get_id()); $feed = new Feed_Adapter(self::$application, $feed->get_id());
$feed->delete(); $feed->delete();
} }
public function testAddPublisher() public function testAddPublisher()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou'); $feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/addpublisher/", array( $this->client->request("POST", "/admin/publications/feed/" . $feed->get_id() . "/addpublisher/", array(
'usr_id' => self::$user_alt1->get_id() 'usr_id' => self::$user_alt1->get_id()
)); ));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
$feed = new Feed_Adapter($appbox, $feed->get_id()); $feed = new Feed_Adapter(self::$application, $feed->get_id());
$publishers = $feed->get_publishers(); $publishers = $feed->get_publishers();
$this->assertTrue(isset($publishers[self::$user_alt1->get_id()])); $this->assertTrue(isset($publishers[self::$user_alt1->get_id()]));
@@ -300,13 +281,13 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testAddPublisherException() public function testAddPublisherException()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou'); $feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/addpublisher/"); $this->client->request("POST", "/admin/publications/feed/" . $feed->get_id() . "/addpublisher/");
$feed = new Feed_Adapter($appbox, $feed->get_id()); $feed = new Feed_Adapter(self::$application, $feed->get_id());
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
$this->assertTrue( $this->assertTrue(
@@ -320,18 +301,18 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testRemovePublisher() public function testRemovePublisher()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou'); $feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/removepublisher/", array( $this->client->request("POST", "/admin/publications/feed/" . $feed->get_id() . "/removepublisher/", array(
'usr_id' => self::$user_alt1->get_id() 'usr_id' => self::$user_alt1->get_id()
)); ));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
$feed = new Feed_Adapter($appbox, $feed->get_id()); $feed = new Feed_Adapter(self::$application, $feed->get_id());
$publishers = $feed->get_publishers(); $publishers = $feed->get_publishers();
$this->assertFalse(isset($publishers[self::$user_alt1->get_id()])); $this->assertFalse(isset($publishers[self::$user_alt1->get_id()]));
@@ -346,16 +327,16 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testRemovePublisherException() public function testRemovePublisherException()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou'); $feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/removepublisher/"); $this->client->request("POST", "/admin/publications/feed/" . $feed->get_id() . "/removepublisher/");
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
$feed = new Feed_Adapter($appbox, $feed->get_id()); $feed = new Feed_Adapter(self::$application, $feed->get_id());
$this->assertTrue( $this->assertTrue(
strpos( strpos(
@@ -368,17 +349,17 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testDeleteFeed() public function testDeleteFeed()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou'); $feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/delete/"); $this->client->request("POST", "/admin/publications/feed/" . $feed->get_id() . "/delete/");
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
try { try {
$feed = new Feed_Adapter($appbox, $feed->get_id()); $feed = new Feed_Adapter(self::$application, $feed->get_id());
$feed->delete(); $feed->delete();
$this->fail("fail deleting feed"); $this->fail("fail deleting feed");
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@@ -6,31 +6,15 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
protected $client; protected $client;
public function createApplication()
{
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
$app['debug'] = true;
unset($app['exception_handler']);
return $app;
}
public function setUp()
{
parent::setUp();
$this->client = $this->createClient();
}
/** /**
* Default route test * Default route test
*/ */
public function testRouteSlash() public function testRouteSlash()
{ {
$this->client->request('GET', '/', array('section' => 'base:featured')); $this->client->request('GET', '/admin/', array('section' => 'base:featured'));
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
$this->client->request('GET', '/'); $this->client->request('GET', '/admin/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
} }

View File

@@ -6,14 +6,9 @@ class SetupTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
protected $client; protected $client;
public function createApplication() public static function setUpBeforeClass()
{ {
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php'; parent::setUpBeforeClass();
$app['debug'] = true;
unset($app['exception_handler']);
return $app;
} }
/** /**
@@ -21,9 +16,8 @@ class SetupTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testGetSlash() public function testGetSlash()
{ {
$this->setAdmin(true); // $this->setAdmin(true);exit;
$this->client->request('GET', '/admin/setup/');
$this->client->request('GET', '/setup/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
@@ -35,7 +29,7 @@ class SetupTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(false); $this->setAdmin(false);
$this->client->request('GET', '/setup/'); $this->client->request('GET', '/admin/setup/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
@@ -44,9 +38,9 @@ class SetupTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/ */
public function testPostGlobals() public function testPostGlobals()
{ {
$this->setAdmin(true); // $this->setAdmin(true);
$this->client->request('POST', '/setup/'); $this->client->request('POST', '/admin/setup/');
$this->assertTrue($this->client->getResponse()->isRedirect()); $this->assertTrue($this->client->getResponse()->isRedirect());
} }
} }

View File

@@ -5,17 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class SphinxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract class SphinxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
protected $client; protected $client;
protected $StubbedACL;
public function createApplication()
{
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
$app['debug'] = true;
unset($app['exception_handler']);
return $app;
}
/** /**
* @covers Alchemy\Phrasea\Controller\Admin\Sphinx::getConfiguration * @covers Alchemy\Phrasea\Controller\Admin\Sphinx::getConfiguration
@@ -25,7 +14,7 @@ class SphinxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->client->request('GET', '/sphinx/configuration/'); $this->client->request('GET', '/admin/sphinx/configuration/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
@@ -37,7 +26,7 @@ class SphinxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(false); $this->setAdmin(false);
$this->client->request('GET', '/sphinx/configuration/'); $this->client->request('GET', '/admin/sphinx/configuration/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
@@ -48,7 +37,7 @@ class SphinxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->setAdmin(true); $this->setAdmin(true);
$this->client->request('POST', '/sphinx/configuration/'); $this->client->request('POST', '/admin/sphinx/configuration/');
$this->assertTrue($this->client->getResponse()->isRedirect()); $this->assertTrue($this->client->getResponse()->isRedirect());
} }
} }

View File

@@ -5,51 +5,42 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
protected $client; protected $client;
protected $app;
protected $databox; protected $databox;
public function createApplication()
{
$this->app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
$this->app['debug'] = true;
unset($this->app['exception_handler']);
return $this->app;
}
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->client = $this->createClient();
$this->databox = array_shift($this->app['phraseanet.appbox']->get_databoxes()); $this->databox = array_shift($this->app['phraseanet.appbox']->get_databoxes());
} }
/**
* Default route test
*/
public function testRouteGetSubdef()
{
$this->client->request("GET", "/subdefs/" . $this->databox->get_sbas_id() . "/");
$this->assertTrue($this->client->getResponse()->isOk());
}
public function getSubdefName() public function getSubdefName()
{ {
return 'testname' . time() . mt_rand(10000, 99999); return 'testname' . time() . mt_rand(10000, 99999);
} }
/**
* Default route test
*/
public function testRouteGetSubdef()
{
$this->client->request("GET", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/");
$this->assertTrue($this->client->getResponse()->isOk());
}
public function testPostRouteAddSubdef() public function testPostRouteAddSubdef()
{ {
$name = $this->getSubdefName(); $name = $this->getSubdefName();
$this->client->request("POST", "/subdefs/" . $this->databox->get_sbas_id() . "/", array('add_subdef' => array( $this->client->request("POST", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/", array('add_subdef' => array(
'class' => 'thumbnail', 'class' => 'thumbnail',
'name' => $name, 'name' => $name,
'group' => 'image' 'group' => 'image'
))); )));
$this->assertTrue($this->client->getResponse()->isRedirect()); $this->assertTrue($this->client->getResponse()->isRedirect());
$subdefs = $this->databox->get_subdef_structure();
$subdefs->get_subdef("image", $name); $subdefs = new databox_subdefsStructure(new databox(self::$application, $this->databox->get_sbas_id()));
$subdef = $subdefs->get_subdef("image", $name);
$subdefs->delete_subdef('image', $name); $subdefs->delete_subdef('image', $name);
} }
@@ -58,7 +49,7 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$subdefs = $this->databox->get_subdef_structure(); $subdefs = $this->databox->get_subdef_structure();
$name = $this->getSubdefName(); $name = $this->getSubdefName();
$subdefs->add_subdef("image", $name, "thumbnail"); $subdefs->add_subdef("image", $name, "thumbnail");
$this->client->request("POST", "/subdefs/" . $this->databox->get_sbas_id() . "/", array('delete_subdef' => 'image_' . $name)); $this->client->request("POST", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/", array('delete_subdef' => 'image_' . $name));
$this->assertTrue($this->client->getResponse()->isRedirect()); $this->assertTrue($this->client->getResponse()->isRedirect());
try { try {
$subdefs->get_subdef("image", $name); $subdefs->get_subdef("image", $name);
@@ -73,7 +64,7 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$subdefs = $this->databox->get_subdef_structure(); $subdefs = $this->databox->get_subdef_structure();
$name = $this->getSubdefName(); $name = $this->getSubdefName();
$subdefs->add_subdef("image", $name, "thumbnail"); $subdefs->add_subdef("image", $name, "thumbnail");
$this->client->request("POST", "/subdefs/" . $this->databox->get_sbas_id() . "/" $this->client->request("POST", "/admin/subdefs/" . $this->databox->get_sbas_id() . "/"
, array('subdefs' => array( , array('subdefs' => array(
'image_' . $name 'image_' . $name
) )
@@ -89,7 +80,7 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
); );
$this->assertTrue($this->client->getResponse()->isRedirect()); $this->assertTrue($this->client->getResponse()->isRedirect());
$subdefs = new databox_subdefsStructure( $this->databox); $subdefs = new databox_subdefsStructure(new databox(self::$application, $this->databox->get_sbas_id()));
$subdef = $subdefs->get_subdef("image", $name); $subdef = $subdefs->get_subdef("image", $name);
/* @var $subdef \databox_subdef */ /* @var $subdef \databox_subdef */

View File

@@ -1,5 +1,7 @@
<?php <?php
use Alchemy\Phrasea\Core\Configuration;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
@@ -7,50 +9,39 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
protected $client; protected $client;
protected $usersParameters; protected $usersParameters;
public function createApplication()
{
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
$app['debug'] = true;
unset($app['exception_handler']);
return $app;
}
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->usersParameters = array("users" => implode(';', array(self::$user->get_id(), self::$user_alt1->get_id()))); $this->usersParameters = array("users" => implode(';', array(self::$user->get_id(), self::$user_alt1->get_id())));
$this->client = $this->createClient();
} }
public function testRouteRightsPost() public function testRouteRightsPost()
{ {
$this->client->request('POST', '/users/rights/', $this->usersParameters); $this->client->request('POST', '/admin/users/rights/', $this->usersParameters);
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
} }
public function testRouteRightsGet() public function testRouteRightsGet()
{ {
$this->client->request('GET', '/users/rights/', $this->usersParameters); $this->client->request('GET', '/admin/users/rights/', $this->usersParameters);
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
} }
public function testRouteDelete() public function testRouteDelete()
{ {
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$username = uniqid('user_'); $username = uniqid('user_');
$user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false); $user = User_Adapter::create(self::$application, $username, "test", $username . "@email.com", false);
$id = $user->get_id(); $id = $user->get_id();
$this->client->request('POST', '/users/delete/', array('users' => $id)); $this->client->request('POST', '/admin/users/delete/', array('users' => $id));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
try { try {
$user = User_Adapter::getInstance($id, $appbox); $user = User_Adapter::getInstance($id, self::$application);
$user->delete(); $user->delete();
$this->fail("user not deleted"); $this->fail("user not deleted");
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -60,16 +51,16 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteRightsApply() public function testRouteRightsApply()
{ {
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$username = uniqid('user_'); $username = uniqid('user_');
$user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false); $user = User_Adapter::create(self::$application, $username, "test", $username . "@email.com", false);
$base_id = self::$collection->get_base_id(); $base_id = self::$collection->get_base_id();
$_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . self::$collection->get_base_id() . '=1&canpush_' . self::$collection->get_base_id() . '=1'; $_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . self::$collection->get_base_id() . '=1&canpush_' . self::$collection->get_base_id() . '=1';
$_GET['user_infos'] = "user_infos[email]=" . $user->get_email(); $_GET['user_infos'] = "user_infos[email]=" . $user->get_email();
$this->client->request('POST', '/users/rights/apply/', array('users' => $user->get_id())); $this->client->request('POST', '/admin/users/rights/apply/', array('users' => $user->get_id()));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type")); $this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -87,13 +78,13 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{ {
$this->markTestIncomplete(); $this->markTestIncomplete();
$_GET = array(); $_GET = array();
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$username = uniqid('user_'); $username = uniqid('user_');
$user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false); $user = User_Adapter::create(self::$application, $username, "test", $username . "@email.com", false);
$base_id = self::$collection->get_base_id(); $base_id = self::$collection->get_base_id();
$_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . self::$collection->get_base_id() . '=1&canpush_' . self::$collection->get_base_id() . '=1'; $_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . self::$collection->get_base_id() . '=1&canpush_' . self::$collection->get_base_id() . '=1';
$_GET['user_infos'] = "user_infos[email]=" . $user->get_email(); $_GET['user_infos'] = "user_infos[email]=" . $user->get_email();
$this->client->request('POST', '/users/rights/apply/', array('users' => $user->get_id())); $this->client->request('POST', '/admin/users/rights/apply/', array('users' => $user->get_id()));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type")); $this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -108,7 +99,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base())); $base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
$params = array('base_id' => $base_id, 'users' => self::$user->get_id()); $params = array('base_id' => $base_id, 'users' => self::$user->get_id());
$this->client->request('POST', '/users/rights/quotas/', $params); $this->client->request('POST', '/admin/users/rights/quotas/', $params);
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
} }
@@ -118,7 +109,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$params = array( $params = array(
'base_id' => self::$collection->get_base_id() 'base_id' => self::$collection->get_base_id()
, 'quota' => '1', 'droits' => 38, 'restes' => 15); , 'quota' => '1', 'droits' => 38, 'restes' => 15);
$this->client->request('POST', '/users/rights/quotas/apply/', $params); $this->client->request('POST', '/admin/users/rights/quotas/apply/', $params);
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
} }
@@ -128,7 +119,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base())); $base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
$params = array('base_id' => $base_id, 'users' => self::$user->get_id()); $params = array('base_id' => $base_id, 'users' => self::$user->get_id());
$this->client->request('POST', '/users/rights/quotas/apply/', $params); $this->client->request('POST', '/admin/users/rights/quotas/apply/', $params);
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
} }
@@ -138,23 +129,23 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base())); $base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
$params = array('base_id' => $base_id, 'users' => self::$user->get_id()); $params = array('base_id' => $base_id, 'users' => self::$user->get_id());
$this->client->request('POST', '/users/rights/time/', $params); $this->client->request('POST', '/admin/users/rights/time/', $params);
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
} }
public function testRouteRightTimeApply() public function testRouteRightTimeApply()
{ {
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$username = uniqid('user_'); $username = uniqid('user_');
$user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false); $user = User_Adapter::create(self::$application, $username, "test", $username . "@email.com", false);
$base_id = self::$collection->get_base_id(); $base_id = self::$collection->get_base_id();
$date = new \Datetime(); $date = new \Datetime();
$date->modify("-10 days"); $date->modify("-10 days");
$dmin = $date->format(DATE_ATOM); $dmin = $date->format(DATE_ATOM);
$date->modify("+30 days"); $date->modify("+30 days");
$dmax = $date->format(DATE_ATOM); $dmax = $date->format(DATE_ATOM);
$this->client->request('POST', '/users/rights/time/apply/', array('base_id' => $base_id, 'dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->get_id())); $this->client->request('POST', '/admin/users/rights/time/apply/', array('base_id' => $base_id, 'dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->get_id()));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
// $this->assertTrue($user->ACL()->is_limited($base_id)); // $this->assertTrue($user->ACL()->is_limited($base_id));
@@ -166,7 +157,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base())); $base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
$params = array('base_id' => $base_id, 'users' => self::$user->get_id()); $params = array('base_id' => $base_id, 'users' => self::$user->get_id());
$this->client->request('POST', '/users/rights/masks/', $params); $this->client->request('POST', '/admin/users/rights/masks/', $params);
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
} }
@@ -176,8 +167,8 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->markTestIncomplete(); $this->markTestIncomplete();
$base_id = self::$collection->get_base_id(); $base_id = self::$collection->get_base_id();
$username = uniqid('user_'); $username = uniqid('user_');
$user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false); $user = User_Adapter::create(self::$application, $username, "test", $username . "@email.com", false);
$this->client->request('POST', '/users/rights/masks/apply/', array( $this->client->request('POST', '/admin/users/rights/masks/apply/', array(
'base_id' => $base_id, 'vand_and', 'vand_or', 'vxor_or', 'vxor_and' 'base_id' => $base_id, 'vand_and', 'vand_or', 'vxor_or', 'vxor_and'
)); ));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
@@ -187,14 +178,14 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteSearch() public function testRouteSearch()
{ {
$this->client->request('POST', '/users/search/'); $this->client->request('POST', '/admin/users/search/');
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
} }
public function testRoutesearchExport() public function testRoutesearchExport()
{ {
$this->client->request('POST', '/users/search/export/'); $this->client->request('POST', '/admin/users/search/export/');
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
$this->assertEquals("text/plain; charset=UTF-8", $response->headers->get("Content-type")); $this->assertEquals("text/plain; charset=UTF-8", $response->headers->get("Content-type"));
@@ -203,7 +194,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteThSearch() public function testRouteThSearch()
{ {
$this->client->request('GET', '/users/typeahead/search/', array('term' => 'admin')); $this->client->request('GET', '/admin/users/typeahead/search/', array('term' => 'admin'));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type")); $this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -211,16 +202,16 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteApplyTp() public function testRouteApplyTp()
{ {
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$templateName = uniqid('template_'); $templateName = uniqid('template_');
$template = User_Adapter::create($appbox, $templateName, "test", $templateName . "@email.com", false); $template = User_Adapter::create(self::$application, $templateName, "test", $templateName . "@email.com", false);
$template->set_template(self::$user); $template->set_template(self::$user);
$username = uniqid('user_'); $username = uniqid('user_');
$user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false); $user = User_Adapter::create(self::$application, $username, "test", $username . "@email.com", false);
$this->client->request('POST', '/users/apply_template/', array( $this->client->request('POST', '/admin/users/apply_template/', array(
'template' => $template->get_id() 'template' => $template->get_id()
, 'users' => $user->get_id()) , 'users' => $user->get_id())
); );
@@ -234,7 +225,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteCreateException() public function testRouteCreateException()
{ {
$this->client->request('POST', '/users/create/', array('value' => '', 'template' => '1')); $this->client->request('POST', '/admin/users/create/', array('value' => '', 'template' => '1'));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type")); $this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -245,7 +236,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteCreateExceptionUser() public function testRouteCreateExceptionUser()
{ {
$this->client->request('POST', '/users/create/', array('value' => '', 'template' => '0')); $this->client->request('POST', '/admin/users/create/', array('value' => '', 'template' => '0'));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type")); $this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -256,12 +247,12 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteCreateUser() public function testRouteCreateUser()
{ {
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = self::$application['phraseanet.appbox'];
$username = uniqid('user_'); $username = uniqid('user_');
$user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false); $user = User_Adapter::create(self::$application, $username, "test", $username . "@email.com", false);
$this->client->request('POST', '/users/create/', array('value' => $username . "@email.com", 'template' => '0')); $this->client->request('POST', '/admin/users/create/', array('value' => $username . "@email.com", 'template' => '0'));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
@@ -272,7 +263,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertFalse($datas->error); $this->assertFalse($datas->error);
try { try {
$user = \User_Adapter::getInstance((int) $datas->data, $appbox); $user = \User_Adapter::getInstance((int) $datas->data, self::$application);
$user->delete(); $user->delete();
} catch (\Exception $e) { } catch (\Exception $e) {
$this->fail("could not delete created user " . $e->getMessage()); $this->fail("could not delete created user " . $e->getMessage());
@@ -281,7 +272,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteExportCsv() public function testRouteExportCsv()
{ {
$this->client->request('POST', '/users/export/csv/'); $this->client->request('POST', '/admin/users/export/csv/');
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
$this->assertRegexp("#text/csv#", $response->headers->get("content-type")); $this->assertRegexp("#text/csv#", $response->headers->get("content-type"));
@@ -291,9 +282,9 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testResetRights() public function testResetRights()
{ {
$appbox = \appbox::get_instance(self::$core); $appbox = self::$application['phraseanet.appbox'];
$username = uniqid('user_'); $username = uniqid('user_');
$user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false); $user = User_Adapter::create(self::$application, $username, "test", $username . "@email.com", false);
$user->ACL()->give_access_to_sbas(array_keys($appbox->get_databoxes())); $user->ACL()->give_access_to_sbas(array_keys($appbox->get_databoxes()));
@@ -324,7 +315,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
} }
} }
$this->client->request('POST', '/users/rights/reset/', array('users' => $user->get_id())); $this->client->request('POST', '/admin/users/rights/reset/', array('users' => $user->get_id()));
$response = $this->client->getResponse(); $response = $this->client->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type")); $this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -337,28 +328,28 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRenderDemands() public function testRenderDemands()
{ {
$this->client->request('GET', '/users/demands/'); $this->client->request('GET', '/admin/users/demands/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
public function testRenderImportFile() public function testRenderImportFile()
{ {
$this->client->request('GET', '/users/import/file/'); $this->client->request('GET', '/admin/users/import/file/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
public function testGetExampleCSVFile() public function testGetExampleCSVFile()
{ {
$this->client->request('GET', '/users/import/example/csv/'); $this->client->request('GET', '/admin/users/import/example/csv/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }
public function testGetExampleRtfFile() public function testGetExampleRtfFile()
{ {
$this->client->request('GET', '/users/import/example/rtf/'); $this->client->request('GET', '/admin/users/import/example/rtf/');
$this->assertTrue($this->client->getResponse()->isOk()); $this->assertTrue($this->client->getResponse()->isOk());
} }