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;
// /!\ re enable collection
self::$collection->enable(self::$application['phraseanet.appbox']);
@@ -50,7 +49,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
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;
@@ -90,7 +89,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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);
$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());
$this->assertTrue($json->success);
$this->assertEquals($collection->get_name(), 'test_rename_coll');
$collection->unmount_collection($this->app);
$collection->unmount_collection(self::$application);
$collection->delete();
}
@@ -410,7 +409,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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);
if ($collection->get_record_amount() === 0) {
@@ -433,7 +432,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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 = '
INSERT INTO record
(coll_id, record_id, parent_record_id, moddate, credate
@@ -471,7 +470,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$json = $this->getJson($this->client->getResponse());
$this->assertTrue($json->success);
$taskManager = new \task_manager($this->app);
$taskManager = new \task_manager(self::$application);
$tasks = $taskManager->getTasks();
$found = false;
@@ -515,8 +514,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/
public function testSetWatermarkBadRequest()
{
$this->setAdmin(true);
$this->client->request('POST', '/admin/collection/' . self::$collection->get_base_id() . '/picture/watermark/');
}
@@ -539,13 +536,13 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true);
$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(
'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->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()
{
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');
}
@@ -586,7 +583,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true);
$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(
'newWm' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg')
);
@@ -633,7 +630,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true);
$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(
'newStamp' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg')
);
@@ -681,7 +678,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true);
$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(
'newBanner' => new \Symfony\Component\HttpFoundation\File\UploadedFile($target, 'logo.jpg')
);
@@ -809,7 +806,7 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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);
if ($collection->get_record_amount() === 0) {

View File

@@ -90,7 +90,7 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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);

View File

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

View File

