mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 20:43:25 +00:00
Fix unit tests
This commit is contained in:
@@ -123,17 +123,17 @@ class ApplicationSpecification implements SpecificationInterface
|
||||
$this->delete();
|
||||
|
||||
copy(
|
||||
$this->getRealRootPath() . "/conf.d/connexions.yml"
|
||||
$this->getRealRootPath() . "/lib/conf.d/connexions.yml"
|
||||
, $this->getConnexionsPathFile()
|
||||
);
|
||||
|
||||
copy(
|
||||
$this->getRealRootPath() . "/conf.d/services.yml"
|
||||
$this->getRealRootPath() . "/lib/conf.d/services.yml"
|
||||
, $this->getServicesPathFile()
|
||||
);
|
||||
|
||||
copy(
|
||||
$this->getRealRootPath() . "/conf.d/config.yml"
|
||||
$this->getRealRootPath() . "/lib/conf.d/config.yml"
|
||||
, $this->getConfigurationsPathFile()
|
||||
);
|
||||
|
||||
|
@@ -31,7 +31,7 @@ class Builder
|
||||
}
|
||||
|
||||
try {
|
||||
$options = $configuration->get("options");
|
||||
$options = $configuration->get("options") ?: array() ;
|
||||
} catch (\Exception $e) {
|
||||
$options = array();
|
||||
}
|
||||
|
@@ -40,12 +40,12 @@ class TaskManager extends ServiceAbstract
|
||||
$options = $this->getOptions();
|
||||
$registry = $this->app['phraseanet.registry'];
|
||||
|
||||
if (null !== $syslogLevel = constant($options['syslog_level'])) {
|
||||
if (isset($options['syslog_level']) && null !== $syslogLevel = constant($options['syslog_level'])) {
|
||||
$handler = new SyslogHandler("Phraseanet-Task", "user", $syslogLevel);
|
||||
$logger->pushHandler($handler);
|
||||
}
|
||||
|
||||
if (null !== $maillogLevel = constant($options['maillog_level'])) {
|
||||
if (isset($options['maillog_level']) && null !== $maillogLevel = constant($options['maillog_level'])) {
|
||||
if ('' === $adminMail = trim($registry->get('GV_adminMail'))) {
|
||||
throw new RuntimeException("Admininstrator mail must be set to get log by mail.");
|
||||
}
|
||||
|
@@ -2089,7 +2089,7 @@ class task_period_archive extends task_abstract
|
||||
$fields = caption_field::get_multi_values($field, $meta->get_separator());
|
||||
|
||||
if (!$metadataBag->containsKey($meta->get_name())) {
|
||||
$values = new \PHPExiftool\Driver\Value\Multi($fields);
|
||||
$values = $fields;
|
||||
} else {
|
||||
$values = array_merge($metadataBag->get($meta->get_name())->getValue(), $fields);
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ namespace Alchemy\Tests\Phrasea\Application;
|
||||
|
||||
use Alchemy\Phrasea\Border\File;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class ApplicationOverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
@@ -20,12 +19,11 @@ class ApplicationOverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
|
||||
$this->assertEquals(self::$DI['record_1']->get_preview()->get_size(), $response->headers->get('content-length'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
function testDatafilesNonExistentSubdef()
|
||||
{
|
||||
$crawler = self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/asubdefthatdoesnotexists/');
|
||||
self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/asubdefthatdoesnotexists/');
|
||||
|
||||
$this->assertNotFoundResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
function testEtag()
|
||||
@@ -58,25 +56,17 @@ class ApplicationOverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac
|
||||
function testDatafilesRouteNotAuthenticated()
|
||||
{
|
||||
self::$DI['app']->closeAccount();
|
||||
try {
|
||||
$crawler = self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/preview/');
|
||||
$this->fail('should throw an HttpException');
|
||||
} catch (HttpException $e) {
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertEquals(403, $e->getStatusCode());
|
||||
}
|
||||
self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/preview/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
function testDatafilesRouteNotAuthenticatedUnknownSubdef()
|
||||
{
|
||||
self::$DI['app']->closeAccount();
|
||||
try {
|
||||
$crawler = self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/notfoundreview/');
|
||||
$this->fail('should throw an HttpException');
|
||||
} catch (HttpException $e) {
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertEquals(403, $e->getStatusCode());
|
||||
}
|
||||
self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/notfoundreview/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
function testPermalinkAuthenticated()
|
||||
|
@@ -10,12 +10,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
protected $client;
|
||||
public static $createdCollections = array();
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
self::$DI['app.use-exception-handler'] = true;
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
self::$DI['app']['phraseanet.user'] = self::$DI['user'];
|
||||
@@ -192,7 +186,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::enable
|
||||
*/
|
||||
public function testPostEnableUnauthorizedException()
|
||||
@@ -200,6 +193,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/enable/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,7 +227,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::disabled
|
||||
*/
|
||||
public function testPostDisabledUnauthorizedException()
|
||||
@@ -240,6 +234,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/disabled/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,7 +255,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::setOrderAdmins
|
||||
*/
|
||||
public function testPostOrderAdminsUnauthorizedException()
|
||||
@@ -267,6 +262,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/order/admins/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,7 +297,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::setPublicationDisplay
|
||||
*/
|
||||
public function testPostPublicationDisplayUnauthorizedException()
|
||||
@@ -308,6 +304,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/publication/display/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,7 +354,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::rename
|
||||
*/
|
||||
public function testPostNameUnauthorizedException()
|
||||
@@ -364,6 +361,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/rename/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -509,7 +508,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::setMiniLogo
|
||||
*/
|
||||
public function testSetMiniLogoBadRequest()
|
||||
@@ -517,10 +515,11 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(true);
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/mini-logo/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::setStamp
|
||||
*/
|
||||
public function testSetStampBadRequest()
|
||||
@@ -528,19 +527,21 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(true);
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/stamp-logo/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::setWatermark
|
||||
*/
|
||||
public function testSetWatermarkBadRequest()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/watermark/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::setBanner
|
||||
*/
|
||||
public function testSetBannerBadRequest()
|
||||
@@ -548,6 +549,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(true);
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/banner/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -741,7 +744,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::getCollection
|
||||
*/
|
||||
public function testGetCollectionUnauthorizedException()
|
||||
@@ -749,10 +751,11 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::getSuggestedValues
|
||||
*/
|
||||
public function testGetSuggestedValuesUnauthorizedException()
|
||||
@@ -760,10 +763,11 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/suggested-values/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::getDetails
|
||||
*/
|
||||
public function testInformationsDetailsUnauthorizedException()
|
||||
@@ -771,6 +775,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/informations/details/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -788,7 +794,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Bas::delete
|
||||
*/
|
||||
public function testDeleteCollectionUnauthorized()
|
||||
@@ -796,6 +801,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/delete/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -7,7 +7,6 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::slash
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::connect
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::call
|
||||
@@ -16,6 +15,8 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
$this->setAdmin(false);
|
||||
self::$DI['client']->request('GET', '/admin/dashboard/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +63,6 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::sendMail
|
||||
*/
|
||||
public function testSendMailTestBadRequest()
|
||||
@@ -70,6 +70,8 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(true);
|
||||
|
||||
self::$DI['client']->request('POST', '/admin/dashboard/send-mail-test/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
/**
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::resetAdminRights
|
||||
|
@@ -126,7 +126,6 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Database::getDatabaseCGU
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testGetCGUHasNoRights()
|
||||
{
|
||||
@@ -138,6 +137,8 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(true);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/cgus/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +200,6 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Database::progressBarInfos
|
||||
*/
|
||||
public function testGetInformationDocumentBadRequest()
|
||||
@@ -207,6 +207,8 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(true);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/informations/documents/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,7 +254,6 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Database::getDatabase
|
||||
*/
|
||||
public function testGetDataboxUnauthorizedException()
|
||||
@@ -260,10 +261,11 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Database::getReorder
|
||||
*/
|
||||
public function testGetCollectionOrderUnauthorizedException()
|
||||
@@ -271,10 +273,11 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/collections/order/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Database::getDatabaseCGU
|
||||
*/
|
||||
public function testGetCGUUnauthorizedException()
|
||||
@@ -282,6 +285,8 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/cgus/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,7 +302,6 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Database::progressBarInfos
|
||||
*/
|
||||
public function testGetInformationDetailsUnauthorizedException()
|
||||
@@ -305,10 +309,11 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/informations/details/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers \Alchemy\Phrasea\Controller\Admin\Database::getNewCollection
|
||||
*/
|
||||
public function testGetNewCollectionUnauthorizedException()
|
||||
@@ -316,6 +321,8 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/collection/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -39,13 +39,14 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Databases::getDatabases
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testGetSlashUnauthorizedException()
|
||||
{
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/databoxes/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\Controller\Admin;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
protected $client;
|
||||
@@ -186,23 +184,19 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$field = \databox_field::create(self::$DI['app'], $databox, $name, false);
|
||||
$id = $field->get_id();
|
||||
|
||||
try {
|
||||
self::$DI['client']->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array(
|
||||
'field_ids' => array($id)
|
||||
, 'name_' . $id => $name
|
||||
, 'multi_' . $id => 1
|
||||
, 'indexable_' . $id => 1
|
||||
, 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories'
|
||||
, 'required_' . $id => 0
|
||||
, 'readonly_' . $id => 0
|
||||
, 'type_' . $id => 'string'
|
||||
, 'vocabulary_' . $id => 'User'
|
||||
));
|
||||
print(self::$DI['client']->getResponse()->getContent());
|
||||
$this->fail('Should throw an HttpException');
|
||||
} catch (HttpException $e) {
|
||||
self::$DI['client']->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array(
|
||||
'field_ids' => array($id)
|
||||
, 'name_' . $id => $name
|
||||
, 'multi_' . $id => 1
|
||||
, 'indexable_' . $id => 1
|
||||
, 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories'
|
||||
, 'required_' . $id => 0
|
||||
, 'readonly_' . $id => 0
|
||||
, 'type_' . $id => 'string'
|
||||
, 'vocabulary_' . $id => 'User'
|
||||
));
|
||||
|
||||
}
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
|
||||
$field->delete();
|
||||
}
|
||||
@@ -214,12 +208,9 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes();
|
||||
$databox = array_shift($databoxes);
|
||||
|
||||
try {
|
||||
self::$DI['client']->request("GET", "/admin/description/" . $databox->get_sbas_id() . "/");
|
||||
$this->fail('Should throw an HttpException');
|
||||
} catch (HttpException $e) {
|
||||
self::$DI['client']->request("GET", "/admin/description/" . $databox->get_sbas_id() . "/");
|
||||
|
||||
}
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
public function testGetDescription()
|
||||
|
@@ -8,12 +8,6 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic
|
||||
public static $api = null;
|
||||
protected $client;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
self::$DI['app.use-exception-handler'] = true;
|
||||
}
|
||||
|
||||
public function testList()
|
||||
{
|
||||
$crawler = self::$DI['client']->request('GET', '/admin/publications/list/');
|
||||
|
@@ -18,14 +18,14 @@ class SetupTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Admin\Setup::getGlobals
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testGetSlashUnauthorizedException()
|
||||
{
|
||||
$this->setAdmin(false);
|
||||
|
||||
self::$DI['client']->request('GET', '/admin/setup/');
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -46,22 +46,26 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\DoDownload::prepareDownload
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testPrepareDownloadTokenNotFound()
|
||||
{
|
||||
$token = 'AzBdisusjA';
|
||||
self::$DI['client']->request('GET', sprintf('/download/%s/prepare/', $token));
|
||||
|
||||
$this->assertNotFoundResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\DoDownload::prepareDownload
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testPrepareDownloadInvalidData()
|
||||
{
|
||||
$token = $this->getToken(array('bad_string' => base64_decode(serialize(array('fail')))));
|
||||
self::$DI['client']->request('GET', sprintf('/download/%s/prepare/', $token));
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertEquals(500, $response->getStatusCode());
|
||||
$this->assertTrue(false !== stripos($response->getContent(), 'internal server error'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +189,6 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\DoDownload::downloadDocuments
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testDocumentsDownloadNotFound()
|
||||
{
|
||||
@@ -215,29 +218,32 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
));
|
||||
$url = sprintf('/download/%s/get/', $token);
|
||||
self::$DI['client']->request('POST', $url);
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
unset($response);
|
||||
|
||||
$this->assertNotFoundResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\DoDownload::downloadDocuments
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testDocumentsDownloadTokenNotFound()
|
||||
{
|
||||
$token = 'AzBdisusjA';
|
||||
self::$DI['client']->request('POST', sprintf('/download/%s/get/', $token));
|
||||
|
||||
$this->assertNotFoundResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\DoDownload::downloadDocuments
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testDocumentsDownloadInvalidData()
|
||||
{
|
||||
$token = $this->getToken(array('bad_string' => base64_decode(serialize(array('fail')))));
|
||||
self::$DI['client']->request('POST', sprintf('/download/%s/get/', $token));
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertEquals(500, $response->getStatusCode());
|
||||
$this->assertTrue(false !== stripos($response->getContent(), 'internal server error'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -76,7 +76,6 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Export::testFtpConnexion
|
||||
*/
|
||||
public function testFtpConnexionNoXMLHTTPRequests()
|
||||
@@ -98,10 +97,8 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
self::$DI['client']->request('POST', '/prod/export/ftp/test/', array('lst' => self::$DI['record_1']->get_serialize_key()));
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$datas = (array) json_decode($response->getContent());
|
||||
$this->assertArrayHasKey('success', $datas);
|
||||
$this->assertFalse($datas['success']);
|
||||
$this->assertArrayHasKey('message', $datas);
|
||||
unset($response, $datas);
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,13 +123,14 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Export::exportFtp
|
||||
* @dataProvider getMissingArguments
|
||||
*/
|
||||
public function testExportFtpBadRequest($params)
|
||||
{
|
||||
self::$DI['client']->request('POST', '/prod/export/ftp/', $params);
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
public function getMissingArguments()
|
||||
|
@@ -10,26 +10,21 @@ class MustacheLoaderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
self::$DI['client']->request('GET', '/prod/MustacheLoader/');
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
/* @var $response \Symfony\Component\HttpFoundation\Response */
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
public function testRouteSlashWrongUrl()
|
||||
{
|
||||
self::$DI['client']->request('GET', '/prod/MustacheLoader/', array('template' => '/../../../../config/config.yml'));
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
/* @var $response \Symfony\Component\HttpFoundation\Response */
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
public function testRouteSlashWrongFile()
|
||||
{
|
||||
self::$DI['client']->request('GET', '/prod/MustacheLoader/', array('template' => 'patator_lala'));
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
$this->assertNotFoundResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
public function testRouteGood()
|
||||
|
@@ -20,12 +20,13 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Property::displayStatusProperty
|
||||
*/
|
||||
public function testDisplayStatusPropertyNotXMLHTTPRequets()
|
||||
{
|
||||
self::$DI['client']->request('GET', '/prod/records/property/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,12 +41,13 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Property::displayProperty
|
||||
*/
|
||||
public function testDisplayTypePropertyNotXMLHTTPRequets()
|
||||
{
|
||||
self::$DI['client']->request('GET', '/prod/records/property/type/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -70,11 +70,12 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testGetRecordDetailNotAjax()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/prod/records/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,25 +18,22 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public function testRouteBasketFail()
|
||||
{
|
||||
$crawler = self::$DI['client']->request('POST', '/prod/tooltip/basket/notanid/');
|
||||
$pageContent = self::$DI['client']->getResponse()->getContent();
|
||||
$this->assertFalse(self::$DI['client']->getResponse()->isOk());
|
||||
|
||||
$this->assertNotFoundResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public function testRouteBasketFail2()
|
||||
{
|
||||
$crawler = self::$DI['client']->request('POST', '/prod/tooltip/basket/-5/');
|
||||
$pageContent = self::$DI['client']->getResponse()->getContent();
|
||||
$this->assertFalse(self::$DI['client']->getResponse()->isOk());
|
||||
|
||||
$this->assertNotFoundResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
public function testRoutePreview()
|
||||
|
@@ -20,7 +20,6 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
self::$DI['app.use-exception-handler'] = true;
|
||||
$this->tmpFile = sys_get_temp_dir() . '/' . time() . mt_rand(1000, 9999) . '.jpg';
|
||||
copy(__DIR__ . '/../../../../../files/cestlafete.jpg', $this->tmpFile);
|
||||
}
|
||||
|
@@ -241,7 +241,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
$this->assertBadResponse($response);
|
||||
$this->assertEquals('UTF-8', $response->getCharset());
|
||||
|
||||
|
||||
@@ -251,11 +251,9 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
$this->assertBadResponse($response);
|
||||
$this->assertEquals('UTF-8', $response->getCharset());
|
||||
|
||||
|
||||
|
||||
$route = '/prod/lists/list/' . $list->getId() . '/share/' . self::$DI['user_alt1']->get_id() . '/';
|
||||
|
||||
self::$DI['client']->request('POST', $route, array('role' => \Entities\UsrListOwner::ROLE_ADMIN));
|
||||
|
@@ -28,8 +28,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
self::$DI['client']->request('POST', $route);
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
$this->assertFalse($response->isOk());
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
public function testAttachStoryToWZ()
|
||||
@@ -146,8 +145,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
self::$DI['client']->request('POST', $route);
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
$this->assertFalse($response->isOk());
|
||||
$this->assertNotFoundResponse(self::$DI['client']->getResponse());
|
||||
|
||||
//attach
|
||||
$attachRoute = sprintf("/prod/WorkZone/attachStories/");
|
||||
|
@@ -120,11 +120,12 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @covers \Alchemy\Phrasea\Controller\Root\Account::resetEmail
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testPostResetMailBadRequest()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/account/reset-email/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,12 +364,11 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->assertEquals(count($ret), count($bases));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testAUthorizedAppGrantAccessBadRequest()
|
||||
{
|
||||
self::$DI['client']->request('GET', '/account/security/application/3/grant/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
public function testAUthorizedAppGrantAccessNotSuccessfull()
|
||||
|
@@ -74,11 +74,12 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @cover \Alchemy\Phrasea\Controller\Root\Developers::getApp
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testGetUnknowApp()
|
||||
{
|
||||
self::$DI['client']->request('GET', '/developers/application/0/');
|
||||
|
||||
$this->assertNotFoundResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,11 +95,12 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @cover \Alchemy\Phrasea\Controller\Root\Developers::deleteApp
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testDeleteAppBadRequest()
|
||||
{
|
||||
self::$DI['client']->request('DELETE', '/developers/application/1/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,11 +136,12 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @cover \Alchemy\Phrasea\Controller\Root\Developers::renewAppCallback
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testRenewAppCallbackBadRequest()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/developers/application/1/callback/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,11 +192,12 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @cover \Alchemy\Phrasea\Controller\Root\Developers::renewAccessToken
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testRenewAccessTokenbadRequest()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/developers/application/1/access_token/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,11 +232,12 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @cover \Alchemy\Phrasea\Controller\Root\Developers::authorizeGrantpassword
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testAuthorizeGrantpasswordBadRequest()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/developers/application/1/authorize_grant_password/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -386,12 +386,13 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @covers \Alchemy\Phrasea\Controller\Root\Login::register
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testPostRegisterBadRequest()
|
||||
{
|
||||
self::$DI['app']->closeAccount();
|
||||
self::$DI['client']->request('POST', '/login/register/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -618,12 +619,13 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @covers \Alchemy\Phrasea\Controller\Root\Login::sendConfirmMail
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testSendConfirmMailBadRequest()
|
||||
{
|
||||
self::$DI['app']->closeAccount();
|
||||
self::$DI['client']->request('GET', '/login/send-mail-confirm/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -74,7 +74,6 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
self::$DI['app.use-exception-handler'] = true;
|
||||
self::$feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], 'title', 'subtitle');
|
||||
self::$publisher = \Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], self::$feed, self::$DI['user']);
|
||||
self::$entry = \Feed_Entry_Adapter::create(self::$DI['app'], self::$feed, self::$publisher, 'title_entry', 'subtitle', 'hello', "test@mail.com");
|
||||
@@ -334,12 +333,11 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract
|
||||
$this->assertEquals(404, self::$DI['client']->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public function testUnknowFeedId2()
|
||||
{
|
||||
self::$DI['client']->request("GET", "/feeds/feed/titi/");
|
||||
|
||||
$this->assertNotFoundResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
public function testGetFeedId()
|
||||
|
@@ -70,11 +70,12 @@ class SessionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @covers \Alchemy\Phrasea\Controller\Root\Session::updateSession
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function testUpdSessionBadRequest()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/session/update/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
private function checkSessionReturn(\stdClass $data)
|
||||
|
@@ -18,21 +18,23 @@ class NotificationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\User\Notifications::listNotifications
|
||||
*/
|
||||
public function testListNotificationsNoXMLHTTPRequests()
|
||||
{
|
||||
self::$DI['client']->request('GET', '/user/notifications/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\User\Notifications::setNotificationsReaded
|
||||
*/
|
||||
public function testSetNotificationsReadedNoXMLHTTPRequests()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/user/notifications/read/');
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +55,6 @@ class NotificationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\User\Notifications::connect
|
||||
* @covers Alchemy\Phrasea\Controller\User\Notifications::call
|
||||
*/
|
||||
@@ -69,5 +70,7 @@ class NotificationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
->will($this->returnValue(true));
|
||||
|
||||
self::$DI['client']->request('GET', '/user/notifications/');
|
||||
|
||||
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
}
|
||||
|
@@ -32,21 +32,23 @@ class PreferencesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\User\Preferences::saveUserPref
|
||||
*/
|
||||
public function testSaveUserPrefNoXMLHTTPRequests()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/user/preferences/', array('prop' => 'prop_test', 'value' => 'val_test'));
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\User\Preferences::saveTemporaryPref
|
||||
*/
|
||||
public function testSaveTempPrefNoXMLHTTPRequests()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/user/preferences/temporary/', array('prop' => 'prop_test', 'value' => 'val_test'));
|
||||
|
||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -100,8 +100,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
|
||||
parent::setUp();
|
||||
|
||||
self::$DI['app.use-exception-handler'] = false;
|
||||
|
||||
\PHPUnit_Framework_Error_Warning::$enabled = true;
|
||||
\PHPUnit_Framework_Error_Notice::$enabled = true;
|
||||
|
||||
@@ -112,10 +110,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
|
||||
$app['debug'] = true;
|
||||
|
||||
if (!$DI['app.use-exception-handler']) {
|
||||
unset($app['exception_handler']);
|
||||
}
|
||||
|
||||
$app['EM'] = $app->share($app->extend('EM', function($em) {
|
||||
@unlink('/tmp/db.sqlite');
|
||||
copy(__DIR__ . '/../db-ref.sqlite', '/tmp/db.sqlite');
|
||||
@@ -169,6 +163,25 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
set_time_limit(0);
|
||||
}
|
||||
|
||||
protected function assertForbiddenResponse(Response $response)
|
||||
{
|
||||
$this->assertEquals(403, $response->getStatusCode());
|
||||
$this->assertTrue(false !== stripos($response->getContent(), 'forbidden'));
|
||||
}
|
||||
|
||||
protected function assertBadResponse(Response $response)
|
||||
{
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
$this->assertTrue(false !== stripos($response->getContent(), 'bad request'));
|
||||
}
|
||||
|
||||
protected function assertNotFoundResponse(Response $response)
|
||||
{
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
$this->assertTrue(false !== stripos($response->getContent(), 'not found'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert fixture contained in the specified fixtureLoader
|
||||
* into sqlLite test temporary database
|
||||
|
Reference in New Issue
Block a user