mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Merge branch '4.0'
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
language: php
|
language: php
|
||||||
sudo: require
|
sudo: require
|
||||||
|
|
||||||
|
branches:
|
||||||
|
except:
|
||||||
|
- /^3\..*$/
|
||||||
|
- /^scrutinizer-.*$/
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
@@ -37,8 +42,8 @@ before_install:
|
|||||||
- echo "extension=zmq.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
- echo "extension=zmq.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||||
- yes | pecl install imagick-beta
|
- yes | pecl install imagick-beta
|
||||||
install:
|
install:
|
||||||
- if [[ $TRAVIS_PHP_VERSION = 5.* ]];then travis_retry composer install --optimize-autoloader --prefer-source; fi;
|
- if [[ $TRAVIS_PHP_VERSION = 5.* ]];then travis_retry composer install --no-progress --no-interaction --optimize-autoloader; fi;
|
||||||
- if [[ $TRAVIS_PHP_VERSION = 7.* ]];then travis_retry composer remove --no-update phpunit/phpunit; travis_retry composer require --dev phpunit/phpunit --sort-packages --optimize-autoloader --update-with-dependencies --prefer-source; fi;
|
- if [[ $TRAVIS_PHP_VERSION = 7.* ]];then travis_retry composer remove --no-update phpunit/phpunit; travis_retry composer require --dev phpunit/phpunit --sort-packages --optimize-autoloader --update-with-dependencies --no-progress --no-interaction; fi;
|
||||||
- travis_retry npm install
|
- travis_retry npm install
|
||||||
before_script:
|
before_script:
|
||||||
- mysql -e 'CREATE DATABASE update39_test;CREATE DATABASE ab_test;CREATE DATABASE db_test;SET @@global.sql_mode=STRICT_ALL_TABLES;SET @@global.max_allowed_packet=33554432;SET @@global.wait_timeout=999999;'
|
- mysql -e 'CREATE DATABASE update39_test;CREATE DATABASE ab_test;CREATE DATABASE db_test;SET @@global.sql_mode=STRICT_ALL_TABLES;SET @@global.max_allowed_packet=33554432;SET @@global.wait_timeout=999999;'
|
||||||
|
@@ -19,13 +19,14 @@ dependencies:
|
|||||||
cache_directories:
|
cache_directories:
|
||||||
- elasticsearch-1.6.0 # relative to the build directory
|
- elasticsearch-1.6.0 # relative to the build directory
|
||||||
- node_modules
|
- node_modules
|
||||||
|
- ~/.composer
|
||||||
pre:
|
pre:
|
||||||
- yes '' | pecl install imagick
|
- yes '' | pecl install imagick
|
||||||
- pecl install json
|
- pecl install json
|
||||||
- yes '' | pecl install zmq-beta
|
- yes '' | pecl install zmq-beta
|
||||||
- sed -i 's/^\(session.cache_limiter = \).*/\1""/' ~/.phpenv/versions/$(phpenv global)/etc/php.ini
|
- sed -i 's/^\(session.cache_limiter = \).*/\1""/' ~/.phpenv/versions/$(phpenv global)/etc/php.ini
|
||||||
override:
|
override:
|
||||||
- composer install --prefer-source --no-interaction
|
- composer install --no-progress --no-interaction --optimize-autoloader
|
||||||
post:
|
post:
|
||||||
- npm install
|
- npm install
|
||||||
- if [[ ! -e elasticsearch-1.6.0 ]]; then wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.6.0.tar.gz && tar -xvf elasticsearch-1.6.0.tar.gz && elasticsearch-1.6.0/bin/plugin install elasticsearch/elasticsearch-analysis-icu/2.6.0; fi
|
- if [[ ! -e elasticsearch-1.6.0 ]]; then wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.6.0.tar.gz && tar -xvf elasticsearch-1.6.0.tar.gz && elasticsearch-1.6.0/bin/plugin install elasticsearch/elasticsearch-analysis-icu/2.6.0; fi
|
||||||
|
@@ -42,7 +42,7 @@ class Linkedin extends AbstractProvider
|
|||||||
/**
|
/**
|
||||||
* @param ClientInterface $client
|
* @param ClientInterface $client
|
||||||
*
|
*
|
||||||
* @return Github
|
* @return Linkedin
|
||||||
*/
|
*/
|
||||||
public function setGuzzleClient(ClientInterface $client)
|
public function setGuzzleClient(ClientInterface $client)
|
||||||
{
|
{
|
||||||
|
@@ -42,7 +42,8 @@ class Colorspace extends AbstractChecker
|
|||||||
$boolean = true; //bypass color if empty array
|
$boolean = true; //bypass color if empty array
|
||||||
} elseif (method_exists($file->getMedia(), 'getColorSpace')) {
|
} elseif (method_exists($file->getMedia(), 'getColorSpace')) {
|
||||||
$colorspace = null;
|
$colorspace = null;
|
||||||
switch ($file->getMedia()->getColorSpace()) {
|
switch ($file->getMedia()->getColorSpace())
|
||||||
|
{
|
||||||
case \MediaVorus\Media\Image::COLORSPACE_CMYK:
|
case \MediaVorus\Media\Image::COLORSPACE_CMYK:
|
||||||
$colorspace = self::COLORSPACE_CMYK;
|
$colorspace = self::COLORSPACE_CMYK;
|
||||||
break;
|
break;
|
||||||
|
@@ -44,7 +44,7 @@ class Filename extends AbstractChecker
|
|||||||
*/
|
*/
|
||||||
public function check(EntityManager $em, File $file)
|
public function check(EntityManager $em, File $file)
|
||||||
{
|
{
|
||||||
$boolean = ! count(\record_adapter::get_records_by_originalname(
|
$boolean = empty(\record_adapter::get_records_by_originalname(
|
||||||
$file->getCollection()->get_databox(), $file->getOriginalName(), $this->sensitive, 0, 1
|
$file->getCollection()->get_databox(), $file->getOriginalName(), $this->sensitive, 0, 1
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@ class Sha256 extends AbstractChecker
|
|||||||
*/
|
*/
|
||||||
public function check(EntityManager $em, File $file)
|
public function check(EntityManager $em, File $file)
|
||||||
{
|
{
|
||||||
$boolean = ! count($file->getCollection()->get_databox()->getRecordRepository()->findBySha256($file->getSha256()));
|
$boolean = empty($file->getCollection()->get_databox()->getRecordRepository()->findBySha256($file->getSha256()));
|
||||||
|
|
||||||
return new Response($boolean, $this);
|
return new Response($boolean, $this);
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ class UUID extends AbstractChecker
|
|||||||
*/
|
*/
|
||||||
public function check(EntityManager $em, File $file)
|
public function check(EntityManager $em, File $file)
|
||||||
{
|
{
|
||||||
$boolean = ! count($file->getCollection()->get_databox()->getRecordRepository()->findByUuid($file->getUUID()));
|
$boolean = empty($file->getCollection()->get_databox()->getRecordRepository()->findByUuid($file->getUUID()));
|
||||||
|
|
||||||
return new Response($boolean, $this);
|
return new Response($boolean, $this);
|
||||||
}
|
}
|
||||||
|
@@ -152,7 +152,8 @@ class File
|
|||||||
*/
|
*/
|
||||||
public function getType()
|
public function getType()
|
||||||
{
|
{
|
||||||
switch ($this->media->getType()) {
|
switch ($this->media->getType())
|
||||||
|
{
|
||||||
case MediaInterface::TYPE_AUDIO:
|
case MediaInterface::TYPE_AUDIO:
|
||||||
return new Audio();
|
return new Audio();
|
||||||
break;
|
break;
|
||||||
|
@@ -95,17 +95,28 @@ class Manager
|
|||||||
return $cache;
|
return $cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param string $label
|
||||||
|
*/
|
||||||
private function register($name, $label)
|
private function register($name, $label)
|
||||||
{
|
{
|
||||||
$this->registry[$label] = $name;
|
$this->registry[$label] = $name;
|
||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @param string $label
|
||||||
|
*/
|
||||||
private function isAlreadyRegistered($name, $label)
|
private function isAlreadyRegistered($name, $label)
|
||||||
{
|
{
|
||||||
return isset($this->registry[$label]) && $name === $this->registry[$label];
|
return isset($this->registry[$label]) && $name === $this->registry[$label];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $label
|
||||||
|
*/
|
||||||
private function isAlreadyLoaded($label)
|
private function isAlreadyLoaded($label)
|
||||||
{
|
{
|
||||||
return isset($this->drivers[$label]);
|
return isset($this->drivers[$label]);
|
||||||
|
@@ -146,7 +146,7 @@ class Firewall
|
|||||||
|
|
||||||
public function requireOrdersAdmin()
|
public function requireOrdersAdmin()
|
||||||
{
|
{
|
||||||
if (false === !!count($this->app->getAclForUser($this->app->getAuthenticatedUser())->get_granted_base(['order_master']))) {
|
if (empty($this->app->getAclForUser($this->app->getAuthenticatedUser())->get_granted_base(['order_master']))) {
|
||||||
$this->app->abort(403, 'You are not an order admin');
|
$this->app->abort(403, 'You are not an order admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ class eventsmanager_notify_uploadquarantine extends eventsmanager_notifyAbstract
|
|||||||
|
|
||||||
$text = $this->app->trans('The document %name% has been quarantined', ['%name%' => $filename]);
|
$text = $this->app->trans('The document %name% has been quarantined', ['%name%' => $filename]);
|
||||||
|
|
||||||
if ( ! ! count($reasons)) {
|
if ($reasons) {
|
||||||
$text .= ' ' . $this->app->trans('for the following reasons : %reasons%', ['%reasons%' => implode(', ', $reasons)]);
|
$text .= ' ' . $this->app->trans('for the following reasons : %reasons%', ['%reasons%' => implode(', ', $reasons)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@ use Alchemy\Phrasea\Application;
|
|||||||
use Alchemy\Phrasea\Authentication\ACLProvider;
|
use Alchemy\Phrasea\Authentication\ACLProvider;
|
||||||
use Alchemy\Phrasea\Border\File;
|
use Alchemy\Phrasea\Border\File;
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Client;
|
use Symfony\Component\HttpKernel\Client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,7 +50,7 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getJson($response)
|
public function getJson(Response $response)
|
||||||
{
|
{
|
||||||
$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'));
|
||||||
@@ -134,8 +135,8 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(false);
|
$this->setAdmin(false);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/suggested-values/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/suggested-values/');
|
||||||
$this->assertXMLHTTPBadJsonResponse(self::$DI['client']->getResponse());
|
$this->assertXMLHTTPBadJsonResponse($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,11 +148,11 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$prefs = '<?xml version="1.0" encoding="UTF-8"?> <baseprefs> <status>0</status> <sugestedValues> <Object> <value>my_new_value</value> </Object> </sugestedValues> </baseprefs>';
|
$prefs = '<?xml version="1.0" encoding="UTF-8"?> <baseprefs> <status>0</status> <sugestedValues> <Object> <value>my_new_value</value> </Object> </sugestedValues> </baseprefs>';
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/suggested-values/', [
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/suggested-values/', [
|
||||||
'str' => $prefs
|
'str' => $prefs
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
|
|
||||||
$collection = $collection = \collection::getByBaseId(self::$DI['app'], self::$DI['collection']->get_base_id());
|
$collection = $collection = \collection::getByBaseId(self::$DI['app'], self::$DI['collection']->get_base_id());
|
||||||
@@ -168,11 +169,11 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$prefs = '<?xml version="1.0" encoding="UTF-alues> </baseprefs>';
|
$prefs = '<?xml version="1.0" encoding="UTF-alues> </baseprefs>';
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/suggested-values/', [
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/suggested-values/', [
|
||||||
'str' => $prefs
|
'str' => $prefs
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertFalse($json->success);
|
$this->assertFalse($json->success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,9 +208,9 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/enable/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/enable/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
|
|
||||||
$collection = \collection::getByBaseId(self::$DI['app'], self::$DI['collection']->get_base_id());
|
$collection = \collection::getByBaseId(self::$DI['app'], self::$DI['collection']->get_base_id());
|
||||||
@@ -248,9 +249,9 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/disabled/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/disabled/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
$collection = \collection::getByBaseId(self::$DI['app'], self::$DI['collection']->get_base_id());
|
$collection = \collection::getByBaseId(self::$DI['app'], self::$DI['collection']->get_base_id());
|
||||||
$this->assertFalse($collection->is_active());
|
$this->assertFalse($collection->is_active());
|
||||||
@@ -318,8 +319,8 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/publication/display/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/publication/display/');
|
||||||
$this->assertXMLHTTPBadJsonResponse(self::$DI['client']->getResponse());
|
$this->assertXMLHTTPBadJsonResponse($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -329,11 +330,11 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/publication/display/', [
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/publication/display/', [
|
||||||
'pub_wm' => 'wm',
|
'pub_wm' => 'wm',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
$collection = \collection::getByBaseId(self::$DI['app'], self::$DI['collection']->get_base_id());
|
$collection = \collection::getByBaseId(self::$DI['app'], self::$DI['collection']->get_base_id());
|
||||||
$this->assertNotNull($collection->get_pub_wm());
|
$this->assertNotNull($collection->get_pub_wm());
|
||||||
@@ -409,8 +410,8 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/rename/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/rename/');
|
||||||
$this->assertXMLHTTPBadJsonResponse(self::$DI['client']->getResponse());
|
$this->assertXMLHTTPBadJsonResponse($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -420,8 +421,8 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/labels/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/labels/');
|
||||||
$this->assertXMLHTTPBadJsonResponse(self::$DI['client']->getResponse());
|
$this->assertXMLHTTPBadJsonResponse($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -433,11 +434,11 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$collection = $this->createOneCollection();
|
$collection = $this->createOneCollection();
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/rename/', [
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/rename/', [
|
||||||
'name' => 'test_rename_coll'
|
'name' => 'test_rename_coll'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
|
|
||||||
// Collection has to be reloaded since it was modified outside of the current process
|
// Collection has to be reloaded since it was modified outside of the current process
|
||||||
@@ -459,7 +460,7 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$collection = $this->createOneCollection();
|
$collection = $this->createOneCollection();
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/labels/', [
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/labels/', [
|
||||||
'labels' => [
|
'labels' => [
|
||||||
'nl' => 'netherlands label',
|
'nl' => 'netherlands label',
|
||||||
'de' => 'german label',
|
'de' => 'german label',
|
||||||
@@ -469,7 +470,7 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
|
|
||||||
$databox = $this->getApplication()->findDataboxById($collection->get_sbas_id());
|
$databox = $this->getApplication()->findDataboxById($collection->get_sbas_id());
|
||||||
@@ -504,8 +505,8 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(false);
|
$this->setAdmin(false);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/empty/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/empty/');
|
||||||
$this->assertXMLHTTPBadJsonResponse(self::$DI['client']->getResponse());
|
$this->assertXMLHTTPBadJsonResponse($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -524,9 +525,9 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$this->markTestSkipped('No record were added');
|
$this->markTestSkipped('No record were added');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/empty/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/empty/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
$this->assertEquals(0, $collection->get_record_amount());
|
$this->assertEquals(0, $collection->get_record_amount());
|
||||||
}
|
}
|
||||||
@@ -573,9 +574,9 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$this->markTestSkipped('No enough records added');
|
$this->markTestSkipped('No enough records added');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/empty/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/empty/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
|
|
||||||
if (count(self::$DI['app']['orm.em']->getRepository('Phraseanet:Task')->findAll()) === 0) {
|
if (count(self::$DI['app']['orm.em']->getRepository('Phraseanet:Task')->findAll()) === 0) {
|
||||||
@@ -662,8 +663,8 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/mini-logo/delete/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/mini-logo/delete/');
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -712,9 +713,9 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
}
|
}
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/watermark/delete/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/watermark/delete/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,9 +761,9 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/stamp-logo/delete/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/stamp-logo/delete/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -837,9 +838,9 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$collection = $this->createOneCollection();
|
$collection = $this->createOneCollection();
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/delete/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/delete/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
try {
|
try {
|
||||||
\collection::getByBaseId(self::$DI['app'], $collection->get_base_id());
|
\collection::getByBaseId(self::$DI['app'], $collection->get_base_id());
|
||||||
@@ -865,9 +866,9 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$this->markTestSkipped('No record were added');
|
$this->markTestSkipped('No record were added');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/delete/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/delete/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertFalse($json->success);
|
$this->assertFalse($json->success);
|
||||||
$collection->empty_collection();
|
$collection->empty_collection();
|
||||||
}
|
}
|
||||||
@@ -893,8 +894,8 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(false);
|
$this->setAdmin(false);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/unmount/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/unmount/');
|
||||||
$this->assertXMLHTTPBadJsonResponse(self::$DI['client']->getResponse());
|
$this->assertXMLHTTPBadJsonResponse($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -906,9 +907,9 @@ class AdminCollectionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$collection = $this->createOneCollection();
|
$collection = $this->createOneCollection();
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/unmount/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/unmount/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@@ -114,12 +114,13 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$app = $this->getApplication();
|
$app = $this->getApplication();
|
||||||
$collection = \collection::create($app, $databox, $app['phraseanet.appbox'], 'TESTTODELETE');
|
$collection = \collection::create($app, $databox, $app['phraseanet.appbox'], 'TESTTODELETE');
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . $databox->get_sbas_id() . '/collections/order/', [
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . $databox->get_sbas_id() . '/collections/order/', [
|
||||||
'order' => [
|
'order' => [
|
||||||
2 => $collection->get_base_id()
|
2 => $collection->get_base_id()
|
||||||
]]);
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
|
|
||||||
$databox->unmount_databox();
|
$databox->unmount_databox();
|
||||||
$databox->delete();
|
$databox->delete();
|
||||||
@@ -197,11 +198,11 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$cgusUpdate = 'Test update CGUS';
|
$cgusUpdate = 'Test update CGUS';
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/cgus/', [
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/cgus/', [
|
||||||
'TOU' => ['fr' => $cgusUpdate]
|
'TOU' => ['fr' => $cgusUpdate]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->checkRedirection(self::$DI['client']->getResponse(), '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/cgus/?success=1');
|
$this->checkRedirection($response, '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/cgus/?success=1');
|
||||||
|
|
||||||
$databox = self::$DI['app']->findDataboxById(self::$DI['collection']->get_sbas_id());
|
$databox = self::$DI['app']->findDataboxById(self::$DI['collection']->get_sbas_id());
|
||||||
$cgus = $databox->get_cgus();
|
$cgus = $databox->get_cgus();
|
||||||
@@ -228,9 +229,9 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/informations/documents/');
|
$response = $this->XMLHTTPRequest('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/informations/documents/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
$this->assertObjectHasAttribute('sbas_id', $json);
|
$this->assertObjectHasAttribute('sbas_id', $json);
|
||||||
$this->assertObjectHasAttribute('indexable', $json);
|
$this->assertObjectHasAttribute('indexable', $json);
|
||||||
@@ -305,8 +306,8 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(false);
|
$this->setAdmin(false);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/informations/documents/');
|
$response = $this->XMLHTTPRequest('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/informations/documents/');
|
||||||
$this->assertXMLHTTPBadJsonResponse(self::$DI['client']->getResponse());
|
$this->assertXMLHTTPBadJsonResponse($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -352,8 +353,7 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/reindex/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/reindex/');
|
||||||
$response = self::$DI['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'));
|
||||||
$content = json_decode($response->getContent());
|
$content = json_decode($response->getContent());
|
||||||
@@ -382,11 +382,10 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/indexable/', [
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/indexable/', [
|
||||||
'indexable' => 1
|
'indexable' => 1
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = self::$DI['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'));
|
||||||
$content = json_decode($response->getContent());
|
$content = json_decode($response->getContent());
|
||||||
@@ -418,9 +417,8 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/clear-logs/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/clear-logs/');
|
||||||
|
|
||||||
$response = self::$DI['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'));
|
||||||
$content = json_decode($response->getContent());
|
$content = json_decode($response->getContent());
|
||||||
@@ -451,8 +449,8 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/view-name/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/view-name/');
|
||||||
$this->assertXMLHTTPBadJsonResponse(self::$DI['client']->getResponse());
|
$this->assertXMLHTTPBadJsonResponse($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -467,11 +465,10 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$this->assertEquals('old_databox_name', $databox->get_viewname());
|
$this->assertEquals('old_databox_name', $databox->get_viewname());
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/view-name/', [
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/view-name/', [
|
||||||
'viewname' => 'new_databox_name'
|
'viewname' => 'new_databox_name'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = self::$DI['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'));
|
||||||
$content = json_decode($response->getContent());
|
$content = json_decode($response->getContent());
|
||||||
@@ -491,9 +488,9 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$base = $this->createDatabox();
|
$base = $this->createDatabox();
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/delete/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/delete/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
$this->assertObjectHasAttribute('sbas_id', $json);
|
$this->assertObjectHasAttribute('sbas_id', $json);
|
||||||
|
|
||||||
@@ -557,9 +554,9 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$this->markTestSkipped('No logo setted');
|
$this->markTestSkipped('No logo setted');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/logo/delete/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/logo/delete/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
$this->assertEmpty(\databox::getPrintLogo(self::$DI['collection']->get_sbas_id()));
|
$this->assertEmpty(\databox::getPrintLogo(self::$DI['collection']->get_sbas_id()));
|
||||||
}
|
}
|
||||||
@@ -573,9 +570,9 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$base = $this->createDatabox();
|
$base = $this->createDatabox();
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/unmount/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/unmount/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
$this->assertObjectHasAttribute('sbas_id', $json);
|
$this->assertObjectHasAttribute('sbas_id', $json);
|
||||||
|
|
||||||
@@ -607,9 +604,9 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$this->markTestSkipped('No record were added');
|
$this->markTestSkipped('No record were added');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/empty/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/empty/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
$this->assertEquals(0, $collection->get_record_amount());
|
$this->assertEquals(0, $collection->get_record_amount());
|
||||||
|
|
||||||
@@ -630,7 +627,7 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
$base = self::$DI['record_1']->get_databox();
|
$base = self::$DI['record_1']->get_databox();
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/labels/', [
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/labels/', [
|
||||||
'labels' => [
|
'labels' => [
|
||||||
'fr' => 'frenchy label',
|
'fr' => 'frenchy label',
|
||||||
'en' => '',
|
'en' => '',
|
||||||
@@ -639,10 +636,10 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertEquals('application/json', self::$DI['client']->getResponse()->headers->get('content-type'));
|
$this->assertEquals('application/json', $response->headers->get('content-type'));
|
||||||
|
|
||||||
$data = json_decode(self::$DI['client']->getResponse()->getContent(), true);
|
$data = json_decode($response->getContent(), true);
|
||||||
$this->assertTrue($data['success']);
|
$this->assertTrue($data['success']);
|
||||||
|
|
||||||
$base = $this->getApplication()->findDataboxById($base->get_sbas_id());
|
$base = $this->getApplication()->findDataboxById($base->get_sbas_id());
|
||||||
@@ -693,9 +690,9 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$this->markTestSkipped('No enough records added');
|
$this->markTestSkipped('No enough records added');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/empty/');
|
$response = $this->XMLHTTPRequest('POST', '/admin/databox/' . $base->get_sbas_id() . '/empty/');
|
||||||
|
|
||||||
$json = $this->getJson(self::$DI['client']->getResponse());
|
$json = $this->getJson($response);
|
||||||
$this->assertTrue($json->success);
|
$this->assertTrue($json->success);
|
||||||
|
|
||||||
if (count(self::$DI['app']['orm.em']->getRepository('Phraseanet:Task')->findAll()) === 0) {
|
if (count(self::$DI['app']['orm.em']->getRepository('Phraseanet:Task')->findAll()) === 0) {
|
||||||
|
@@ -431,14 +431,9 @@ class ApiJsonTest extends ApiTestCase
|
|||||||
|
|
||||||
public function testGetMonitorTaskById()
|
public function testGetMonitorTaskById()
|
||||||
{
|
{
|
||||||
$tasks = self::$DI['app']['repo.tasks']->findAll();
|
$idTask = $this->getTestTaskId();
|
||||||
|
|
||||||
if (!count($tasks)) {
|
|
||||||
$this->markTestSkipped('no tasks created for the current instance');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setToken($this->adminAccessToken);
|
$this->setToken($this->adminAccessToken);
|
||||||
$idTask = $tasks[0]->getId();
|
|
||||||
|
|
||||||
$route = '/api/v1/monitor/task/' . $idTask . '/';
|
$route = '/api/v1/monitor/task/' . $idTask . '/';
|
||||||
$this->evaluateMethodNotAllowedRoute($route, ['PUT', 'DELETE']);
|
$this->evaluateMethodNotAllowedRoute($route, ['PUT', 'DELETE']);
|
||||||
@@ -454,14 +449,9 @@ class ApiJsonTest extends ApiTestCase
|
|||||||
|
|
||||||
public function testPostMonitorTaskById()
|
public function testPostMonitorTaskById()
|
||||||
{
|
{
|
||||||
$tasks = self::$DI['app']['repo.tasks']->findAll();
|
$idTask = $this->getTestTaskId();
|
||||||
|
|
||||||
if (!count($tasks)) {
|
|
||||||
$this->markTestSkipped('no tasks created for the current instance');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setToken($this->adminAccessToken);
|
$this->setToken($this->adminAccessToken);
|
||||||
$idTask = $tasks[0]->getId();
|
|
||||||
|
|
||||||
$route = '/api/v1/monitor/task/' . $idTask . '/';
|
$route = '/api/v1/monitor/task/' . $idTask . '/';
|
||||||
$this->evaluateMethodNotAllowedRoute($route, ['PUT', 'DELETE']);
|
$this->evaluateMethodNotAllowedRoute($route, ['PUT', 'DELETE']);
|
||||||
@@ -492,14 +482,9 @@ class ApiJsonTest extends ApiTestCase
|
|||||||
|
|
||||||
public function testPostMonitorStartTask()
|
public function testPostMonitorStartTask()
|
||||||
{
|
{
|
||||||
$tasks = self::$DI['app']['repo.tasks']->findAll();
|
$idTask = $this->getTestTaskId();
|
||||||
|
|
||||||
if (!count($tasks)) {
|
|
||||||
$this->markTestSkipped('no tasks created for the current instance');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setToken($this->adminAccessToken);
|
$this->setToken($this->adminAccessToken);
|
||||||
$idTask = $tasks[0]->getId();
|
|
||||||
|
|
||||||
$route = '/api/v1/monitor/task/' . $idTask . '/start/';
|
$route = '/api/v1/monitor/task/' . $idTask . '/start/';
|
||||||
$this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']);
|
$this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']);
|
||||||
@@ -518,14 +503,9 @@ class ApiJsonTest extends ApiTestCase
|
|||||||
|
|
||||||
public function testPostMonitorStopTask()
|
public function testPostMonitorStopTask()
|
||||||
{
|
{
|
||||||
$tasks = self::$DI['app']['repo.tasks']->findAll();
|
$idTask = $this->getTestTaskId();
|
||||||
|
|
||||||
if (!count($tasks)) {
|
|
||||||
$this->markTestSkipped('no tasks created for the current instance');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setToken($this->adminAccessToken);
|
$this->setToken($this->adminAccessToken);
|
||||||
$idTask = $tasks[0]->getId();
|
|
||||||
|
|
||||||
$route = '/api/v1/monitor/task/' . $idTask . '/stop/';
|
$route = '/api/v1/monitor/task/' . $idTask . '/stop/';
|
||||||
$this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']);
|
$this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']);
|
||||||
@@ -1965,4 +1945,22 @@ class ApiJsonTest extends ApiTestCase
|
|||||||
$this->assertTrue(is_array($response['results']));
|
$this->assertTrue(is_array($response['results']));
|
||||||
$this->assertTrue(is_string($response['query']));
|
$this->assertTrue(is_string($response['query']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function getTestTaskId()
|
||||||
|
{
|
||||||
|
$app = $this->getApplication();
|
||||||
|
$tasks = $app['repo.tasks']->findAll();
|
||||||
|
|
||||||
|
if (empty($tasks)) {
|
||||||
|
$this->markTestSkipped('no tasks created for the current instance');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var Task $task */
|
||||||
|
$task = array_shift($tasks);
|
||||||
|
|
||||||
|
return $task->getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,8 +48,7 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
->getMock();
|
->getMock();
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/prod/export/ftp/test/', ['lst' => self::$DI['record_1']->get_serialize_key()]);
|
$response = $this->XMLHTTPRequest('POST', '/prod/export/ftp/test/', ['lst' => self::$DI['record_1']->get_serialize_key()]);
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$datas = (array) json_decode($response->getContent());
|
$datas = (array) json_decode($response->getContent());
|
||||||
$this->assertArrayHasKey('success', $datas);
|
$this->assertArrayHasKey('success', $datas);
|
||||||
$this->assertTrue($datas['success']);
|
$this->assertTrue($datas['success']);
|
||||||
|
@@ -61,12 +61,11 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$triggered = true;
|
$triggered = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/prod/order/', [
|
$response = $this->XMLHTTPRequest('POST', '/prod/order/', [
|
||||||
'lst' => $this->getRecord1()->getId(),
|
'lst' => $this->getRecord1()->getId(),
|
||||||
'deadline' => '+10 minutes'
|
'deadline' => '+10 minutes'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = $this->getClient()->getResponse();
|
|
||||||
$this->assertTrue($response->isOk(), 'Invalid response from create order');
|
$this->assertTrue($response->isOk(), 'Invalid response from create order');
|
||||||
$this->assertTrue($triggered, 'Order create listener not triggered');
|
$this->assertTrue($triggered, 'Order create listener not triggered');
|
||||||
$this->assertEquals('application/json', $response->headers->get('Content-Type'));
|
$this->assertEquals('application/json', $response->headers->get('Content-Type'));
|
||||||
@@ -86,11 +85,10 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
'lst' => $this->getRecord1()->getId(),
|
'lst' => $this->getRecord1()->getId(),
|
||||||
'deadline' => '+10 minutes'
|
'deadline' => '+10 minutes'
|
||||||
]);
|
]);
|
||||||
$client = $this->getClient();
|
$response = $this->request('GET', '/prod/order/', [
|
||||||
$client->request('GET', '/prod/order/', [
|
|
||||||
'sort' => 'usage'
|
'sort' => 'usage'
|
||||||
]);
|
]);
|
||||||
$this->assertTrue($client->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,8 +138,7 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
foreach ($order->getElements() as $element) {
|
foreach ($order->getElements() as $element) {
|
||||||
$parameters[] = $element->getId();
|
$parameters[] = $element->getId();
|
||||||
}
|
}
|
||||||
$this->XMLHTTPRequest('POST', '/prod/order/' . $order->getId() . '/send/', ['elements' => $parameters]);
|
$response = $this->XMLHTTPRequest('POST', '/prod/order/' . $order->getId() . '/send/', ['elements' => $parameters]);
|
||||||
$response = $this->getClient()->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'));
|
||||||
$content = json_decode($response->getContent());
|
$content = json_decode($response->getContent());
|
||||||
@@ -189,9 +186,7 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
foreach ($order->getElements() as $element) {
|
foreach ($order->getElements() as $element) {
|
||||||
$parameters[] = $element->getId();
|
$parameters[] = $element->getId();
|
||||||
}
|
}
|
||||||
$this->XMLHTTPRequest('POST', '/prod/order/' . $order->getId() . '/deny/', ['elements' => $parameters]);
|
$response = $this->XMLHTTPRequest('POST', '/prod/order/' . $order->getId() . '/deny/', ['elements' => $parameters]);
|
||||||
$client = $this->getClient();
|
|
||||||
$response = $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'));
|
||||||
$content = json_decode($response->getContent());
|
$content = json_decode($response->getContent());
|
||||||
|
@@ -19,8 +19,13 @@ class PropertyTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testDisplayStatusProperty()
|
public function testDisplayStatusProperty()
|
||||||
{
|
{
|
||||||
$this->XMLHTTPRequest('GET', '/prod/records/property/', ['lst' => implode(';', [self::$DI['record_no_access']->get_serialize_key(), self::$DI['record_1']->get_serialize_key(), self::$DI['record_4']->get_serialize_key()])]);
|
$response = $this->XMLHTTPRequest('GET', '/prod/records/property/', [
|
||||||
$response = self::$DI['client']->getResponse();
|
'lst' => implode(';', [
|
||||||
|
self::$DI['record_no_access']->get_serialize_key(),
|
||||||
|
self::$DI['record_1']->get_serialize_key(),
|
||||||
|
self::$DI['record_4']->get_serialize_key()
|
||||||
|
])
|
||||||
|
]);
|
||||||
$this->assertTrue($response->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
unset($response);
|
unset($response);
|
||||||
}
|
}
|
||||||
@@ -40,10 +45,14 @@ class PropertyTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testDisplayTypeProperty()
|
public function testDisplayTypeProperty()
|
||||||
{
|
{
|
||||||
$this->XMLHTTPRequest('GET', '/prod/records/property/type/',['lst' => implode(';', [self::$DI['record_no_access']->get_serialize_key(), self::$DI['record_1']->get_serialize_key(), self::$DI['record_4']->get_serialize_key()])]);
|
$response = $this->XMLHTTPRequest('GET', '/prod/records/property/type/', [
|
||||||
$response = self::$DI['client']->getResponse();
|
'lst' => implode(';', [
|
||||||
|
self::$DI['record_no_access']->get_serialize_key(),
|
||||||
|
self::$DI['record_1']->get_serialize_key(),
|
||||||
|
self::$DI['record_4']->get_serialize_key()
|
||||||
|
])
|
||||||
|
]);
|
||||||
$this->assertTrue($response->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
unset($response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,8 +36,7 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/cestlafete.jpg'), self::$DI['collection']);
|
$file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/cestlafete.jpg'), self::$DI['collection']);
|
||||||
$record = \record_adapter::createFromFile($file, self::$DI['app']);
|
$record = \record_adapter::createFromFile($file, self::$DI['app']);
|
||||||
$this->XMLHTTPRequest('POST', '/prod/records/delete/', ['lst' => $record->getId()]);
|
$response = $this->XMLHTTPRequest('POST', '/prod/records/delete/', ['lst' => $record->getId()]);
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$datas = (array) json_decode($response->getContent());
|
$datas = (array) json_decode($response->getContent());
|
||||||
$this->assertContains($record->getId(), $datas);
|
$this->assertContains($record->getId(), $datas);
|
||||||
try {
|
try {
|
||||||
@@ -46,7 +45,6 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
unset($response, $datas, $record);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,12 +54,10 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/cestlafete.jpg'), self::$DI['collection']);
|
$file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/cestlafete.jpg'), self::$DI['collection']);
|
||||||
$record = \record_adapter::createFromFile($file, self::$DI['app']);
|
$record = \record_adapter::createFromFile($file, self::$DI['app']);
|
||||||
$this->XMLHTTPRequest('POST', '/prod/records/renew-url/', ['lst' => $record->getId()]);
|
$response = $this->XMLHTTPRequest('POST', '/prod/records/renew-url/', ['lst' => $record->getId()]);
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$datas = (array) json_decode($response->getContent());
|
$datas = (array) json_decode($response->getContent());
|
||||||
$this->assertTrue(count($datas) > 0);
|
$this->assertTrue(count($datas) > 0);
|
||||||
$record->delete();
|
$record->delete();
|
||||||
unset($response, $datas, $record);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,13 +88,12 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
self::$DI['app']['orm.em']->persist($element);
|
self::$DI['app']['orm.em']->persist($element);
|
||||||
self::$DI['app']['orm.em']->flush();
|
self::$DI['app']['orm.em']->flush();
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/prod/records/', [
|
$response = $this->XMLHTTPRequest('POST', '/prod/records/', [
|
||||||
'env' => 'BASK',
|
'env' => 'BASK',
|
||||||
'pos' => 0,
|
'pos' => 0,
|
||||||
'query' => '',
|
'query' => '',
|
||||||
'cont' => $basket->getId(),
|
'cont' => $basket->getId(),
|
||||||
]);
|
]);
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$data = json_decode($response->getContent(), true);
|
$data = json_decode($response->getContent(), true);
|
||||||
|
|
||||||
@@ -126,14 +121,13 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$options->onCollections($acl->get_granted_base());
|
$options->onCollections($acl->get_granted_base());
|
||||||
$serializedOptions = $options->serialize();
|
$serializedOptions = $options->serialize();
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/prod/records/', [
|
$response = $this->XMLHTTPRequest('POST', '/prod/records/', [
|
||||||
'env' => 'RESULT',
|
'env' => 'RESULT',
|
||||||
'options_serial' => $serializedOptions,
|
'options_serial' => $serializedOptions,
|
||||||
'pos' => 0,
|
'pos' => 0,
|
||||||
'query' => ''
|
'query' => ''
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$data = json_decode($response->getContent(), true);
|
$data = json_decode($response->getContent(), true);
|
||||||
|
|
||||||
$this->assertArrayHasKey('desc', $data);
|
$this->assertArrayHasKey('desc', $data);
|
||||||
@@ -145,8 +139,6 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$this->assertArrayHasKey('tools', $data);
|
$this->assertArrayHasKey('tools', $data);
|
||||||
$this->assertArrayHasKey('pos', $data);
|
$this->assertArrayHasKey('pos', $data);
|
||||||
$this->assertArrayHasKey('title', $data);
|
$this->assertArrayHasKey('title', $data);
|
||||||
|
|
||||||
unset($response, $data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,14 +149,13 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$this->authenticate(self::$DI['app']);
|
$this->authenticate(self::$DI['app']);
|
||||||
self::$DI['record_story_1'];
|
self::$DI['record_story_1'];
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/prod/records/', [
|
$response = $this->XMLHTTPRequest('POST', '/prod/records/', [
|
||||||
'env' => 'REG',
|
'env' => 'REG',
|
||||||
'pos' => 0,
|
'pos' => 0,
|
||||||
'query' => '',
|
'query' => '',
|
||||||
'cont' => self::$DI['record_story_1']->get_serialize_key()
|
'cont' => self::$DI['record_story_1']->get_serialize_key()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$data = json_decode($response->getContent());
|
$data = json_decode($response->getContent());
|
||||||
$this->assertObjectHasAttribute('desc', $data);
|
$this->assertObjectHasAttribute('desc', $data);
|
||||||
$this->assertObjectHasAttribute('html_preview', $data);
|
$this->assertObjectHasAttribute('html_preview', $data);
|
||||||
@@ -175,8 +166,6 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$this->assertObjectHasAttribute('tools', $data);
|
$this->assertObjectHasAttribute('tools', $data);
|
||||||
$this->assertObjectHasAttribute('pos', $data);
|
$this->assertObjectHasAttribute('pos', $data);
|
||||||
$this->assertObjectHasAttribute('title', $data);
|
$this->assertObjectHasAttribute('title', $data);
|
||||||
|
|
||||||
unset($response, $data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -187,14 +176,13 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$this->authenticate(self::$DI['app']);
|
$this->authenticate(self::$DI['app']);
|
||||||
$basket = self::$DI['app']['orm.em']->find('Phraseanet:Basket', 1);
|
$basket = self::$DI['app']['orm.em']->find('Phraseanet:Basket', 1);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/prod/records/', [
|
$response = $this->XMLHTTPRequest('POST', '/prod/records/', [
|
||||||
'env' => 'BASK',
|
'env' => 'BASK',
|
||||||
'pos' => 0,
|
'pos' => 0,
|
||||||
'query' => '',
|
'query' => '',
|
||||||
'cont' => $basket->getId()
|
'cont' => $basket->getId()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$data = json_decode($response->getContent());
|
$data = json_decode($response->getContent());
|
||||||
|
|
||||||
$this->assertObjectHasAttribute('desc', $data);
|
$this->assertObjectHasAttribute('desc', $data);
|
||||||
@@ -224,14 +212,13 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$feed = self::$DI['app']['orm.em']->find('Phraseanet:Feed', 1);
|
$feed = self::$DI['app']['orm.em']->find('Phraseanet:Feed', 1);
|
||||||
$feedEntry = $feed->getEntries()->first();
|
$feedEntry = $feed->getEntries()->first();
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/prod/records/', [
|
$response = $this->XMLHTTPRequest('POST', '/prod/records/', [
|
||||||
'env' => 'FEED',
|
'env' => 'FEED',
|
||||||
'pos' => 0,
|
'pos' => 0,
|
||||||
'query' => '',
|
'query' => '',
|
||||||
'cont' => $feedEntry->getId()
|
'cont' => $feedEntry->getId()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$data = json_decode($response->getContent());
|
$data = json_decode($response->getContent());
|
||||||
$this->assertObjectHasAttribute('desc', $data);
|
$this->assertObjectHasAttribute('desc', $data);
|
||||||
$this->assertObjectHasAttribute('html_preview', $data);
|
$this->assertObjectHasAttribute('html_preview', $data);
|
||||||
|
@@ -34,10 +34,8 @@ class TOUTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetTOUAJAX()
|
public function testGetTOUAJAX()
|
||||||
{
|
{
|
||||||
$this->XMLHTTPRequest('GET', '/prod/TOU/');
|
$response = $this->XMLHTTPRequest('GET', '/prod/TOU/');
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$this->assertTrue($response->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
unset($response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,8 +46,7 @@ class TOUTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$databoxes = self::$DI['app']->getDataboxes();
|
$databoxes = self::$DI['app']->getDataboxes();
|
||||||
$databox = array_shift($databoxes);
|
$databox = array_shift($databoxes);
|
||||||
self::$DI['app']['authentication']->setUser(self::$DI['user_alt2']);
|
self::$DI['app']['authentication']->setUser(self::$DI['user_alt2']);
|
||||||
$this->XMLHTTPRequest('POST', '/prod/TOU/deny/'.$databox->get_sbas_id() .'/');
|
$response = $this->XMLHTTPRequest('POST', '/prod/TOU/deny/' . $databox->get_sbas_id() . '/');
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$this->assertTrue($response->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
unset($response, $databoxes);
|
unset($response, $databoxes);
|
||||||
|
|
||||||
|
@@ -34,13 +34,11 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->authenticate(self::$DI['app']);
|
$this->authenticate(self::$DI['app']);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('GET', '/report/dashboard', [
|
$response = $this->XMLHTTPRequest('GET', '/report/dashboard', [
|
||||||
'dmin' => $this->dmin->format('Y-m-d'),
|
'dmin' => $this->dmin->format('Y-m-d'),
|
||||||
'dmax' => $this->dmin->format('Y-m-d'),
|
'dmax' => $this->dmin->format('Y-m-d'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
|
|
||||||
$this->assertTrue($response->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -115,10 +115,10 @@ class DevelopersTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testDeleteAppError()
|
public function testDeleteAppError()
|
||||||
{
|
{
|
||||||
$this->XMLHTTPRequest('DELETE', '/developers/application/0/');
|
$response = $this->XMLHTTPRequest('DELETE', '/developers/application/0/');
|
||||||
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
$content = json_decode($response->getContent());
|
||||||
$this->assertFalse($content->success);
|
$this->assertFalse($content->success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,8 +134,8 @@ class DevelopersTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
'http://phraseanet.com/'
|
'http://phraseanet.com/'
|
||||||
);
|
);
|
||||||
$id = $oauthApp->getId();
|
$id = $oauthApp->getId();
|
||||||
$this->XMLHTTPRequest('DELETE', '/developers/application/' . $id . '/');
|
$response = $this->XMLHTTPRequest('DELETE', '/developers/application/' . $id . '/');
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
|
|
||||||
$this->assertNull(self::$DI['app']['repo.api-applications']->find($id));
|
$this->assertNull(self::$DI['app']['repo.api-applications']->find($id));
|
||||||
}
|
}
|
||||||
@@ -155,12 +155,12 @@ class DevelopersTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenewAppCallbackError()
|
public function testRenewAppCallbackError()
|
||||||
{
|
{
|
||||||
$this->XMLHTTPRequest('POST', '/developers/application/0/callback/', [
|
$response = $this->XMLHTTPRequest('POST', '/developers/application/0/callback/', [
|
||||||
'callback' => 'my.callback.com'
|
'callback' => 'my.callback.com'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
$content = json_decode($response->getContent());
|
||||||
$this->assertFalse($content->success);
|
$this->assertFalse($content->success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,9 +170,9 @@ class DevelopersTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
public function testRenewAppCallbackError2()
|
public function testRenewAppCallbackError2()
|
||||||
{
|
{
|
||||||
$oauthApp = self::$DI['oauth2-app-user'];
|
$oauthApp = self::$DI['oauth2-app-user'];
|
||||||
$this->XMLHTTPRequest('POST', '/developers/application/'.$oauthApp->getId().'/callback/');
|
$response = $this->XMLHTTPRequest('POST', '/developers/application/' . $oauthApp->getId() . '/callback/');
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
$content = json_decode($response->getContent());
|
||||||
$this->assertFalse($content->success);
|
$this->assertFalse($content->success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,12 +183,12 @@ class DevelopersTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$oauthApp = self::$DI['oauth2-app-user'];
|
$oauthApp = self::$DI['oauth2-app-user'];
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/developers/application/' . $oauthApp->getId() . '/callback/', [
|
$response = $this->XMLHTTPRequest('POST', '/developers/application/' . $oauthApp->getId() . '/callback/', [
|
||||||
'callback' => 'http://my.callback.com'
|
'callback' => 'http://my.callback.com'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
$content = json_decode($response->getContent());
|
||||||
$this->assertTrue($content->success);
|
$this->assertTrue($content->success);
|
||||||
$oauthApp = self::$DI['app']['repo.api-applications']->find($oauthApp->getId());
|
$oauthApp = self::$DI['app']['repo.api-applications']->find($oauthApp->getId());
|
||||||
$this->assertEquals('http://my.callback.com', $oauthApp->getRedirectUri());
|
$this->assertEquals('http://my.callback.com', $oauthApp->getRedirectUri());
|
||||||
@@ -209,12 +209,12 @@ class DevelopersTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRenewAccessTokenError()
|
public function testRenewAccessTokenError()
|
||||||
{
|
{
|
||||||
$this->XMLHTTPRequest('POST', '/developers/application/0/access_token/', [
|
$response = $this->XMLHTTPRequest('POST', '/developers/application/0/access_token/', [
|
||||||
'callback' => 'my.callback.com'
|
'callback' => 'my.callback.com'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
$content = json_decode($response->getContent());
|
||||||
$this->assertFalse($content->success);
|
$this->assertFalse($content->success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,10 +225,10 @@ class DevelopersTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$oauthApp = self::$DI['oauth2-app-user'];
|
$oauthApp = self::$DI['oauth2-app-user'];
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/developers/application/' . $oauthApp->getId() . '/access_token/');
|
$response = $this->XMLHTTPRequest('POST', '/developers/application/' . $oauthApp->getId() . '/access_token/');
|
||||||
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
$content = json_decode($response->getContent());
|
||||||
$this->assertTrue($content->success);
|
$this->assertTrue($content->success);
|
||||||
$this->assertNotNull($content->token);
|
$this->assertNotNull($content->token);
|
||||||
}
|
}
|
||||||
@@ -248,12 +248,12 @@ class DevelopersTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testAuthorizeGrantpasswordError()
|
public function testAuthorizeGrantpasswordError()
|
||||||
{
|
{
|
||||||
$this->XMLHTTPRequest('POST', '/developers/application/0/authorize_grant_password/', [
|
$response = $this->XMLHTTPRequest('POST', '/developers/application/0/authorize_grant_password/', [
|
||||||
'callback' => 'my.callback.com'
|
'callback' => 'my.callback.com'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
$content = json_decode($response->getContent());
|
||||||
$this->assertFalse($content->success);
|
$this->assertFalse($content->success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,12 +264,12 @@ class DevelopersTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$oauthApp = self::$DI['oauth2-app-user'];
|
$oauthApp = self::$DI['oauth2-app-user'];
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/developers/application/' . $oauthApp->getId() . '/authorize_grant_password/', [
|
$response = $this->XMLHTTPRequest('POST', '/developers/application/' . $oauthApp->getId() . '/authorize_grant_password/', [
|
||||||
'grant' => '1'
|
'grant' => '1'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
$content = json_decode($response->getContent());
|
||||||
$this->assertTrue($content->success);
|
$this->assertTrue($content->success);
|
||||||
$oauthApp = self::$DI['app']['repo.api-applications']->find($oauthApp->getId());
|
$oauthApp = self::$DI['app']['repo.api-applications']->find($oauthApp->getId());
|
||||||
$this->assertTrue($oauthApp->isPasswordGranted());
|
$this->assertTrue($oauthApp->isPasswordGranted());
|
||||||
|
@@ -19,9 +19,9 @@ class SessionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
public function testUpdSessionLogout()
|
public function testUpdSessionLogout()
|
||||||
{
|
{
|
||||||
$this->logout(self::$DI['app']);
|
$this->logout(self::$DI['app']);
|
||||||
$this->XMLHTTPRequest('POST', '/session/update/');
|
$response = $this->XMLHTTPRequest('POST', '/session/update/');
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$datas = json_decode(self::$DI['client']->getResponse()->getContent());
|
$datas = json_decode($response->getContent());
|
||||||
$this->checkSessionReturn($datas);
|
$this->checkSessionReturn($datas);
|
||||||
$this->assertEquals('disconnected', $datas->status);
|
$this->assertEquals('disconnected', $datas->status);
|
||||||
}
|
}
|
||||||
@@ -31,11 +31,11 @@ class SessionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpdSessionChangeUser()
|
public function testUpdSessionChangeUser()
|
||||||
{
|
{
|
||||||
$this->XMLHTTPRequest('POST', '/session/update/', [
|
$response = $this->XMLHTTPRequest('POST', '/session/update/', [
|
||||||
'usr' => self::$DI['user_alt1']->getId()
|
'usr' => self::$DI['user_alt1']->getId()
|
||||||
]);
|
]);
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$datas = json_decode(self::$DI['client']->getResponse()->getContent());
|
$datas = json_decode($response->getContent());
|
||||||
$this->checkSessionReturn($datas);
|
$this->checkSessionReturn($datas);
|
||||||
$this->assertEquals('disconnected', $datas->status);
|
$this->assertEquals('disconnected', $datas->status);
|
||||||
}
|
}
|
||||||
@@ -49,13 +49,12 @@ class SessionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = self::$DI['user'];
|
$user = self::$DI['user'];
|
||||||
$this->XMLHTTPRequest('POST', '/session/update/', [
|
$response = $this->XMLHTTPRequest('POST', '/session/update/', [
|
||||||
'usr' => $user->getId(),
|
'usr' => $user->getId(),
|
||||||
'module' => 1
|
'module' => 1
|
||||||
]);
|
]);
|
||||||
$client = $this->getClient();
|
$this->assertTrue($response->isOk());
|
||||||
$this->assertTrue($client->getResponse()->isOk());
|
$data = json_decode($response->getContent());
|
||||||
$data = json_decode($client->getResponse()->getContent());
|
|
||||||
$this->checkSessionReturn($data);
|
$this->checkSessionReturn($data);
|
||||||
$this->assertEquals('ok', $data->status);
|
$this->assertEquals('ok', $data->status);
|
||||||
}
|
}
|
||||||
@@ -67,12 +66,12 @@ class SessionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$this->authenticate(self::$DI['app']);
|
$this->authenticate(self::$DI['app']);
|
||||||
|
|
||||||
$this->XMLHTTPRequest('POST', '/session/update/', [
|
$response = $this->XMLHTTPRequest('POST', '/session/update/', [
|
||||||
'usr' => self::$DI['user']->getId()
|
'usr' => self::$DI['user']->getId()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$datas = json_decode(self::$DI['client']->getResponse()->getContent());
|
$datas = json_decode($response->getContent());
|
||||||
$datas = json_decode(self::$DI['client']->getResponse()->getContent());
|
$datas = json_decode($response->getContent());
|
||||||
$this->checkSessionReturn($datas);
|
$this->checkSessionReturn($datas);
|
||||||
$this->assertEquals('unknown', $datas->status);
|
$this->assertEquals('unknown', $datas->status);
|
||||||
}
|
}
|
||||||
@@ -118,8 +117,8 @@ class SessionTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
->will($this->returnValue(null));
|
->will($this->returnValue(null));
|
||||||
|
|
||||||
self::$DI['app']['orm.em'] = $em;
|
self::$DI['app']['orm.em'] = $em;
|
||||||
$this->XMLHTTPRequest('POST', '/session/delete/1');
|
$response = $this->XMLHTTPRequest('POST', '/session/delete/1');
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOK());
|
$this->assertTrue($response->isOK());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteSessionUnauthorized()
|
public function testDeleteSessionUnauthorized()
|
||||||
|
@@ -17,10 +17,8 @@ class NotificationsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testListNotifications()
|
public function testListNotifications()
|
||||||
{
|
{
|
||||||
$this->XMLHTTPRequest('GET', '/user/notifications/');
|
$response = $this->XMLHTTPRequest('GET', '/user/notifications/');
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$this->assertTrue($response->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
unset($response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,16 +46,14 @@ class NotificationsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSetNotificationsReaded()
|
public function testSetNotificationsReaded()
|
||||||
{
|
{
|
||||||
$this->XMLHTTPRequest('POST', '/user/notifications/read/', [
|
$response = $this->XMLHTTPRequest('POST', '/user/notifications/read/', [
|
||||||
'notifications' => ''
|
'notifications' => ''
|
||||||
]);
|
]);
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$this->assertTrue($response->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$datas = (array) json_decode($response->getContent());
|
$datas = (array) json_decode($response->getContent());
|
||||||
$this->assertArrayHasKey('success', $datas);
|
$this->assertArrayHasKey('success', $datas);
|
||||||
$this->assertTrue($datas['success'], $response->getContent());
|
$this->assertTrue($datas['success'], $response->getContent());
|
||||||
$this->assertArrayHasKey('message', $datas);
|
$this->assertArrayHasKey('message', $datas);
|
||||||
unset($response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -17,8 +17,7 @@ class PreferencesTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSaveUserPref()
|
public function testSaveUserPref()
|
||||||
{
|
{
|
||||||
$this->XMLHTTPRequest('POST', '/user/preferences/', ['prop' => 'prop_test', 'value' => 'val_test']);
|
$response = $this->XMLHTTPRequest('POST', '/user/preferences/', ['prop' => 'prop_test', 'value' => 'val_test']);
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$this->assertTrue($response->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$this->assertTrue(json_decode($response->getContent())->success);
|
$this->assertTrue(json_decode($response->getContent())->success);
|
||||||
$this->assertEquals('val_test', self::$DI['app']['settings']->getUserSetting(self::$DI['user'], 'prop_test'));
|
$this->assertEquals('val_test', self::$DI['app']['settings']->getUserSetting(self::$DI['user'], 'prop_test'));
|
||||||
@@ -49,8 +48,10 @@ class PreferencesTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSaveTemporaryPref()
|
public function testSaveTemporaryPref()
|
||||||
{
|
{
|
||||||
$this->XMLHTTPRequest('POST', "/user/preferences/temporary/", ['prop' => 'prop_test', 'value' => 'val_test']);
|
$response = $this->XMLHTTPRequest('POST', "/user/preferences/temporary/", [
|
||||||
$response = self::$DI['client']->getResponse();
|
'prop' => 'prop_test',
|
||||||
|
'value' => 'val_test'
|
||||||
|
]);
|
||||||
$this->assertTrue($response->isOk());
|
$this->assertTrue($response->isOk());
|
||||||
$this->assertTrue(json_decode($response->getContent())->success);
|
$this->assertTrue(json_decode($response->getContent())->success);
|
||||||
$this->assertEquals('val_test', self::$DI['app']['session']->get('phraseanet.prop_test'));
|
$this->assertEquals('val_test', self::$DI['app']['session']->get('phraseanet.prop_test'));
|
||||||
|
@@ -492,6 +492,24 @@ abstract class PhraseanetTestCase extends WebTestCase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $method
|
||||||
|
* @param string $uri
|
||||||
|
* @param array $parameters
|
||||||
|
* @param array $server
|
||||||
|
* @param string $content
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
protected function request($method, $uri, array $parameters = [], array $server = [], $content = null)
|
||||||
|
{
|
||||||
|
$client = $this->getClient();
|
||||||
|
|
||||||
|
$client->request($method, $uri, $parameters, [], $server, $content);
|
||||||
|
|
||||||
|
return $client->getResponse();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls a URI as XMLHTTP request.
|
* Calls a URI as XMLHTTP request.
|
||||||
*
|
*
|
||||||
@@ -500,11 +518,11 @@ abstract class PhraseanetTestCase extends WebTestCase
|
|||||||
* @param array $parameters The Request parameters
|
* @param array $parameters The Request parameters
|
||||||
* @param string $httpAccept Contents of the Accept header
|
* @param string $httpAccept Contents of the Accept header
|
||||||
*
|
*
|
||||||
* @return Crawler
|
* @return Response
|
||||||
*/
|
*/
|
||||||
protected function XMLHTTPRequest($method, $uri, array $parameters = [], $httpAccept = 'application/json')
|
protected function XMLHTTPRequest($method, $uri, array $parameters = [], $httpAccept = 'application/json')
|
||||||
{
|
{
|
||||||
return $this->getClient()->request($method, $uri, $parameters, [], [
|
return $this->request($method, $uri, $parameters, [
|
||||||
'HTTP_ACCEPT' => $httpAccept,
|
'HTTP_ACCEPT' => $httpAccept,
|
||||||
'HTTP_X-Requested-With' => 'XMLHttpRequest',
|
'HTTP_X-Requested-With' => 'XMLHttpRequest',
|
||||||
]);
|
]);
|
||||||
|
Reference in New Issue
Block a user