@@ -1,5 +1,6 @@
<?php
use Alchemy\Phrasea\Core\Configuration;
use MediaAlchemyst\Alchemyst;
use MediaAlchemyst\DriversContainer;
use Symfony\Component\Filesystem\Filesystem;
@@ -12,26 +13,23 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
protected static $createdCollections = 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;
unset($app['exception_handler']);
return $app;
public function setUp()
{
self::dropDatabase();
parent::setUp();
}
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) {
try {
$collection->unmount_collection($appbox);
$collection->unmount_collection(self::$application);
} catch (\Exception $e) {
}
@@ -43,33 +41,17 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
}
}
foreach (self::$createdDataboxes as $databox) {
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();
self::$createdCollections = null;
parent::tearDownAfterClass();
}
public function tearDown()
{
// self::dropDatabase();
parent::tearDown();
}
public function getJson($response)
{
$this->assertTrue($response->isOk());
@@ -84,55 +66,40 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
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;
return $collection;
}
public function createDatabox($dbName)
public function createDatabox()
{
$registry = $this->app['phraseanet.core']['Registry'];
$registry = self::$application['phraseanet.registry'];
try {
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare(
'DROP DATABASE IF EXISTS `' . $dbName . '`'
);
$this->createDatabase();
$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 ');
}
$configuration = $this->app['phraseanet.core']->getConfiguration();
$configuration = self::$application['phraseanet.configuration'];
$choosenConnexion = $configuration->getPhraseanet()->get('database');
$connexion = $configuration->getConnexion($choosenConnexion);
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) {
$this->markTestSkipped('Could not reach DB');
}
$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;
$databox->registerAdmin($this->app['phraseanet.core']->getAuthenticatedUser());
unset($stmt, $conn);
$databox->registerAdmin(self::$application['phraseanet.user']);
return $databox;
}
@@ -143,6 +110,30 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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::connect
@@ -152,7 +143,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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());
}
@@ -163,7 +154,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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());
}
@@ -172,12 +163,13 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/
public function testSetReorder()
{
$databox = $this->createDatabox('unit_test_db8');
$collection = \collection::create($databox, $this->app['phraseanet.appbox'], 'TESTTODELETE');
$databox = $this->createDatabox();
$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(
2 => $collection->get_base_id()
)));
@@ -202,7 +194,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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->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());
}
@@ -230,7 +222,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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')
));
@@ -251,13 +243,13 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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)
));
$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();
$this->assertEquals($cgus['fr_FR']['value'], $cgusUpdate);
unset($databox);
@@ -271,7 +263,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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->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());
$this->assertTrue($json->success);
@@ -301,7 +293,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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());
}
@@ -312,7 +304,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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());
}
@@ -324,7 +316,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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->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->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->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->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->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()
{
$this->setAdmin(true);
$collection = $this->createOneCollection();
$collection = $this->createOnecollection();
$this->client->request('POST', '/databox/' . $collection->get_sbas_id() . '/reindex/');
$this->client->request('POST', '/admin/databox/' . $collection->get_sbas_id() . '/reindex/');
$this->assertTrue($this->client->getResponse()->isRedirect());
}
@@ -404,7 +394,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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();
$this->assertTrue($response->isOk());
$this->assertEquals('application/json', $response->headers->get('Content-Type'));
@@ -422,7 +412,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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());
}
@@ -434,7 +424,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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
));
@@ -445,7 +435,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertTrue(is_object($content));
$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();
$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());
}
@@ -469,7 +459,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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();
$this->assertTrue($response->isOk());
@@ -488,7 +478,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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'
));
@@ -503,7 +493,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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->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'
));
@@ -524,7 +514,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertTrue(is_object($content));
$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());
}
@@ -535,7 +525,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$this->client->request('POST', '/databox/', array(
$this->client->request('POST', '/admin/databox/', array(
'new_dbname' => ''
));
@@ -551,7 +541,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$this->client->request('POST', '/databox/', array(
$this->client->request('POST', '/admin/databox/', array(
'new_dbname' => 'ééààèè'
));
@@ -567,33 +557,21 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$dbName = 'unit_test_db';
$this->createDatabase();
try {
$stmt = $this->app['phraseanet.appbox']->get_connection()->prepare('DROP DATABASE IF EXISTS `' . $dbName . '`');
$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,
$this->client->request('POST', '/admin/databox/', array(
'new_dbname' => 'unit_test_db',
'new_data_template' => 'fr-simple',
));
$response = $this->client->getResponse();
$this->assertTrue($response->isRedirect());
$uriRedirect = $response->headers->get('location');
$this->assertTrue( ! ! strrpos($uriRedirect, 'success=1'));
$this->assertTrue(!!strrpos($uriRedirect, 'success=1'));
$explode = explode('/', $uriRedirect);
$databoxId = $explode[3];
$databox = $this->app['phraseanet.appbox']->get_databox($databoxId);
$databox->unmount_databox($this->app['phraseanet.appbox']);
$databox = self::$application['phraseanet.appbox']->get_databox($databoxId);
$databox->unmount_databox(self::$application['phraseanet.appbox']);
$databox->delete();
unset($stmt, $databox);
@@ -606,16 +584,16 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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());
$this->assertTrue($json->success);
$this->assertObjectHasAttribute('sbas_id', $json);
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');
} catch (\Exception_DataboxNotFound $e) {
@@ -629,11 +607,11 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$base = $this->createDatabox('unit_test_db3');
$base->unmount_databox($this->app['phraseanet.appbox']);
$base = $this->createDatabox();
$base->unmount_databox(self::$application['phraseanet.appbox']);
$this->client->request('POST', '/databox/mount/', array(
'new_dbname' => 'unit_test_db3'
$this->client->request('POST', '/admin/databox/mount/', array(
'new_dbname' => 'unit_test_db'
));
$response = $this->client->getResponse();
@@ -642,13 +620,13 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$uriRedirect = $response->headers->get('location');
$this->assertTrue( ! ! strrpos($uriRedirect, 'success=1'));
$this->assertTrue(!!strrpos($uriRedirect, 'success=1'));
$explode = explode('/', $uriRedirect);
$databoxId = $explode[3];
try {
$databox = $this->app['phraseanet.appbox']->get_databox($databoxId);
$databox->unmount_databox($this->app['phraseanet.appbox']);
$databox = self::$application['phraseanet.appbox']->get_databox($databoxId);
$databox->unmount_databox(self::$application['phraseanet.appbox']);
$databox->delete();
} catch (\Exception_DataboxNotFound $e) {
$this->fail('databox not mounted');
@@ -666,9 +644,9 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true);
$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()
));
@@ -683,11 +661,11 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->setAdmin(true);
$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(
'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->assertNotEmpty(\databox::getPrintLogo(self::$collection->get_sbas_id()));
}
@@ -703,7 +681,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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());
$this->assertTrue($json->success);
@@ -717,16 +695,16 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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());
$this->assertTrue($json->success);
$this->assertObjectHasAttribute('sbas_id', $json);
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');
} catch (\Exception_DataboxNotFound $e) {
@@ -743,17 +721,17 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$base = $this->createDatabox('unit_test_db6');
$collection = \collection::create($base, $this->app['phraseanet.appbox'], 'TESTTODELETE');
$base = $this->createDatabox();
$collection = \collection::create(self::$application, $base, self::$application['phraseanet.appbox'], 'TESTTODELETE');
self::$createdCollections[] = $collection;
$file = new \Alchemy\Phrasea\Border\File($this->app['phraseanet.core']['mediavorus']->guess(new \SplFileInfo(__DIR__ . '/../../../../testfiles/test001.CR2')), $collection);
\record_adapter::createFromFile($file, new Filesystem());
$file = new \Alchemy\Phrasea\Border\File(self::$application['mediavorus']->guess(__DIR__ . '/../../../../testfiles/test001.CR2'), $collection);
\record_adapter::createFromFile($file, self::$application);
if ($collection->get_record_amount() === 0) {
$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());
$this->assertTrue($json->success);
@@ -767,8 +745,8 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$base = $this->createDatabox('unit_test_db7');
$collection = \collection::create($base, $this->app['phraseanet.appbox'], 'TESTTODELETE');
$base = $this->createDatabox();
$collection = \collection::create(self::$application, $base, self::$application['phraseanet.appbox'], 'TESTTODELETE');
self::$createdCollections[] = $collection;
$sql = 'INSERT INTO record
@@ -791,7 +769,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
':originalname' => null,
':mime' => null,
));
$i ++;
$i++;
}
$stmt->closeCursor();
@@ -800,13 +778,13 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$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());
$this->assertTrue($json->success);
$taskManager = new \task_manager($this->app['phraseanet.appbox']);
$tasks = $taskManager->getTasks($this->app);
$taskManager = new \task_manager(self::$application);
$tasks = $taskManager->getTasks();
$found = false;
foreach ($tasks as $task) {
@@ -816,7 +794,7 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
}
}
if ( ! $found) {
if (!$found) {
$this->fail('Task for empty collection has not been created');
}
}

