mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Add missing class declaration
Fix tests Update tests Fix CS
This commit is contained in:
@@ -61,7 +61,7 @@ define('GV_smtp_port', '');
|
||||
define('GV_smtp_secure', false);
|
||||
define('GV_smtp_user', '');
|
||||
define('GV_smtp_password', '');
|
||||
define('GV_activeFTP', false);
|
||||
define('GV_activeFTP', true);
|
||||
define('GV_ftp_for_user', false);
|
||||
define('GV_download_max', '120');
|
||||
define('GV_ong_search', '1');
|
||||
|
@@ -45,8 +45,10 @@ use Alchemy\Phrasea\Controller\Prod\Order;
|
||||
use Alchemy\Phrasea\Controller\Prod\Printer;
|
||||
use Alchemy\Phrasea\Controller\Prod\Push;
|
||||
use Alchemy\Phrasea\Controller\Prod\Query;
|
||||
use Alchemy\Phrasea\Controller\Prod\Record\Property;
|
||||
use Alchemy\Phrasea\Controller\Prod\Property;
|
||||
use Alchemy\Phrasea\Controller\Prod\Records;
|
||||
use Alchemy\Phrasea\Controller\Prod\Root as Prod;
|
||||
use Alchemy\Phrasea\Controller\Prod\Share;
|
||||
use Alchemy\Phrasea\Controller\Prod\Story;
|
||||
use Alchemy\Phrasea\Controller\Prod\Tools;
|
||||
use Alchemy\Phrasea\Controller\Prod\Tooltip;
|
||||
@@ -136,6 +138,7 @@ return call_user_func(function($environment = null) {
|
||||
$app->mount('/prod/WorkZone', new WorkZone());
|
||||
$app->mount('/prod/lists', new UsrLists());
|
||||
$app->mount('/prod/MustacheLoader', new MustacheLoader());
|
||||
$app->mount('/prod/records/', new Records());
|
||||
$app->mount('/prod/records/edit', new Edit());
|
||||
$app->mount('/prod/records/property', new Property());
|
||||
$app->mount('/prod/records/movecollection', new MoveCollection());
|
||||
|
@@ -18,11 +18,6 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Export implements ControllerProviderInterface
|
||||
{
|
||||
|
||||
@@ -113,7 +108,12 @@ class Export implements ControllerProviderInterface
|
||||
*/
|
||||
public function displayMultiExport(Application $app, Request $request)
|
||||
{
|
||||
$download = new \set_export($app, $request->request->get('lst', ''), (int) $request->request->get('ssel'), $request->request->get('story'));
|
||||
$download = new \set_export(
|
||||
$app,
|
||||
$request->request->get('lst', ''),
|
||||
$request->request->get('ssel', ''),
|
||||
$request->request->get('story')
|
||||
);
|
||||
|
||||
return new Response($app['twig']->render('common/dialog_export.html.twig', array(
|
||||
'download' => $download,
|
||||
@@ -165,44 +165,62 @@ class Export implements ControllerProviderInterface
|
||||
$download = new \set_exportftp($app, $request->request->get('lst'), $request->request->get('ssttid'));
|
||||
|
||||
if (null === $address = $request->request->get('addr')) {
|
||||
$app->abort(400, _('Missing ftp address'));
|
||||
$app->abort(400, _('addr parameter is missing'));
|
||||
}
|
||||
|
||||
if (null === $login = $request->request->get('login')) {
|
||||
$app->abort(400, _('Missing ftp lofin'));
|
||||
$app->abort(400, _('login parameter is missing'));
|
||||
}
|
||||
|
||||
if (null === $destFolder = $request->request->get('destfolder')) {
|
||||
$app->abort(400, _('Missing destination folder'));
|
||||
$app->abort(400, _('destfolder parameter is missing'));
|
||||
}
|
||||
|
||||
if (null === $folderTocreate = $request->request->get('NAMMKDFOLD')) {
|
||||
$app->abort(400, _('Missing folder to create'));
|
||||
$app->abort(400, _('NAMMKDFOLD parameter is missing'));
|
||||
}
|
||||
|
||||
if (null === $subdefs = $request->request->get('obj')) {
|
||||
$app->abort(400, _('Missing subdefs to export'));
|
||||
$app->abort(400, _('obj parameter is missing'));
|
||||
}
|
||||
|
||||
if (count($download->get_display_ftp()) == 0) {
|
||||
|
||||
return $app->json(array('success' => false, 'message' => _('Documents can be sent by FTP')));
|
||||
} else {
|
||||
try {
|
||||
$download->prepare_export($app['phraseanet.user'], $app['filesystem'], $request->request->get('obj'), false, $request->request->get('businessfields'));
|
||||
$download->export_ftp($request->request->get('user_dest'), $address, $login, $request->request->get('pwd', ''), $request->request->get('ssl'), $request->request->get('nbretry'), $request->request->get('passif'), $destFolder, $folderTocreate, $request->request->get('logfile'));
|
||||
return $app->json(array('success' => false, 'message' => _("You do not have required rights to send these documents over FTP")));
|
||||
}
|
||||
|
||||
return $app->json(array(
|
||||
'success' => true,
|
||||
'message' => _('Export saved in the waiting queue')
|
||||
));
|
||||
} catch (\Exception $e) {
|
||||
try {
|
||||
$download->prepare_export(
|
||||
$app['phraseanet.user'],
|
||||
$app['filesystem'],
|
||||
$request->request->get('obj'),
|
||||
false,
|
||||
$request->request->get('businessfields')
|
||||
);
|
||||
|
||||
return $app->json(array(
|
||||
'success' => false,
|
||||
'message' => _('Something went wrong')
|
||||
));
|
||||
}
|
||||
$download->export_ftp(
|
||||
$request->request->get('user_dest'),
|
||||
$address,
|
||||
$login,
|
||||
$request->request->get('pwd', ''),
|
||||
$request->request->get('ssl'),
|
||||
$request->request->get('nbretry'),
|
||||
$request->request->get('passif'),
|
||||
$destFolder,
|
||||
$folderTocreate,
|
||||
$request->request->get('logfile')
|
||||
);
|
||||
|
||||
return $app->json(array(
|
||||
'success' => true,
|
||||
'message' => _('Export saved in the waiting queue')
|
||||
));
|
||||
} catch (\Exception $e) {
|
||||
|
||||
return $app->json(array(
|
||||
'success' => false,
|
||||
'message' => _('Something went wrong')
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +242,14 @@ class Export implements ControllerProviderInterface
|
||||
|
||||
//prepare export
|
||||
$download = new \set_export($app, $lst, $ssttid);
|
||||
$list = $download->prepare_export($app['phraseanet.user'], $app['filesystem'], $request->request->get('obj'), $request->request->get("type") == "title" ? : false, $request->request->get('businessfields'));
|
||||
$list = $download->prepare_export(
|
||||
$app['phraseanet.user'],
|
||||
$app['filesystem'],
|
||||
$request->request->get('obj'),
|
||||
$request->request->get("type") == "title" ? : false,
|
||||
$request->request->get('businessfields')
|
||||
);
|
||||
|
||||
$list['export_name'] = sprintf("%s.zip", $download->getExportName());
|
||||
$list['email'] = $request->request->get("destmail", "");
|
||||
|
||||
@@ -250,7 +275,12 @@ class Export implements ControllerProviderInterface
|
||||
|
||||
if (count($destMails) > 0 && $token) {
|
||||
//zip documents
|
||||
\set_export::build_zip(new Filesystem(), $token, $list, $app['phraseanet.registry']->get('GV_RootPath') . 'tmp/download/' . $token . '.zip');
|
||||
\set_export::build_zip(
|
||||
new Filesystem(),
|
||||
$token,
|
||||
$list,
|
||||
$app['phraseanet.registry']->get('GV_RootPath') . 'tmp/download/' . $token . '.zip'
|
||||
);
|
||||
|
||||
$remaingEmails = $destMails;
|
||||
|
||||
@@ -263,7 +293,16 @@ class Export implements ControllerProviderInterface
|
||||
|
||||
//send mails
|
||||
foreach ($destMails as $key => $mail) {
|
||||
if (\mail::send_documents($app, trim($mail), $url, $from, $endDateObject, $request->request->get('textmail'), $request->request->get('reading_confirm') == '1' ? : false)) {
|
||||
if (\mail::send_documents(
|
||||
$app,
|
||||
trim($mail),
|
||||
$url,
|
||||
$from,
|
||||
$endDateObject,
|
||||
$request->request->get('textmail'),
|
||||
$request->request->get('reading_confirm') == '1' ? : false
|
||||
)
|
||||
) {
|
||||
unset($remaingEmails[$key]);
|
||||
}
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Controller\Prod\Record;
|
||||
namespace Alchemy\Phrasea\Controller\Prod;
|
||||
|
||||
use Alchemy\Phrasea\Controller\RecordsRequest;
|
||||
use Silex\Application;
|
||||
@@ -18,11 +18,6 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Property implements ControllerProviderInterface
|
||||
{
|
||||
|
||||
@@ -122,36 +117,32 @@ class Property implements ControllerProviderInterface
|
||||
$statusBit = $nRec = array();
|
||||
|
||||
foreach ($records as $record) {
|
||||
//perform logic
|
||||
$sbasId = $record->get_databox()->get_sbas_id();
|
||||
|
||||
if ($this->isEligible($app, $record)) {
|
||||
//perform logic
|
||||
$sbasId = $record->get_databox()->get_sbas_id();
|
||||
if (!isset($nRec[$sbasId])) {
|
||||
$nRec[$sbasId] = array('stories' => 0, 'records' => 0);
|
||||
}
|
||||
|
||||
if (!isset($nRec[$sbasId])) {
|
||||
$nRec[$sbasId] = array('stories' => 0, 'records' => 0);
|
||||
}
|
||||
$nRec[$sbasId]['records']++;
|
||||
|
||||
$nRec[$sbasId]['records']++;
|
||||
if ($record->is_grouping()) {
|
||||
$nRec[$sbasId]['stories']++;
|
||||
}
|
||||
|
||||
if ($record->is_grouping()) {
|
||||
$nRec[$sbasId]['stories']++;
|
||||
}
|
||||
|
||||
if (!isset($statusBit[$sbasId])) {
|
||||
|
||||
$statusBit[$sbasId] = isset($databoxStatus[$sbasId]) ? $databoxStatus[$sbasId] : array();
|
||||
|
||||
foreach (array_keys($statusBit[$sbasId]) as $bit) {
|
||||
$statusBit[$sbasId][$bit]['nset'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$status = strrev($record->get_status());
|
||||
if (!isset($statusBit[$sbasId])) {
|
||||
$statusBit[$sbasId] = isset($databoxStatus[$sbasId]) ? $databoxStatus[$sbasId] : array();
|
||||
|
||||
foreach (array_keys($statusBit[$sbasId]) as $bit) {
|
||||
$statusBit[$sbasId][$bit]["nset"] += substr($status, $bit, 1) !== "0" ? 1 : 0;
|
||||
$statusBit[$sbasId][$bit]['nset'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$status = strrev($record->get_status());
|
||||
|
||||
foreach (array_keys($statusBit[$sbasId]) as $bit) {
|
||||
$statusBit[$sbasId][$bit]["nset"] += substr($status, $bit, 1) !== "0" ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($records->databoxes() as $databox) {
|
||||
@@ -186,21 +177,18 @@ class Property implements ControllerProviderInterface
|
||||
$recordsType = array();
|
||||
|
||||
foreach ($records as $record) {
|
||||
//perform logic
|
||||
$sbasId = $record->get_databox()->get_sbas_id();
|
||||
|
||||
if ($this->isEligible($app, $record)) {
|
||||
//perform logic
|
||||
$sbasId = $record->get_databox()->get_sbas_id();
|
||||
|
||||
if (!isset($recordsType[$sbasId])) {
|
||||
$recordsType[$sbasId] = array();
|
||||
}
|
||||
|
||||
if (!isset($recordsType[$sbasId][$record->get_type()])) {
|
||||
$recordsType[$sbasId][$record->get_type()] = array();
|
||||
}
|
||||
|
||||
$recordsType[$sbasId][$record->get_type()][] = $record;
|
||||
if (!isset($recordsType[$sbasId])) {
|
||||
$recordsType[$sbasId] = array();
|
||||
}
|
||||
|
||||
if (!isset($recordsType[$sbasId][$record->get_type()])) {
|
||||
$recordsType[$sbasId][$record->get_type()] = array();
|
||||
}
|
||||
|
||||
$recordsType[$sbasId][$record->get_type()][] = $record;
|
||||
}
|
||||
|
||||
return new Response($app['twig']->render('prod/actions/Property/type.html.twig', array(
|
||||
@@ -305,38 +293,6 @@ class Property implements ControllerProviderInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Application $app
|
||||
* @param record_adapter $record
|
||||
* @return boolean
|
||||
*/
|
||||
private function isEligible(Application $app, \record_adapter $record)
|
||||
{
|
||||
$eligible = false;
|
||||
|
||||
if (!$app['phraseanet.user']->ACL()->has_hd_grant($record) ||
|
||||
!$app['phraseanet.user']->ACL()->has_preview_grant($record)) {
|
||||
try {
|
||||
$stmt = $record->get_databox()->get_connection()->prepare(sprintf('SELECT record_id FROM record WHERE ((status ^ %s) & %s) = 0 AND record_id = :record_id', $app['phraseanet.user']->ACL()->get_mask_xor($record->get_base_id()), $app['phraseanet.user']->ACL()->get_mask_and($record->get_base_id())));
|
||||
$stmt->execute(array(':record_id' => $record->get_record_id()));
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$eligible = true;
|
||||
}
|
||||
|
||||
$stmt->closeCursor();
|
||||
unset($stmt);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
} else {
|
||||
$eligible = true;
|
||||
}
|
||||
|
||||
return $eligible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefix the method to call with the controller class name
|
||||
*
|
@@ -9,21 +9,15 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Controller\Prod\Records;
|
||||
namespace Alchemy\Phrasea\Controller\Prod;
|
||||
|
||||
use Alchemy\Phrasea\Controller\RecordsRequest;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Deletion implements ControllerProviderInterface
|
||||
class Records implements ControllerProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -32,12 +26,10 @@ class Deletion implements ControllerProviderInterface
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->before(function(Request $request) use ($app) {
|
||||
$response = $app['firewall']->requireNotGuest();
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
});
|
||||
$app['firewall']->requireNotGuest();
|
||||
});
|
||||
|
||||
/**
|
||||
* Delete a record or a list of records
|
||||
@@ -52,7 +44,7 @@ class Deletion implements ControllerProviderInterface
|
||||
*
|
||||
* return : JSON Response
|
||||
*/
|
||||
$controllers->post('/', $this->call('deleteRecord'))
|
||||
$controllers->post('/delete/', $this->call('doDeleteRecords'))
|
||||
->bind('record_delete');
|
||||
|
||||
/**
|
||||
@@ -60,15 +52,15 @@ class Deletion implements ControllerProviderInterface
|
||||
*
|
||||
* name : record_what_can_i_delete
|
||||
*
|
||||
* description : Save CSS preferences
|
||||
* description : Verify if I can delete records
|
||||
*
|
||||
* method : POST
|
||||
*
|
||||
* parameters : none
|
||||
*
|
||||
* return : JSON Response
|
||||
* return : HTML Response
|
||||
*/
|
||||
$controllers->get('/', $this->call('whatCanIDelete'))
|
||||
$controllers->post('/delete/what/', $this->call('whatCanIDelete'))
|
||||
->bind('record_what_can_i_delete');
|
||||
|
||||
/**
|
||||
@@ -97,11 +89,11 @@ class Deletion implements ControllerProviderInterface
|
||||
* @param Request $request
|
||||
* @return HtmlResponse
|
||||
*/
|
||||
public function deleteRecord(Application $app, Request $request)
|
||||
public function doDeleteRecords(Application $app, Request $request)
|
||||
{
|
||||
$records = RecordsRequest::fromRequest($app, $request, !!$app->request->get('del_children'), array(
|
||||
'candeleterecord'
|
||||
));
|
||||
'candeleterecord'
|
||||
));
|
||||
|
||||
$basketElementsRepository = $app['EM']->getRepository('\Entities\BasketElement');
|
||||
$deleted = array();
|
||||
@@ -137,13 +129,13 @@ class Deletion implements ControllerProviderInterface
|
||||
public function whatICanDelete(Application $app, Request $request)
|
||||
{
|
||||
$records = RecordsRequest::fromRequest($app, $request, !!$app->request->get('del_children'), array(
|
||||
'candeleterecord'
|
||||
));
|
||||
'candeleterecord'
|
||||
));
|
||||
|
||||
return $app['twig']->render('prod/actions/delete_records_confirm.html.twig', array(
|
||||
'lst' => explode(';', $records->serializedList()),
|
||||
'groupings' => $records->stories()->count(),
|
||||
));
|
||||
'lst' => $records->serializedList(),
|
||||
'groupings' => $records->stories()->count(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -16,11 +16,6 @@ use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Share implements ControllerProviderInterface
|
||||
{
|
||||
|
||||
|
@@ -16,11 +16,6 @@ use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Notifications implements ControllerProviderInterface
|
||||
{
|
||||
|
||||
@@ -30,11 +25,11 @@ class Notifications implements ControllerProviderInterface
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->before(function(Request $request) use ($app) {
|
||||
$app['firewall']->requireNotGuest();
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Read all notifications
|
||||
*
|
||||
@@ -64,7 +59,7 @@ class Notifications implements ControllerProviderInterface
|
||||
*
|
||||
* return : JSON Response
|
||||
*/
|
||||
$controllers->post('/read/', $this->call('setNotificationsReaded'))
|
||||
$controllers->post('/read/', $this->call('readNotifications'))
|
||||
->bind('set_notifications_readed');
|
||||
|
||||
return $controllers;
|
||||
@@ -77,14 +72,17 @@ class Notifications implements ControllerProviderInterface
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function setNotificationsReaded(Application $app, Request $request)
|
||||
public function readNotifications(Application $app, Request $request)
|
||||
{
|
||||
if (!$request->isXmlHttpRequest()) {
|
||||
$app->abort(400);
|
||||
}
|
||||
|
||||
try {
|
||||
$app['events-manager']->read(explode('_', (string) $request->request->get('notifications')), $app['phraseanet.user']->get_id());
|
||||
$app['events-manager']->read(
|
||||
explode('_', (string) $request->request->get('notifications')),
|
||||
$app['phraseanet.user']->get_id()
|
||||
);
|
||||
|
||||
return $app->json(array('success' => true, 'message' => ''));
|
||||
} catch (\Exception $e) {
|
||||
|
@@ -25,6 +25,7 @@ class Preferences implements ControllerProviderInterface
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->before(function(Request $request) use ($app) {
|
||||
$app['firewall']->requireAuthentication();
|
||||
});
|
||||
@@ -83,7 +84,7 @@ class Preferences implements ControllerProviderInterface
|
||||
$msg = _('Error while saving preference');
|
||||
|
||||
if ($prop && $value) {
|
||||
$app['session']->set('pref.' . $prop, $value);
|
||||
$app['session']->set('phraseanet.' . $prop, $value);
|
||||
$success = true;
|
||||
$msg = _('Preference saved !');
|
||||
}
|
||||
|
@@ -753,3 +753,4 @@
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
|
@@ -31,8 +31,19 @@ class SetupTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
*/
|
||||
public function testPostGlobals()
|
||||
{
|
||||
// $this->setAdmin(true);
|
||||
$registry = $this->getMockBuilder('\registry')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$registry->expects($this->atLeastOnce())
|
||||
->method('set')
|
||||
->with(
|
||||
$this->stringStartsWith('GV_'),
|
||||
$this->anything(),
|
||||
$this->isType('string'));
|
||||
|
||||
self::$DI['app']['phraseanet.registry'] = $registry;
|
||||
self::$DI['client'] = new Symfony\Component\HttpKernel\Client(self::$DI['app']);
|
||||
self::$DI['client']->request('POST', '/admin/setup/');
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||
}
|
||||
|
@@ -5,19 +5,29 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
|
||||
use Alchemy\Phrasea\Controller\Prod\Export;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @todo Test Alchemy\Phrasea\Controller\Prod\Export::exportMail
|
||||
*/
|
||||
class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
protected $client;
|
||||
protected static $GV_activeFTP;
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
if(self::$GV_activeFTP) {
|
||||
self::$DI['app']['phraseanet.registry']->set('GV_activeFTP', true, \registry::TYPE_BOOLEAN);
|
||||
}
|
||||
|
||||
self::$GV_activeFTP = null;
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete inserted rows from FTP export
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
self::$DI['app']['phraseanet.registry']->set('GV_activeFTP', self::$GV_activeFTP, \registry::TYPE_BOOLEAN);
|
||||
self::$GV_activeFTP = null;
|
||||
|
||||
$conn = self::$DI['app']['phraseanet.appbox']->get_connection();
|
||||
|
||||
$sql = 'DELETE FROM ftp_export WHERE mail = :email_dest';
|
||||
@@ -32,6 +42,7 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$stmtElements->closeCursor();
|
||||
|
||||
unset($conn, $stmtFtp, $stmtElements);
|
||||
parent::tearDownAfterClass();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,11 +63,11 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
$framework = $this;
|
||||
self::$DI['app']['phraseanet.ftp.client'] = self::$DI['app']->protect(function($host, $port = 21, $timeout = 90, $ssl = false, $proxy = false, $proxyport = false) use ($framework) {
|
||||
return $framework->getMockBuilder('\ftpclient')
|
||||
->setMethods(array('login', 'close'))
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
});
|
||||
return $framework->getMockBuilder('\ftpclient')
|
||||
->setMethods(array('login', 'close'))
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
});
|
||||
|
||||
$this->XMLHTTPRequest('POST', '/prod/export/ftp/test/', array('lst' => self::$DI['record_1']->get_serialize_key()));
|
||||
$response = self::$DI['client']->getResponse();
|
||||
@@ -75,17 +86,17 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
$framework = $this;
|
||||
self::$DI['app']['phraseanet.ftp.client'] = self::$DI['app']->protect(function($host, $port = 21, $timeout = 90, $ssl = false, $proxy = false, $proxyport = false) use ($framework) {
|
||||
$ftpStub = $framework->getMockBuilder('\ftpclient')
|
||||
->setMethods(array('login', 'close'))
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$ftpStub = $framework->getMockBuilder('\ftpclient')
|
||||
->setMethods(array('login', 'close'))
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$ftpStub->expects($framework->once())
|
||||
->method('login')
|
||||
->will($framework->throwException(new \Exception()));
|
||||
$ftpStub->expects($framework->once())
|
||||
->method('login')
|
||||
->will($framework->throwException(new \Exception()));
|
||||
|
||||
return $ftpStub;
|
||||
});
|
||||
return $ftpStub;
|
||||
});
|
||||
|
||||
self::$DI['client']->request('POST', '/prod/export/ftp/test/', array('lst' => self::$DI['record_1']->get_serialize_key()));
|
||||
$response = self::$DI['client']->getResponse();
|
||||
@@ -132,24 +143,27 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Export::exportFtp
|
||||
*/
|
||||
public function testExportFtp()
|
||||
{
|
||||
self::$GV_activeFTP = self::$DI['app']['phraseanet.registry']->get('GV_activeFTP');
|
||||
self::$DI['app']['phraseanet.registry']->set('GV_activeFTP', '1', \registry::TYPE_BOOLEAN);
|
||||
|
||||
if (!self::$DI['app']['phraseanet.registry']->get('GV_activeFTP')) {
|
||||
self::$DI['app']['phraseanet.registry']->set('GV_activeFTP', true, \registry::TYPE_BOOLEAN);
|
||||
self::$GV_activeFTP = true;
|
||||
}
|
||||
//inserted rows from this function are deleted in tearDownAfterClass
|
||||
self::$DI['client']->request('POST', '/prod/export/ftp/', array(
|
||||
'lst' => self::$DI['record_2']->get_serialize_key(),
|
||||
'user_dest' => self::$DI['user']->get_id(),
|
||||
'addr' => 'local.phrasea.test',
|
||||
'login' => self::$DI['user']->get_email(),
|
||||
'destfolder' => '/home/test/',
|
||||
'NAMMKDFOLD' => 'test2/',
|
||||
'obj' => array('preview')
|
||||
));
|
||||
'lst' => self::$DI['record_1']->get_serialize_key(),
|
||||
'user_dest' => self::$DI['user']->get_id(),
|
||||
'addr' => 'local.phrasea.test',
|
||||
'login' => self::$DI['user']->get_email(),
|
||||
'destfolder' => '/home/test/',
|
||||
'NAMMKDFOLD' => 'test2/',
|
||||
'obj' => array('preview')
|
||||
));
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
$datas = (array) json_decode($response->getContent());
|
||||
@@ -165,11 +179,9 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
*/
|
||||
public function testRequireAuthentication()
|
||||
{
|
||||
$this->markTestSkipped();
|
||||
$this->logout(self::$DI['app']);
|
||||
self::$DI['client']->request('POST', '/prod/export/multi-export/');
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||
}
|
||||
/**
|
||||
* @todo Test Alchemy\Phrasea\Controller\Prod\Export::exportMail
|
||||
*/
|
||||
}
|
||||
|
@@ -1,16 +1,13 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
||||
|
||||
use Alchemy\Phrasea\Controller\Prod\Record\Property;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
||||
|
||||
class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
{
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Record\Property::displayStatusProperty
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Property::displayStatusProperty
|
||||
*/
|
||||
public function testDisplayStatusProperty()
|
||||
{
|
||||
@@ -22,7 +19,7 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Record\Property::displayStatusProperty
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Property::displayStatusProperty
|
||||
*/
|
||||
public function testDisplayStatusPropertyNotXMLHTTPRequets()
|
||||
{
|
||||
@@ -30,7 +27,7 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Record\Property::displayTypeProperty
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Property::displayTypeProperty
|
||||
*/
|
||||
public function testDisplayTypeProperty()
|
||||
{
|
||||
@@ -42,7 +39,7 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Record\Property::displayProperty
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Property::displayProperty
|
||||
*/
|
||||
public function testDisplayTypePropertyNotXMLHTTPRequets()
|
||||
{
|
||||
@@ -50,19 +47,19 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Record\Property::changeStatus
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Property::changeStatus
|
||||
*/
|
||||
public function testChangeStatus()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/prod/records/property/status/', array(
|
||||
'apply_to_children' => array(self::$DI['record_story_1']->get_sbas_id() => true),
|
||||
'status' => array(
|
||||
self::$DI['record_1']->get_sbas_id() => array(6 => true, 8 => true, 11 => true)
|
||||
),
|
||||
'lst' => implode(';', array(
|
||||
self::$DI['record_1']->get_serialize_key(), self::$DI['record_story_1']->get_serialize_key()
|
||||
))
|
||||
));
|
||||
'apply_to_children' => array(self::$DI['record_story_1']->get_sbas_id() => true),
|
||||
'status' => array(
|
||||
self::$DI['record_1']->get_sbas_id() => array(6 => true, 8 => true, 11 => true)
|
||||
),
|
||||
'lst' => implode(';', array(
|
||||
self::$DI['record_1']->get_serialize_key(), self::$DI['record_story_1']->get_serialize_key()
|
||||
))
|
||||
));
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$datas = (array) json_decode($response->getContent());
|
||||
$this->assertArrayHasKey('success', $datas);
|
||||
@@ -94,19 +91,19 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Record\Property::changeType
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Property::changeType
|
||||
*/
|
||||
public function testChangeType()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/prod/records/property/type/', array(
|
||||
'lst' => implode(';', array(
|
||||
self::$DI['record_1']->get_serialize_key(), self::$DI['record_2']->get_serialize_key()
|
||||
)),
|
||||
'types' => array(
|
||||
self::$DI['record_1']->get_serialize_key() => 'document',
|
||||
self::$DI['record_2']->get_serialize_key() => 'flash',
|
||||
)
|
||||
));
|
||||
'lst' => implode(';', array(
|
||||
self::$DI['record_1']->get_serialize_key(), self::$DI['record_2']->get_serialize_key()
|
||||
)),
|
||||
'types' => array(
|
||||
self::$DI['record_1']->get_serialize_key() => 'document',
|
||||
self::$DI['record_2']->get_serialize_key() => 'flash',
|
||||
)
|
||||
));
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$datas = (array) json_decode($response->getContent());
|
||||
$this->assertArrayHasKey('success', $datas);
|
@@ -90,6 +90,10 @@ class ShareTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
->method('ACL')
|
||||
->will($this->returnValue($stubbedACL));
|
||||
|
||||
$share->shareRecord(self::$DI['app'], $this->getMock('Symfony\Component\HttpFoundation\Request'), self::$DI['record_1']->get_base_id(), self::$DI['record_1']->get_record_id());
|
||||
$share->shareRecord(
|
||||
self::$DI['app'],
|
||||
$this->getMock('Symfony\Component\HttpFoundation\Request'),
|
||||
self::$DI['record_1']->get_base_id(), self::$DI['record_1']->get_record_id()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -495,7 +495,7 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract
|
||||
$available_medium = array('image', 'audio', 'video');
|
||||
array_walk($content, $this->removeBadItems($content, $available_medium));
|
||||
$media_group = $xpath->query("/rss/channel/item[" . $count . "]/media:group");
|
||||
$this->assertEquals(sizeof($content), $media_group->length);
|
||||
$this->assertEquals(sizeof($content), $media_group->length, sizeof($content)." != ".$media_group->length);
|
||||
|
||||
foreach ($media_group as $media) {
|
||||
$entry_item = array_shift($content);
|
||||
|
@@ -44,13 +44,13 @@ class NotificationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
public function testSetNotificationsReaded()
|
||||
{
|
||||
$this->XMLHTTPRequest('POST', '/user/notifications/read/', array(
|
||||
'notifications' => array()
|
||||
));
|
||||
'notifications' => ''
|
||||
));
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
$datas = (array) json_decode($response->getContent());
|
||||
$this->assertArrayHasKey('success', $datas);
|
||||
$this->assertTrue($datas['success']);
|
||||
$this->assertTrue($datas['success'], $response->getContent());
|
||||
$this->assertArrayHasKey('message', $datas);
|
||||
unset($response);
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ class Bridge_ApiTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
$this->assertTrue($this->object->is_disabled());
|
||||
sleep(3);
|
||||
$update2 = $this->object->get_updated_on();
|
||||
$this->assertTrue($update2 > $update1);
|
||||
$this->assertTrue($update2 > $update1, $update2->format('Y-m-d, H:i:s') ." sould be > to " . $update1->format('Y-m-d, H:i:s'));
|
||||
$this->assertFalse($this->object->is_disabled());
|
||||
$this->object->enable();
|
||||
$this->assertFalse($this->object->is_disabled());
|
||||
|
@@ -23,7 +23,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
*
|
||||
* @var \Pimple
|
||||
*/
|
||||
protected static $DI;
|
||||
public static $DI;
|
||||
protected static $testsTime = array();
|
||||
protected static $records;
|
||||
public static $recordsInitialized = false;
|
||||
@@ -139,6 +139,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
self::$DI['client'] = self::$DI->share(function($DI) {
|
||||
return new Client($DI['app'], array());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
@@ -158,11 +159,15 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
|
||||
parent::tearDown();
|
||||
|
||||
$duration = (microtime(true) - $this->start);
|
||||
// $duration = (microtime(true) - $this->start);
|
||||
// if ($duration > 0.75) {
|
||||
// echo "test in " . get_class($this) . " last " . $duration . "\n";
|
||||
// }
|
||||
$this->start = null;
|
||||
|
||||
//In case some executed script modify 'max_execution_time' ini var
|
||||
//Initialize set_time_limit(0) which is the default value for PHP CLI
|
||||
set_time_limit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user