View File

@@ -6,16 +6,6 @@ class DataboxesTest 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;
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Databases::getDatabases
* @covers Alchemy\Phrasea\Controller\Admin\Databases::connect
@@ -23,13 +13,7 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
*/
public function testGetSlash($type, $errorMsgId)
{
$this->StubbedACL->expects($this->any())
->method('get_granted_sbas')
->will($this->returnValue(array(self::$collection->get_sbas_id())));
$this->setAdmin(true);
$this->client->request('GET', '/databoxes/', array(
$this->client->request('GET', '/admin/databoxes/', array(
$type => $errorMsgId
));
@@ -61,7 +45,7 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$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->client->request('POST', '/databoxes/upgrade/');
$this->client->request('POST', '/admin/databoxes/upgrade/');
$this->assertTrue($this->client->getResponse()->isRedirect());
}

View File

@@ -2,40 +2,24 @@
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
use Symfony\Component\HttpKernel\Client;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $app;
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
*/
public function testRouteDescription()
{
$appbox = $this->app['phraseanet.appbox'];
$appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes());
$name = "testtest" . uniqid();
$field = \databox_field::create($databox, $name, false);
$field = \databox_field::create(self::$application, $databox, $name, false);
$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)
, 'name_' . $id => $name
, 'multi_' . $id => 1
@@ -53,20 +37,20 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testPostDelete()
{
$appbox = $this->app['phraseanet.appbox'];
$appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes());
$name = "test" . uniqid();
$field = \databox_field::create($databox, $name, false);
$field = \databox_field::create(self::$application, $databox, $name, false);
$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)
));
$this->assertTrue($this->client->getResponse()->isRedirect());
try {
$field = \databox_field::get_instance($databox, $id);
$field = \databox_field::get_instance(self::$application, $databox, $id);
$field->delete();
$this->fail("should raise an exception");
} catch (\Exception $e) {
@@ -76,12 +60,12 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testPostCreate()
{
$appbox = $this->app['phraseanet.appbox'];
$appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes());
$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
));
@@ -104,19 +88,19 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testPostDescriptionException()
{
$appbox = $this->app['phraseanet.appbox'];
$appbox = self::$application['phraseanet.appbox'];
$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')
));
$this->assertTrue($this->client->getResponse()->isRedirect());
$name = "test" . uniqid();
$field = \databox_field::create($databox, $name, false);
$field = \databox_field::create(self::$application, $databox, $name, false);
$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)
, 'name_' . $id => $name
, 'multi_' . $id => 1
@@ -132,9 +116,9 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$field->delete();
$name = "test" . uniqid();
$field = \databox_field::create($databox, $name, false);
$field = \databox_field::create(self::$application, $databox, $name, false);
$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)
, 'multi_' . $id => 1
, 'indexable_' . $id => 1
@@ -149,12 +133,12 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$field->delete();
$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_required(true);
$field->set_readonly(true);
$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)
, 'name_' . $id => $name
, 'multi_' . $id => 1
@@ -175,9 +159,9 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$name = "test" . uniqid();
$field = \databox_field::create($databox, $name, false);
$field = \databox_field::create(self::$application, $databox, $name, false);
$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')
, 'name_' . $id => $name
, 'multi_' . $id => 1
@@ -195,19 +179,15 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testPostDescriptionRights()
{
$appbox = $this->app['phraseanet.appbox'];
$this->setAdmin(false);
$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(self::$application['phraseanet.appbox']->get_databoxes());
$name = "test" . uniqid();
$field = \databox_field::create($databox, $name, false);
$field = \databox_field::create(self::$application, $databox, $name, false);
$id = $field->get_id();
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)
, 'name_' . $id => $name
, 'multi_' . $id => 1
@@ -218,6 +198,7 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
, 'type_' . $id => 'string'
, 'vocabulary_' . $id => 'User'
));
print($this->client->getResponse()->getContent());
$this->fail('Should throw an AccessDeniedException');
} catch (AccessDeniedHttpException $e) {
@@ -228,16 +209,13 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testGetDescriptionException()
{
$appbox = $this->app['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);
$this->setAdmin(false);
$appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes());
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');
} catch (AccessDeniedHttpException $e) {
@@ -246,25 +224,25 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testGetDescription()
{
$appbox = $this->app['phraseanet.appbox'];
$appbox = self::$application['phraseanet.appbox'];
$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());
}
public function testGetMetadatas()
{
$appbox = $this->app['phraseanet.appbox'];
$appbox = self::$application['phraseanet.appbox'];
$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());
$datas = json_decode($this->client->getResponse()->getContent(), true);
$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());
$datas = json_decode($this->client->getResponse()->getContent(), true);

View File

@@ -1,41 +1,25 @@
<?php
use Alchemy\Phrasea\Core\Configuration;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
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
*/
public function testCheckMulti()
{
$appbox = \appbox::get_instance(\bootstrap::getCore());
$appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes());
$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();
$this->client->request("GET", "/fields/checkmulti/", array(
$this->client->request("GET", "/admin/fields/checkmulti/", array(
'source' => $tag->getTagname(), 'multi' => 'false'));
$response = $this->client->getResponse();
@@ -49,15 +33,15 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testCheckReadOnly()
{
$appbox = \appbox::get_instance(\bootstrap::getCore());
$appbox = self::$application['phraseanet.appbox'];
$databox = array_shift($appbox->get_databoxes());
$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();
$this->client->request("GET", "/fields/checkreadonly/", array(
$this->client->request("GET", "/admin/fields/checkreadonly/", array(
'source' => $tag->getTagname(), 'readonly' => 'false'));
$response = $this->client->getResponse();

View File

@@ -1,9 +1,8 @@
<?php
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
use Alchemy\Phrasea\Core\Configuration;
use Silex\WebTestCase;
use Symfony\Component\HttpFoundation\Response;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthenticatedAbstract
{
@@ -11,28 +10,12 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public static $api = null;
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()
{
$crawler = $this->client->request('GET', '/publications/list/');
$crawler = $this->client->request('GET', '/admin/publications/list/');
$pageContent = $this->client->getResponse()->getContent();
$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) {
$this->assertRegExp('/\/admin\/publications\/feed\/' . $feed->get_id() . '/', $pageContent);
@@ -45,22 +28,22 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testCreate()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$appbox = self::$application['phraseanet.appbox'];
foreach ($appbox->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) {
$base_id = $collection->get_base_id();
break;
}
}
$feeds = Feed_Collection::load_all($appbox, self::$user);
// foreach ($appbox->get_databoxes() as $databox) {
// foreach ($databox->get_collections() as $collection) {
// $base_id = $collection->get_base_id();
// break;
// }
// }
$feeds = Feed_Collection::load_all(self::$application, self::$user);
$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/'));
$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());
$this->assertGreaterThan($count, $count_after);
@@ -71,9 +54,9 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testGetFeed()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
$crawler = $this->client->request('GET', '/publications/feed/' . $feed->get_id() . '/');
$appbox = self::$application['phraseanet.appbox'];
$feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$crawler = $this->client->request('GET', '/admin/publications/feed/' . $feed->get_id() . '/');
$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("//input[@value='salut']")->count());
@@ -84,14 +67,14 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testUpdateFeedNotOwner()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$appbox = self::$application['phraseanet.appbox'];
//is not owner
$stub = $this->getMock("user_adapter", array(), array(), "", false);
//return a different userid
$stub->expects($this->any())->method("get_id")->will($this->returnValue(99999999));
$feed = Feed_Adapter::create($appbox, $stub, "salut", 'coucou');
$this->client->request("POST", "/publications/feed/" . $feed->get_id() . "/update/");
$feed = Feed_Adapter::create(self::$application, $stub, "salut", 'coucou');
$this->client->request("POST", "/admin/publications/feed/" . $feed->get_id() . "/update/");
$this->assertTrue($this->client->getResponse()->isRedirect(), 'update fails, i\'m redirected');
$this->assertTrue(
strpos(
@@ -103,17 +86,17 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
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'
, 'subtitle' => 'test'
, 'public' => '1'
));
$feed = new Feed_Adapter($appbox, $feed->get_id());
$feed = new Feed_Adapter(self::$application, $feed->get_id());
$this->assertTrue(
strpos(
@@ -131,11 +114,11 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
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'
, 'subtitle' => 'test'
, 'public' => '1'
@@ -149,7 +132,7 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
) === 0);
$feed = new Feed_Adapter($appbox, $feed->get_id());
$feed = new Feed_Adapter(self::$application, $feed->get_id());
$collection = $feed->get_collection();
@@ -169,7 +152,7 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
public function testIconUploadErrorOwner()
{
$appbox = appbox::get_instance(\bootstrap::getCore());
$appbox = self::$application['phraseanet.appbox'];
//is not owner
$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));
$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();
@@ -194,13 +177,13 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
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(
"POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/"
, "/admin/publications/feed/" . $feed->get_id() . "/iconupload/"
, array()
, array('Filedata' => array('error' => 1))
);
@@ -216,13 +199,13 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
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(
"POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/"
, "/admin/publications/feed/" . $feed->get_id() . "/iconupload/"
, array()
, 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()
{
$core = \bootstrap::getCore();
$appbox = self::$application['phraseanet.appbox'];
$appbox = appbox::get_instance($core);
$feed = Feed_Adapter::create($appbox, self::$user, "salut", 'coucou');
$feed = Feed_Adapter::create(self::$application, self::$user, "salut", 'coucou');
$files = array(
'files' => array(
@@ -254,7 +235,7 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
$this->client->request(
"POST"
, "/publications/feed/" . $feed->get_id() . "/iconupload/"
, "/admin/publications/feed/" . $feed->get_id() . "/iconupload/"
, array()
, $files
);
@@ -267,25 +248,25 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
$this->assertTrue($content->success);
$feed = new Feed_Adapter($appbox, $feed->get_id());
$feed = new Feed_Adapter(self::$application, $feed->get_id());
$feed->delete();
}
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()
));
$response = $this->client->getResponse();
$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();
$this->assertTrue(isset($publishers[self::$user_alt1->get_id()]));
@@ -300,13 +281,13 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
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();
$this->assertTrue($response->isRedirect());
$this->assertTrue(
@@ -320,18 +301,18 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
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()
));
$response = $this->client->getResponse();
$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();
$this->assertFalse(isset($publishers[self::$user_alt1->get_id()]));
@@ -346,16 +327,16 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
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();
$this->assertTrue($response->isRedirect());
$feed = new Feed_Adapter($appbox, $feed->get_id());
$feed = new Feed_Adapter(self::$application, $feed->get_id());
$this->assertTrue(
strpos(
@@ -368,17 +349,17 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
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();
$this->assertTrue($response->isRedirect());
try {
$feed = new Feed_Adapter($appbox, $feed->get_id());
$feed = new Feed_Adapter(self::$application, $feed->get_id());
$feed->delete();
$this->fail("fail deleting feed");
} catch (\Exception $e) {

View File

@@ -6,31 +6,15 @@ class RootTest 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
*/
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->client->request('GET', '/');
$this->client->request('GET', '/admin/');
$this->assertTrue($this->client->getResponse()->isOk());
}
}

View File

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

View File

@@ -5,17 +5,6 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class SphinxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
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
@@ -25,7 +14,7 @@ class SphinxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$this->client->request('GET', '/sphinx/configuration/');
$this->client->request('GET', '/admin/sphinx/configuration/');
$this->assertTrue($this->client->getResponse()->isOk());
}
@@ -37,7 +26,7 @@ class SphinxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(false);
$this->client->request('GET', '/sphinx/configuration/');
$this->client->request('GET', '/admin/sphinx/configuration/');
$this->assertTrue($this->client->getResponse()->isOk());
}
@@ -48,7 +37,7 @@ class SphinxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->setAdmin(true);
$this->client->request('POST', '/sphinx/configuration/');
$this->client->request('POST', '/admin/sphinx/configuration/');
$this->assertTrue($this->client->getResponse()->isRedirect());
}
}

View File

@@ -5,51 +5,42 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
protected $client;
protected $app;
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()
{
parent::setUp();
$this->client = $this->createClient();
$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()
{
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()
{
$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',
'name' => $name,
'group' => 'image'
)));
$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);
}
@@ -58,7 +49,7 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$subdefs = $this->databox->get_subdef_structure();
$name = $this->getSubdefName();
$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());
try {
$subdefs->get_subdef("image", $name);
@@ -73,7 +64,7 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$subdefs = $this->databox->get_subdef_structure();
$name = $this->getSubdefName();
$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(
'image_' . $name
)
@@ -89,7 +80,7 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
);
$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);
/* @var $subdef \databox_subdef */

View File

@@ -1,5 +1,7 @@
<?php
use Alchemy\Phrasea\Core\Configuration;
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
@@ -7,50 +9,39 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
protected $client;
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()
{
parent::setUp();
$this->usersParameters = array("users" => implode(';', array(self::$user->get_id(), self::$user_alt1->get_id())));
$this->client = $this->createClient();
}
public function testRouteRightsPost()
{
$this->client->request('POST', '/users/rights/', $this->usersParameters);
$this->client->request('POST', '/admin/users/rights/', $this->usersParameters);
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
}
public function testRouteRightsGet()
{
$this->client->request('GET', '/users/rights/', $this->usersParameters);
$this->client->request('GET', '/admin/users/rights/', $this->usersParameters);
$response = $this->client->getResponse();
$this->assertTrue($response->isOk());
}
public function testRouteDelete()
{
$appbox = \appbox::get_instance(\bootstrap::getCore());
$appbox = self::$application['phraseanet.appbox'];
$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();
$this->client->request('POST', '/users/delete/', array('users' => $id));
$this->client->request('POST', '/admin/users/delete/', array('users' => $id));
$response = $this->client->getResponse();
$this->assertTrue($response->isRedirect());
try {
$user = User_Adapter::getInstance($id, $appbox);
$user = User_Adapter::getInstance($id, self::$application);
$user->delete();
$this->fail("user not deleted");
} catch (\Exception $e) {
@@ -60,16 +51,16 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteRightsApply()
{
$appbox = \appbox::get_instance(\bootstrap::getCore());
$appbox = self::$application['phraseanet.appbox'];
$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();
$_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();
$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();
$this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -87,13 +78,13 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
{
$this->markTestIncomplete();
$_GET = array();
$appbox = \appbox::get_instance(\bootstrap::getCore());
$appbox = self::$application['phraseanet.appbox'];
$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();
$_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();
$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();
$this->assertTrue($response->isOK());
$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()));
$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();
$this->assertTrue($response->isOK());
}
@@ -118,7 +109,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$params = array(
'base_id' => self::$collection->get_base_id()
, '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();
$this->assertTrue($response->isOK());
}
@@ -128,7 +119,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
$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();
$this->assertTrue($response->isOK());
}
@@ -138,23 +129,23 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$base_id = array_pop(array_keys(self::$user->ACL()->get_granted_base()));
$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();
$this->assertTrue($response->isOK());
}
public function testRouteRightTimeApply()
{
$appbox = \appbox::get_instance(\bootstrap::getCore());
$appbox = self::$application['phraseanet.appbox'];
$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();
$date = new \Datetime();
$date->modify("-10 days");
$dmin = $date->format(DATE_ATOM);
$date->modify("+30 days");
$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();
$this->assertTrue($response->isOK());
// $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()));
$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();
$this->assertTrue($response->isOK());
}
@@ -176,8 +167,8 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->markTestIncomplete();
$base_id = self::$collection->get_base_id();
$username = uniqid('user_');
$user = User_Adapter::create($appbox, $username, "test", $username . "@email.com", false);
$this->client->request('POST', '/users/rights/masks/apply/', array(
$user = User_Adapter::create(self::$application, $username, "test", $username . "@email.com", false);
$this->client->request('POST', '/admin/users/rights/masks/apply/', array(
'base_id' => $base_id, 'vand_and', 'vand_or', 'vxor_or', 'vxor_and'
));
$response = $this->client->getResponse();
@@ -187,14 +178,14 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteSearch()
{
$this->client->request('POST', '/users/search/');
$this->client->request('POST', '/admin/users/search/');
$response = $this->client->getResponse();
$this->assertTrue($response->isOK());
}
public function testRoutesearchExport()
{
$this->client->request('POST', '/users/search/export/');
$this->client->request('POST', '/admin/users/search/export/');
$response = $this->client->getResponse();
$this->assertTrue($response->isOK());
$this->assertEquals("text/plain; charset=UTF-8", $response->headers->get("Content-type"));
@@ -203,7 +194,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
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();
$this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -211,16 +202,16 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteApplyTp()
{
$appbox = \appbox::get_instance(\bootstrap::getCore());
$appbox = self::$application['phraseanet.appbox'];
$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);
$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()
, 'users' => $user->get_id())
);
@@ -234,7 +225,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
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();
$this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -245,7 +236,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
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();
$this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -256,12 +247,12 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteCreateUser()
{
$appbox = \appbox::get_instance(\bootstrap::getCore());
$appbox = self::$application['phraseanet.appbox'];
$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();
@@ -272,7 +263,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertFalse($datas->error);
try {
$user = \User_Adapter::getInstance((int) $datas->data, $appbox);
$user = \User_Adapter::getInstance((int) $datas->data, self::$application);
$user->delete();
} catch (\Exception $e) {
$this->fail("could not delete created user " . $e->getMessage());
@@ -281,7 +272,7 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRouteExportCsv()
{
$this->client->request('POST', '/users/export/csv/');
$this->client->request('POST', '/admin/users/export/csv/');
$response = $this->client->getResponse();
$this->assertTrue($response->isOK());
$this->assertRegexp("#text/csv#", $response->headers->get("content-type"));
@@ -291,9 +282,9 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testResetRights()
{
$appbox = \appbox::get_instance(self::$core);
$appbox = self::$application['phraseanet.appbox'];
$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()));
@@ -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();
$this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -337,28 +328,28 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function testRenderDemands()
{
$this->client->request('GET', '/users/demands/');
$this->client->request('GET', '/admin/users/demands/');
$this->assertTrue($this->client->getResponse()->isOk());
}
public function testRenderImportFile()
{
$this->client->request('GET', '/users/import/file/');
$this->client->request('GET', '/admin/users/import/file/');
$this->assertTrue($this->client->getResponse()->isOk());
}
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());
}
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());
}