This commit is contained in:
Nicolas Le Goff
2014-07-17 15:17:04 +02:00
parent fcdc10c554
commit 66fa05f4ee
92 changed files with 336 additions and 406 deletions

View File

@@ -311,7 +311,7 @@ class Application extends SilexApplication
$this->register(new SessionHandlerServiceProvider()); $this->register(new SessionHandlerServiceProvider());
$this->register(new SessionServiceProvider(), [ $this->register(new SessionServiceProvider(), [
'session.test' => $this->getEnvironment() === static::ENV_TEST, 'session.test' => $this->getEnvironment() === static::ENV_TEST,
'session.storage.options' => array('cookie_lifetime' => 0) 'session.storage.options' => ['cookie_lifetime' => 0]
]); ]);
$this['session.storage.test'] = $this->share(function ($app) { $this['session.storage.test'] = $this->share(function ($app) {
@@ -467,7 +467,7 @@ class Application extends SilexApplication
$this['dispatcher'] = $this->share( $this['dispatcher'] = $this->share(
$this->extend('dispatcher', function ($dispatcher, Application $app) { $this->extend('dispatcher', function ($dispatcher, Application $app) {
$dispatcher->addListener(KernelEvents::RESPONSE, array($app, 'addUTF8Charset'), -128); $dispatcher->addListener(KernelEvents::RESPONSE, [$app, 'addUTF8Charset'], -128);
$dispatcher->addSubscriber($app['phraseanet.logout-subscriber']); $dispatcher->addSubscriber($app['phraseanet.logout-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.locale-subscriber']); $dispatcher->addSubscriber($app['phraseanet.locale-subscriber']);
$dispatcher->addSubscriber($app['phraseanet.maintenance-subscriber']); $dispatcher->addSubscriber($app['phraseanet.maintenance-subscriber']);
@@ -649,8 +649,8 @@ class Application extends SilexApplication
})); }));
$twig->addFilter(new \Twig_SimpleFilter('highlight', function (\Twig_Environment $twig, $string) { $twig->addFilter(new \Twig_SimpleFilter('highlight', function (\Twig_Environment $twig, $string) {
return str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), $string); return str_replace(['[[em]]', '[[/em]]'], ['<em>', '</em>'], $string);
}, array('needs_environment' => true,'is_safe' => array('html')))); }, ['needs_environment' => true,'is_safe' => ['html']]));
$twig->addFilter(new \Twig_SimpleFilter('linkify', function (\Twig_Environment $twig, $string) { $twig->addFilter(new \Twig_SimpleFilter('linkify', function (\Twig_Environment $twig, $string) {
return preg_replace( return preg_replace(
@@ -658,7 +658,7 @@ class Application extends SilexApplication
, '$1 $2 <a title="' . _('Open the URL in a new window') . '" class="ui-icon ui-icon-extlink" href="$2" style="display:inline;padding:2px 5px;margin:0 4px 0 2px;" target="_blank"> &nbsp;</a>$7' , '$1 $2 <a title="' . _('Open the URL in a new window') . '" class="ui-icon ui-icon-extlink" href="$2" style="display:inline;padding:2px 5px;margin:0 4px 0 2px;" target="_blank"> &nbsp;</a>$7'
, $string , $string
); );
}, array('needs_environment' => true, 'is_safe' => array('html')))); }, ['needs_environment' => true, 'is_safe' => ['html']]));
$twig->addFilter(new \Twig_SimpleFilter('bounce', function (\Twig_Environment $twig, $fieldValue, $fieldName, $searchRequest, $sbasId) { $twig->addFilter(new \Twig_SimpleFilter('bounce', function (\Twig_Environment $twig, $fieldValue, $fieldName, $searchRequest, $sbasId) {
// bounce value if it is present in thesaurus as well // bounce value if it is present in thesaurus as well
@@ -670,7 +670,7 @@ class Application extends SilexApplication
. $fieldValue . $fieldValue
. "</a>"; . "</a>";
}, array('needs_environment' => true, 'is_safe' => array('html')))); }, ['needs_environment' => true, 'is_safe' => ['html']]));
$twig->addFilter(new \Twig_SimpleFilter('escapeDoubleQuote', function ($value) { $twig->addFilter(new \Twig_SimpleFilter('escapeDoubleQuote', function ($value) {
return str_replace('"', '\"', $value); return str_replace('"', '\"', $value);

View File

@@ -342,10 +342,10 @@ class RegenerateSqliteDb extends Command
$event = new WebhookEvent(); $event = new WebhookEvent();
$event->setName(WebhookEvent::NEW_FEED_ENTRY); $event->setName(WebhookEvent::NEW_FEED_ENTRY);
$event->setType(WebhookEvent::FEED_ENTRY_TYPE); $event->setType(WebhookEvent::FEED_ENTRY_TYPE);
$event->setData(array( $event->setData([
'feed_id' => $DI['feed_public_entry']->getFeed()->getId(), 'feed_id' => $DI['feed_public_entry']->getFeed()->getId(),
'entry_id' => $DI['feed_public_entry']->getId() 'entry_id' => $DI['feed_public_entry']->getId()
)); ]);
$em->persist($event); $em->persist($event);
$DI['event_webhook_1'] = $event; $DI['event_webhook_1'] = $event;
@@ -353,10 +353,10 @@ class RegenerateSqliteDb extends Command
$event2 = new WebhookEvent(); $event2 = new WebhookEvent();
$event2->setName(WebhookEvent::NEW_FEED_ENTRY); $event2->setName(WebhookEvent::NEW_FEED_ENTRY);
$event2->setType(WebhookEvent::FEED_ENTRY_TYPE); $event2->setType(WebhookEvent::FEED_ENTRY_TYPE);
$event2->setData(array( $event2->setData([
'feed_id' => $DI['feed_public_entry']->getFeed()->getId(), 'feed_id' => $DI['feed_public_entry']->getFeed()->getId(),
'entry_id' => $DI['feed_public_entry']->getId() 'entry_id' => $DI['feed_public_entry']->getId()
)); ]);
$event2->setProcessed(true); $event2->setProcessed(true);
$em->persist($event2); $em->persist($event2);
} }

View File

@@ -254,11 +254,11 @@ class Collection implements ControllerProviderInterface
} }
if ('json' === $app['request']->getRequestFormat()) { if ('json' === $app['request']->getRequestFormat()) {
return $app->json(array( return $app->json([
'success' => $success, 'success' => $success,
'msg' => $msg, 'msg' => $msg,
'bas_id' => $collection->get_base_id() 'bas_id' => $collection->get_base_id()
)); ]);
} }
return $app->redirectPath('admin_display_collection', [ return $app->redirectPath('admin_display_collection', [

View File

@@ -530,7 +530,7 @@ class Users implements ControllerProviderInterface
]; ];
$nbUsrToAdd = 0; $nbUsrToAdd = 0;
$lines = array(); $lines = [];
$app['csv.interpreter']->addObserver(function (array $row) use (&$lines) { $app['csv.interpreter']->addObserver(function (array $row) use (&$lines) {
$lines[] = $row; $lines[] = $row;
}); });

View File

@@ -1431,7 +1431,7 @@ class V1 implements ControllerProviderInterface
public function get_publications(Application $app, Request $request) public function get_publications(Application $app, Request $request)
{ {
$user = $app['authentication']->getUser(); $user = $app['authentication']->getUser();
$restrictions = (array) ($request->get('feeds') ? : array()); $restrictions = (array) ($request->get('feeds') ? : []);
$feed = Aggregate::createFromUser($app, $user, $restrictions); $feed = Aggregate::createFromUser($app, $user, $restrictions);

View File

@@ -72,11 +72,10 @@ class Datafiles extends AbstractDelivery
->get_subdef_structure() ->get_subdef_structure()
->get_subdef($record->get_type(), $subdef) ->get_subdef($record->get_type(), $subdef)
->get_class(); ->get_class();
} catch(\Exception_Databox_SubdefNotFound $e) { } catch (\Exception_Databox_SubdefNotFound $e) {
} }
if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $app['acl']->get($app['authentication']->getUser())->has_preview_grant($record)) { if ($subdef_class == \databox_subdef::CLASS_PREVIEW && $app['acl']->get($app['authentication']->getUser())->has_preview_grant($record)) {
$watermark = false; $watermark = false;
} elseif ($subdef_class == \databox_subdef::CLASS_DOCUMENT && $app['acl']->get($app['authentication']->getUser())->has_hd_grant($record)) { } elseif ($subdef_class == \databox_subdef::CLASS_DOCUMENT && $app['acl']->get($app['authentication']->getUser())->has_hd_grant($record)) {

View File

@@ -217,9 +217,9 @@ class Push implements ControllerProviderInterface
$app['EM']->flush(); $app['EM']->flush();
$arguments = array( $arguments = [
'basket' => $Basket->getId(), 'basket' => $Basket->getId(),
); ];
if (!$app['conf']->get(['registry', 'actions', 'enable-push-authentication']) || !$request->get('force_authentication')) { if (!$app['conf']->get(['registry', 'actions', 'enable-push-authentication']) || !$request->get('force_authentication')) {
$arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $user_receiver); $arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $user_receiver);
@@ -412,14 +412,14 @@ class Push implements ControllerProviderInterface
$app['EM']->flush(); $app['EM']->flush();
$arguments = array( $arguments = [
'basket' => $Basket->getId(), 'basket' => $Basket->getId(),
); ];
if (!$app['conf']->get(['registry', 'actions', 'enable-push-authentication']) || !$request->get('force_authentication')) { if (!$app['conf']->get(['registry', 'actions', 'enable-push-authentication']) || !$request->get('force_authentication')) {
$arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $participant_user); $arguments['LOG'] = $app['manipulator.token']->createBasketAccessToken($Basket, $participant_user);
} }
$url = $app->url('lightbox_validation', $arguments); $url = $app->url('lightbox_validation', $arguments);
$receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : ''; $receipt = $request->get('recept') ? $app['authentication']->getUser()->getEmail() : '';

View File

@@ -135,7 +135,7 @@ class Records implements ControllerProviderInterface
'record' => $record 'record' => $record
]), ]),
"pos" => $record->get_number(), "pos" => $record->get_number(),
"title" => str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), $record->get_title($query, $searchEngine)) "title" => str_replace(['[[em]]', '[[/em]]'], ['<em>', '</em>'], $record->get_title($query, $searchEngine))
]); ]);
} }

View File

@@ -99,10 +99,10 @@ class Tooltip implements ControllerProviderInterface
public function displayPreview(Application $app, $sbas_id, $record_id) public function displayPreview(Application $app, $sbas_id, $record_id)
{ {
return $app['twig']->render('prod/Tooltip/Preview.html.twig', array( return $app['twig']->render('prod/Tooltip/Preview.html.twig', [
'record' => new \record_adapter($app, $sbas_id, $record_id), 'record' => new \record_adapter($app, $sbas_id, $record_id),
'not_wrapped' => true 'not_wrapped' => true
)); ]);
} }
public function displayCaption(Application $app, $sbas_id, $record_id, $context) public function displayCaption(Application $app, $sbas_id, $record_id, $context)

View File

@@ -217,18 +217,18 @@ class Activity implements ControllerProviderInterface
$report = $activity->getTopQuestion($conf); $report = $activity->getTopQuestion($conf);
return $app->json(array( return $app->json([
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [
'result' => isset($report['report']) ? $report['report'] : $report, 'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false, 'is_infouser' => false,
'is_nav' => false, 'is_nav' => false,
'is_groupby' => false, 'is_groupby' => false,
'is_plot' => false, 'is_plot' => false,
'is_doc' => false 'is_doc' => false
)), ]),
'display_nav' => false, 'display_nav' => false,
'title' => false 'title' => false
)); ]);
} }
/** /**
@@ -276,18 +276,18 @@ class Activity implements ControllerProviderInterface
$report = $activity->getTopQuestion($conf, true); $report = $activity->getTopQuestion($conf, true);
return $app->json(array( return $app->json([
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [
'result' => isset($report['report']) ? $report['report'] : $report, 'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false, 'is_infouser' => false,
'is_nav' => false, 'is_nav' => false,
'is_groupby' => false, 'is_groupby' => false,
'is_plot' => false, 'is_plot' => false,
'is_doc' => false 'is_doc' => false
)), ]),
'display_nav' => false, 'display_nav' => false,
'title' => false 'title' => false
)); ]);
} }
/** /**
@@ -320,18 +320,18 @@ class Activity implements ControllerProviderInterface
$report = $activity->getActivityPerHours(); $report = $activity->getActivityPerHours();
return $app->json(array( return $app->json([
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [
'result' => isset($report['report']) ? $report['report'] : $report, 'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false, 'is_infouser' => false,
'is_nav' => false, 'is_nav' => false,
'is_groupby' => false, 'is_groupby' => false,
'is_plot' => true, 'is_plot' => true,
'is_doc' => false 'is_doc' => false
)), ]),
'display_nav' => false, 'display_nav' => false,
'title' => false 'title' => false
)); ]);
} }
/** /**
@@ -380,18 +380,18 @@ class Activity implements ControllerProviderInterface
$report = $activity->getDownloadByBaseByDay($conf); $report = $activity->getDownloadByBaseByDay($conf);
return $app->json(array( return $app->json([
'rs' => $app['twig']->render('report/ajax_data_content.html.twig', array( 'rs' => $app['twig']->render('report/ajax_data_content.html.twig', [
'result' => isset($report['report']) ? $report['report'] : $report, 'result' => isset($report['report']) ? $report['report'] : $report,
'is_infouser' => false, 'is_infouser' => false,
'is_nav' => false, 'is_nav' => false,
'is_groupby' => false, 'is_groupby' => false,
'is_plot' => false, 'is_plot' => false,
'is_doc' => false 'is_doc' => false
)), ]),
'display_nav' => false, 'display_nav' => false,
'title' => false 'title' => false
)); ]);
} }
/** /**
@@ -852,7 +852,7 @@ class Activity implements ControllerProviderInterface
private function getCSVResponse(Application $app, \module_report $report, $type) private function getCSVResponse(Application $app, \module_report $report, $type)
{ {
// set headers // set headers
$headers = array(); $headers = [];
foreach (array_keys($report->getDisplay()) as $k) { foreach (array_keys($report->getDisplay()) as $k) {
$headers[$k] = $k; $headers[$k] = $k;
} }

View File

@@ -471,7 +471,6 @@ class Informations implements ControllerProviderInterface
$reportArray = $info->buildTabGrpInfo(false, [], $request->request->get('user'), $conf, false); $reportArray = $info->buildTabGrpInfo(false, [], $request->request->get('user'), $conf, false);
if ($request->request->get('printcsv') == 'on' && isset($download)) { if ($request->request->get('printcsv') == 'on' && isset($download)) {
return $this->getCSVResponse($app, $info, 'info_user'); return $this->getCSVResponse($app, $info, 'info_user');
} }
@@ -512,7 +511,7 @@ class Informations implements ControllerProviderInterface
private function getCSVResponse(Application $app, \module_report $report, $type) private function getCSVResponse(Application $app, \module_report $report, $type)
{ {
// set headers // set headers
$headers = array(); $headers = [];
foreach (array_keys($report->getDisplay()) as $k) { foreach (array_keys($report->getDisplay()) as $k) {
$headers[$k] = $k; $headers[$k] = $k;
} }

View File

@@ -482,7 +482,7 @@ class Root implements ControllerProviderInterface
]; ];
if ($request->request->get('printcsv') == 'on') { if ($request->request->get('printcsv') == 'on') {
$result = array(); $result = [];
$result[] = array_keys($conf_nav); $result[] = array_keys($conf_nav);
foreach ($report['nav']['result'] as $row) { foreach ($report['nav']['result'] as $row) {
@@ -677,7 +677,7 @@ class Root implements ControllerProviderInterface
private function getCSVResponse(Application $app, \module_report $report, $type) private function getCSVResponse(Application $app, \module_report $report, $type)
{ {
// set headers // set headers
$headers = array(); $headers = [];
foreach (array_keys($report->getDisplay()) as $k) { foreach (array_keys($report->getDisplay()) as $k) {
$headers[$k] = $k; $headers[$k] = $k;
} }

View File

@@ -25,7 +25,6 @@ use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Account implements ControllerProviderInterface class Account implements ControllerProviderInterface
{ {

View File

@@ -18,7 +18,6 @@ use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Developers implements ControllerProviderInterface class Developers implements ControllerProviderInterface
{ {
@@ -116,7 +115,6 @@ class Developers implements ControllerProviderInterface
return $app->json(['success' => true]); return $app->json(['success' => true]);
} }
/** /**
* Change application webhook * Change application webhook
* *
@@ -137,7 +135,7 @@ class Developers implements ControllerProviderInterface
return $app->json(['success' => false]); return $app->json(['success' => false]);
} }
return $app->json(array('success' => true)); return $app->json(['success' => true]);
} }
/** /**
@@ -159,7 +157,7 @@ class Developers implements ControllerProviderInterface
$app->abort(404, sprintf('Account not found for application %s', $application->getName())); $app->abort(404, sprintf('Account not found for application %s', $application->getName()));
} }
if(null !== $devToken = $app['repo.api-oauth-tokens']->findDeveloperToken($account)) { if (null !== $devToken = $app['repo.api-oauth-tokens']->findDeveloperToken($account)) {
$app['manipulator.api-oauth-token']->renew($devToken); $app['manipulator.api-oauth-token']->renew($devToken);
} else { } else {
// dev tokens do not expires // dev tokens do not expires

View File

@@ -52,12 +52,12 @@ class Session implements ControllerProviderInterface
$app->abort(400); $app->abort(400);
} }
$ret = array( $ret = [
'status' => 'unknown', 'status' => 'unknown',
'message' => '', 'message' => '',
'notifications' => false, 'notifications' => false,
'changed' => array() 'changed' => []
); ];
if ($app['authentication']->isAuthenticated()) { if ($app['authentication']->isAuthenticated()) {
$usr_id = $app['authentication']->getUser()->getId(); $usr_id = $app['authentication']->getUser()->getId();
@@ -86,9 +86,9 @@ class Session implements ControllerProviderInterface
$ret['status'] = 'ok'; $ret['status'] = 'ok';
$ret['notifications'] = $app['twig']->render('prod/notifications.html.twig', array( $ret['notifications'] = $app['twig']->render('prod/notifications.html.twig', [
'notifications' => $app['events-manager']->get_notifications() 'notifications' => $app['events-manager']->get_notifications()
)); ]);
$baskets = $app['EM']->getRepository('\Entities\Basket')->findUnreadActiveByUser($app['authentication']->getUser()); $baskets = $app['EM']->getRepository('\Entities\Basket')->findUnreadActiveByUser($app['authentication']->getUser());
@@ -96,7 +96,7 @@ class Session implements ControllerProviderInterface
$ret['changed'][] = $basket->getId(); $ret['changed'][] = $basket->getId();
} }
if (in_array($app['session']->get('phraseanet.message'), array('1', null))) { if (in_array($app['session']->get('phraseanet.message'), ['1', null])) {
if ($app['phraseanet.configuration']['main']['maintenance']) { if ($app['phraseanet.configuration']['main']['maintenance']) {
$ret['message'] .= _('The application is going down for maintenance, please logout.'); $ret['message'] .= _('The application is going down for maintenance, please logout.');
} }

View File

@@ -753,7 +753,7 @@ class Xmlhttp implements ControllerProviderInterface
$lcoll = ''; $lcoll = '';
$collections = $app['authentication']->getUser()->ACL() $collections = $app['authentication']->getUser()->ACL()
->get_granted_base(array(), array($sbid)); // array(), $sbid); ->get_granted_base([], [$sbid]); // array(), $sbid);
foreach ($collections as $collection) { foreach ($collections as $collection) {
$lcoll .= ($lcoll?",":"") . $collection->get_coll_id(); $lcoll .= ($lcoll?",":"") . $collection->get_coll_id();
} }
@@ -779,7 +779,7 @@ class Xmlhttp implements ControllerProviderInterface
FROM (thit AS t INNER JOIN record AS r USING(record_id)) FROM (thit AS t INNER JOIN record AS r USING(record_id))
INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id
WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0'; WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0';
$sqlparm = array(':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id); $sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id];
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute($sqlparm); $stmt->execute($sqlparm);
@@ -797,10 +797,10 @@ class Xmlhttp implements ControllerProviderInterface
INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id
WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0 WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0
GROUP BY k'; GROUP BY k';
$sqlparm = array(':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id); $sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id];
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':like' => $dthid . '%')); $stmt->execute([':like' => $dthid . '%']);
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
@@ -816,7 +816,7 @@ class Xmlhttp implements ControllerProviderInterface
INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id
WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0 WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0
GROUP BY k'; GROUP BY k';
$sqlparm = array(':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id); $sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id];
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute($sqlparm); $stmt->execute($sqlparm);
@@ -834,7 +834,7 @@ class Xmlhttp implements ControllerProviderInterface
INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id
WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0 WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0
GROUP BY k'; GROUP BY k';
$sqlparm = array(':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id); $sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id];
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute($sqlparm); $stmt->execute($sqlparm);

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Core\Event; namespace Alchemy\Phrasea\Core\Event;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Symfony\Component\EventDispatcher\Event as SfEvent; use Symfony\Component\EventDispatcher\Event as SfEvent;

View File

@@ -25,12 +25,12 @@ class ApiCorsSubscriber implements EventSubscriberInterface
/** /**
* Simple headers as defined in the spec should always be accepted * Simple headers as defined in the spec should always be accepted
*/ */
protected static $simpleHeaders = array( protected static $simpleHeaders = [
'accept', 'accept',
'accept-language', 'accept-language',
'content-language', 'content-language',
'origin', 'origin',
); ];
private $app; private $app;
private $options; private $options;
@@ -42,9 +42,9 @@ class ApiCorsSubscriber implements EventSubscriberInterface
public static function getSubscribedEvents() public static function getSubscribedEvents()
{ {
return array( return [
KernelEvents::REQUEST => array('onKernelRequest', 128), KernelEvents::REQUEST => ['onKernelRequest', 128],
); ];
} }
public function onKernelRequest(GetResponseEvent $event) public function onKernelRequest(GetResponseEvent $event)
@@ -66,15 +66,15 @@ class ApiCorsSubscriber implements EventSubscriberInterface
return; return;
} }
$options = array_merge(array( $options = array_merge([
'allow_credentials'=> false, 'allow_credentials'=> false,
'allow_origin'=> array(), 'allow_origin'=> [],
'allow_headers'=> array(), 'allow_headers'=> [],
'allow_methods'=> array(), 'allow_methods'=> [],
'expose_headers'=> array(), 'expose_headers'=> [],
'max_age'=> 0, 'max_age'=> 0,
'hosts'=> array(), 'hosts'=> [],
), $this->app['phraseanet.configuration']['api_cors']); ], $this->app['phraseanet.configuration']['api_cors']);
// skip if the host is not matching // skip if the host is not matching
if (!$this->checkHost($request, $options)) { if (!$this->checkHost($request, $options)) {
@@ -87,13 +87,13 @@ class ApiCorsSubscriber implements EventSubscriberInterface
return; return;
} }
if (!$this->checkOrigin($request, $options)) { if (!$this->checkOrigin($request, $options)) {
$response = new Response('', 403, array('Access-Control-Allow-Origin' => 'null')); $response = new Response('', 403, ['Access-Control-Allow-Origin' => 'null']);
$event->setResponse($response); $event->setResponse($response);
return; return;
} }
$this->app['dispatcher']->addListener(KernelEvents::RESPONSE, array($this, 'onKernelResponse')); $this->app['dispatcher']->addListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']);
$this->options = $options; $this->options = $options;
} }

View File

@@ -32,12 +32,12 @@ class SessionManagerSubscriber implements EventSubscriberInterface
public static function getSubscribedEvents() public static function getSubscribedEvents()
{ {
return array( return [
KernelEvents::REQUEST => array( KernelEvents::REQUEST => [
array('initSession', Application::EARLY_EVENT), ['initSession', Application::EARLY_EVENT],
array('checkSessionActivity', Application::LATE_EVENT) ['checkSessionActivity', Application::LATE_EVENT]
) ]
); ];
} }
public function initSession(GetResponseEvent $event) public function initSession(GetResponseEvent $event)
@@ -60,14 +60,14 @@ class SessionManagerSubscriber implements EventSubscriberInterface
/**log real human activity on application, to keep session alive*/ /**log real human activity on application, to keep session alive*/
public function checkSessionActivity(GetResponseEvent $event) public function checkSessionActivity(GetResponseEvent $event)
{ {
$modulesIds = array( $modulesIds = [
"prod" => 1, "prod" => 1,
"client" => 2, "client" => 2,
"admin" => 3, "admin" => 3,
"thesaurus" => 5, "thesaurus" => 5,
"report" => 10, "report" => 10,
"lightbox" => 6, "lightbox" => 6,
); ];
$pathInfo = array_filter(explode('/', $event->getRequest()->getPathInfo())); $pathInfo = array_filter(explode('/', $event->getRequest()->getPathInfo()));
@@ -101,7 +101,7 @@ class SessionManagerSubscriber implements EventSubscriberInterface
if ($event->getRequest()->isXmlHttpRequest()) { if ($event->getRequest()->isXmlHttpRequest()) {
$response = new Response("End-Session", 403); $response = new Response("End-Session", 403);
} else { } else {
$response = new RedirectResponse($this->app["url_generator"]->generate("homepage", array("redirect"=>'..' . $event->getRequest()->getPathInfo()))); $response = new RedirectResponse($this->app["url_generator"]->generate("homepage", ["redirect"=>'..' . $event->getRequest()->getPathInfo()]));
} }
$response->headers->set('X-Phraseanet-End-Session', '1'); $response->headers->set('X-Phraseanet-End-Session', '1');
@@ -124,7 +124,7 @@ class SessionManagerSubscriber implements EventSubscriberInterface
if ($event->getRequest()->isXmlHttpRequest()) { if ($event->getRequest()->isXmlHttpRequest()) {
$response = new Response("End-Session", 403); $response = new Response("End-Session", 403);
} else { } else {
$response = new RedirectResponse($this->app["url_generator"]->generate("homepage", array("redirect"=>'..' . $event->getRequest()->getPathInfo()))); $response = new RedirectResponse($this->app["url_generator"]->generate("homepage", ["redirect"=>'..' . $event->getRequest()->getPathInfo()]));
} }
$response->headers->set('X-Phraseanet-End-Session', '1'); $response->headers->set('X-Phraseanet-End-Session', '1');

View File

@@ -61,7 +61,7 @@ class CSVServiceProvider implements ServiceProviderInterface
$app['csv.response'] = $app->protect(function ($callback) use ($app) { $app['csv.response'] = $app->protect(function ($callback) use ($app) {
// set headers to fix ie issues // set headers to fix ie issues
$response = new StreamedResponse($callback, 200, array( $response = new StreamedResponse($callback, 200, [
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
'Last-Modified' => gmdate('D, d M Y H:i:s'). ' GMT', 'Last-Modified' => gmdate('D, d M Y H:i:s'). ' GMT',
'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Cache-Control' => 'no-store, no-cache, must-revalidate',
@@ -70,7 +70,7 @@ class CSVServiceProvider implements ServiceProviderInterface
'Content-Type' => 'text/csv', 'Content-Type' => 'text/csv',
'Cache-Control' => 'max-age=3600, must-revalidate', 'Cache-Control' => 'max-age=3600, must-revalidate',
'Content-Disposition' => 'max-age=3600, must-revalidate', 'Content-Disposition' => 'max-age=3600, must-revalidate',
)); ]);
$response->headers->set('Content-Disposition', $response->headers->makeDisposition( $response->headers->set('Content-Disposition', $response->headers->makeDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT, ResponseHeaderBag::DISPOSITION_ATTACHMENT,

View File

@@ -27,7 +27,7 @@ class ConvertersServiceProvider implements ServiceProviderInterface
return new TaskConverter($app['repo.tasks']); return new TaskConverter($app['repo.tasks']);
}); });
$app['converter.task-callback'] = $app->protect(function($id) use ($app) { $app['converter.task-callback'] = $app->protect(function ($id) use ($app) {
return $app['converter.task']->convert($id); return $app['converter.task']->convert($id);
}); });

View File

@@ -25,7 +25,6 @@ use Alchemy\Phrasea\TaskManager\LiveInformation;
use Alchemy\Phrasea\TaskManager\TaskManagerStatus; use Alchemy\Phrasea\TaskManager\TaskManagerStatus;
use Alchemy\Phrasea\TaskManager\Log\LogFileFactory; use Alchemy\Phrasea\TaskManager\Log\LogFileFactory;
use Alchemy\Phrasea\TaskManager\Notifier; use Alchemy\Phrasea\TaskManager\Notifier;
use Alchemy\Phrasea\Webhook\EventProcessorFactory;
use Silex\Application; use Silex\Application;
use Silex\ServiceProviderInterface; use Silex\ServiceProviderInterface;

View File

@@ -15,11 +15,11 @@ use Symfony\Component\HttpFoundation\ResponseHeaderBag;
class CSVFileResponse extends StreamedResponse class CSVFileResponse extends StreamedResponse
{ {
public function __construct($filename, $callback = null, $status = 200, $headers = array()) public function __construct($filename, $callback = null, $status = 200, $headers = [])
{ {
parent::__construct($callback, $status, array_merge( parent::__construct($callback, $status, array_merge(
// set some headers to fix ie issues // set some headers to fix ie issues
array( [
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
'Last-Modified' => gmdate('D, d M Y H:i:s'). ' GMT', 'Last-Modified' => gmdate('D, d M Y H:i:s'). ' GMT',
'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Cache-Control' => 'no-store, no-cache, must-revalidate',
@@ -27,7 +27,7 @@ class CSVFileResponse extends StreamedResponse
'Pragma' => 'no-cache', 'Pragma' => 'no-cache',
'Cache-Control' => 'max-age=3600, must-revalidate', 'Cache-Control' => 'max-age=3600, must-revalidate',
'Content-Disposition' => 'max-age=3600, must-revalidate', 'Content-Disposition' => 'max-age=3600, must-revalidate',
), ],
$headers $headers
)); ));

View File

@@ -45,9 +45,9 @@ class EmailFormType extends AbstractType
]); ]);
$builder->add('hidden-password', 'password', [ $builder->add('hidden-password', 'password', [
'label' => false, 'label' => false,
'attr' => array( 'attr' => [
'style' => 'display:none' 'style' => 'display:none'
) ]
]); ]);
$builder->add('smtp-password', 'password', [ $builder->add('smtp-password', 'password', [
'label' => 'SMTP password', 'label' => 'SMTP password',

View File

@@ -46,20 +46,20 @@ class PhraseaAuthenticationForm extends AbstractType
]); ]);
if ($this->app['phraseanet.configuration']['session']['idle'] < 1) { if ($this->app['phraseanet.configuration']['session']['idle'] < 1) {
$builder->add('remember-me', 'checkbox' , array( $builder->add('remember-me', 'checkbox' , [
'label' => _('Remember me'), 'label' => _('Remember me'),
'mapped' => false, 'mapped' => false,
'required' => false, 'required' => false,
'attr' => array( 'attr' => [
'value' => '1', 'value' => '1',
) ]
)); ]);
} else { } else {
$builder->add('remember-me', 'hidden' , array( $builder->add('remember-me', 'hidden' , [
'label' => '', 'label' => '',
'mapped' => false, 'mapped' => false,
'required' => false 'required' => false
)); ]);
} }
$builder->add('redirect', 'hidden', [ $builder->add('redirect', 'hidden', [

View File

@@ -11,9 +11,6 @@
namespace Alchemy\Phrasea\Helper; namespace Alchemy\Phrasea\Helper;
use Doctrine\DBAL\DBALException;
use Alchemy\Phrasea\Core\Connection\ConnectionProvider;
class DatabaseHelper extends Helper class DatabaseHelper extends Helper
{ {
public function checkConnection() public function checkConnection()
@@ -75,12 +72,12 @@ class DatabaseHelper extends Helper
} }
} }
return array( return [
'connection' => $connection_ok, 'connection' => $connection_ok,
'database' => $db_ok, 'database' => $db_ok,
'is_empty' => $empty, 'is_empty' => $empty,
'is_appbox' => $is_appbox, 'is_appbox' => $is_appbox,
'is_databox' => $is_databox 'is_databox' => $is_databox
); ];
} }
} }

View File

@@ -17,18 +17,18 @@ class PathHelper extends Helper
{ {
public function checkPath() public function checkPath()
{ {
return array( return [
'exists' => file_exists($this->request->query->get('path')), 'exists' => file_exists($this->request->query->get('path')),
'file' => is_file($this->request->query->get('path')), 'file' => is_file($this->request->query->get('path')),
'dir' => is_dir($this->request->query->get('path')), 'dir' => is_dir($this->request->query->get('path')),
'readable' => is_readable($this->request->query->get('path')), 'readable' => is_readable($this->request->query->get('path')),
'writeable' => is_writable($this->request->query->get('path')), 'writeable' => is_writable($this->request->query->get('path')),
'executable' => is_executable($this->request->query->get('path')), 'executable' => is_executable($this->request->query->get('path')),
); ];
} }
public function checkUrl() public function checkUrl()
{ {
return array('code' => \http_query::getHttpCodeFromUrl($this->request->query->get('url'))); return ['code' => \http_query::getHttpCodeFromUrl($this->request->query->get('url'))];
} }
} }

View File

@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Model\Converter;
use Alchemy\Phrasea\Model\Entities\Basket; use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Repositories\BasketRepository; use Alchemy\Phrasea\Model\Repositories\BasketRepository;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class BasketConverter implements ConverterInterface class BasketConverter implements ConverterInterface

View File

@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Model\Converter;
use Alchemy\Phrasea\Model\Entities\Task; use Alchemy\Phrasea\Model\Entities\Task;
use Alchemy\Phrasea\Model\Repositories\TaskRepository; use Alchemy\Phrasea\Model\Repositories\TaskRepository;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class TaskConverter implements ConverterInterface class TaskConverter implements ConverterInterface

View File

@@ -208,7 +208,7 @@ class ApiOauthToken
} }
/** /**
* @param \DateTime $lastUsed * @param \DateTime $lastUsed
* *
* @return ApiOauthToken * @return ApiOauthToken
*/ */

View File

@@ -53,12 +53,12 @@ class WebhookEvent
public static function types() public static function types()
{ {
return array(self::FEED_ENTRY_TYPE); return [self::FEED_ENTRY_TYPE];
} }
public static function events() public static function events()
{ {
return array(self::NEW_FEED_ENTRY); return [self::NEW_FEED_ENTRY];
} }
/** /**

View File

@@ -12,7 +12,6 @@
namespace Alchemy\Phrasea\Model\Manipulator; namespace Alchemy\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Controller\Api\V1; use Alchemy\Phrasea\Controller\Api\V1;
use Alchemy\Phrasea\Model\Entities\ApiAccount; use Alchemy\Phrasea\Model\Entities\ApiAccount;
use Alchemy\Phrasea\Model\Entities\ApiApplication; use Alchemy\Phrasea\Model\Entities\ApiApplication;

View File

@@ -12,11 +12,9 @@
namespace Alchemy\Phrasea\Model\Manipulator; namespace Alchemy\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Alchemy\Phrasea\Model\Entities\ApiApplication; use Alchemy\Phrasea\Model\Entities\ApiApplication;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Manipulator\TokenManipulator;
use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use RandomLib\Generator; use RandomLib\Generator;
@@ -58,7 +56,7 @@ class ApiApplicationManipulator implements ManipulatorInterface
$this->om->remove($application); $this->om->remove($application);
$this->om->flush(); $this->om->flush();
} }
public function update(ApiApplication $application) public function update(ApiApplication $application)
{ {
$this->om->persist($application); $this->om->persist($application);

View File

@@ -11,11 +11,8 @@
namespace Alchemy\Phrasea\Model\Manipulator; namespace Alchemy\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Model\Entities\ApiAccount; use Alchemy\Phrasea\Model\Entities\ApiAccount;
use Alchemy\Phrasea\Model\Entities\ApiLog; use Alchemy\Phrasea\Model\Entities\ApiLog;
use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;

View File

@@ -11,14 +11,10 @@
namespace Alchemy\Phrasea\Model\Manipulator; namespace Alchemy\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Alchemy\Phrasea\Model\Entities\ApiAccount; use Alchemy\Phrasea\Model\Entities\ApiAccount;
use Alchemy\Phrasea\Model\Entities\ApiOauthCode; use Alchemy\Phrasea\Model\Entities\ApiOauthCode;
use Alchemy\Phrasea\Model\Entities\ApiApplication; use Alchemy\Phrasea\Model\Entities\ApiApplication;
use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Manipulator\TokenManipulator;
use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use RandomLib\Generator; use RandomLib\Generator;

View File

@@ -11,12 +11,8 @@
namespace Alchemy\Phrasea\Model\Manipulator; namespace Alchemy\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Model\Entities\ApiAccount; use Alchemy\Phrasea\Model\Entities\ApiAccount;
use Alchemy\Phrasea\Model\Entities\ApiOauthRefreshtoken; use Alchemy\Phrasea\Model\Entities\ApiOauthRefreshtoken;
use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Manipulator\TokenManipulator;
use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use RandomLib\Generator; use RandomLib\Generator;

View File

@@ -11,13 +11,8 @@
namespace Alchemy\Phrasea\Model\Manipulator; namespace Alchemy\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Model\Entities\ApiAccount; use Alchemy\Phrasea\Model\Entities\ApiAccount;
use Alchemy\Phrasea\Model\Entities\ApiOauthToken; use Alchemy\Phrasea\Model\Entities\ApiOauthToken;
use Alchemy\Phrasea\Model\Entities\Session;
use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Manipulator\TokenManipulator;
use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use RandomLib\Generator; use RandomLib\Generator;

View File

@@ -12,17 +12,11 @@
namespace Alchemy\Phrasea\Model\Manipulator; namespace Alchemy\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Model\Entities\ApiAccount;
use Alchemy\Phrasea\Model\Entities\ApiApplication; use Alchemy\Phrasea\Model\Entities\ApiApplication;
use Alchemy\Phrasea\Model\Entities\ApiLog;
use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\WebhookEvent; use Alchemy\Phrasea\Model\Entities\WebhookEvent;
use Alchemy\Phrasea\Model\Entities\WebhookEventDelivery; use Alchemy\Phrasea\Model\Entities\WebhookEventDelivery;
use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class WebhookEventDeliveryManipulator implements ManipulatorInterface class WebhookEventDeliveryManipulator implements ManipulatorInterface
{ {

View File

@@ -11,16 +11,9 @@
namespace Alchemy\Phrasea\Model\Manipulator; namespace Alchemy\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Model\Entities\ApiAccount;
use Alchemy\Phrasea\Model\Entities\ApiLog;
use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\WebhookEvent; use Alchemy\Phrasea\Model\Entities\WebhookEvent;
use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class WebhookEventManipulator implements ManipulatorInterface class WebhookEventManipulator implements ManipulatorInterface
{ {

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Model\Repositories; namespace Alchemy\Phrasea\Model\Repositories;
use Alchemy\Phrasea\Model\Entities\WebhookEvent;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
/** /**

View File

@@ -623,7 +623,7 @@ class PhraseaEngine implements SearchEngineInterface
$sxe = @simplexml_load_string($res['xml']); $sxe = @simplexml_load_string($res['xml']);
foreach ($fields as $name => $field) { foreach ($fields as $name => $field) {
$newValues = array(); $newValues = [];
if ($sxe && $sxe->description && $sxe->description->{$name}) { if ($sxe && $sxe->description && $sxe->description->{$name}) {
foreach ($sxe->description->{$name} as $value) { foreach ($sxe->description->{$name} as $value) {
$newValues[(string) $value['meta_id']] = (string) $value; $newValues[(string) $value['meta_id']] = (string) $value;

View File

@@ -519,7 +519,7 @@ class SphinxSearchEngine implements SearchEngineInterface
*/ */
public function excerpt($query, $fields, \record_adapter $record, SearchEngineOptions $options = null) public function excerpt($query, $fields, \record_adapter $record, SearchEngineOptions $options = null)
{ {
return array(); return [];
} }
/** /**

View File

@@ -113,7 +113,7 @@ class Firewall
public function requireAuthentication(Request $request = null) public function requireAuthentication(Request $request = null)
{ {
$params = array(); $params = [];
if (null !== $request) { if (null !== $request) {
$params['redirect'] = '..' . $request->getPathInfo(); $params['redirect'] = '..' . $request->getPathInfo();
} }

View File

@@ -25,11 +25,9 @@ use Guzzle\Plugin\Backoff\BackoffPlugin;
use Guzzle\Plugin\Backoff\TruncatedBackoffStrategy; use Guzzle\Plugin\Backoff\TruncatedBackoffStrategy;
use Guzzle\Plugin\Backoff\CallbackBackoffStrategy; use Guzzle\Plugin\Backoff\CallbackBackoffStrategy;
use Guzzle\Plugin\Backoff\CurlBackoffStrategy; use Guzzle\Plugin\Backoff\CurlBackoffStrategy;
use Guzzle\Plugin\Backoff\ExponentialBackoffStrategy;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Translation\TranslatorInterface;
use Guzzle\Http\Exception\MultiTransferException;
class WebhookJob extends AbstractJob class WebhookJob extends AbstractJob
{ {
@@ -94,7 +92,7 @@ class WebhookJob extends AbstractJob
// set max retries // set max retries
new TruncatedBackoffStrategy(WebhookEventDelivery::MAX_DELIVERY_TRIES, new TruncatedBackoffStrategy(WebhookEventDelivery::MAX_DELIVERY_TRIES,
// set callback which logs success or failure // set callback which logs success or failure
new CallbackBackoffStrategy(function($retries, $request, $response, $e) use ($app, $that) { new CallbackBackoffStrategy(function ($retries, $request, $response, $e) use ($app, $that) {
$retry = true; $retry = true;
if ($response && (null !== $deliverId = parse_url($request->getUrl(), PHP_URL_FRAGMENT))) { if ($response && (null !== $deliverId = parse_url($request->getUrl(), PHP_URL_FRAGMENT))) {
$delivery = $app['repo.webhook-delivery']->find($deliverId); $delivery = $app['repo.webhook-delivery']->find($deliverId);
@@ -153,9 +151,9 @@ class WebhookJob extends AbstractJob
$uniqueUrl = $this->getUrl($thirdPartyApplication, $delivery); $uniqueUrl = $this->getUrl($thirdPartyApplication, $delivery);
// create http request with data as request body // create http request with data as request body
$batch->add($this->httpClient->createRequest('POST', $uniqueUrl, array( $batch->add($this->httpClient->createRequest('POST', $uniqueUrl, [
'Content-Type' => 'application/vnd.phraseanet.event+json' 'Content-Type' => 'application/vnd.phraseanet.event+json'
), json_encode($data))); ], json_encode($data)));
} }
$batch->flush(); $batch->flush();

View File

@@ -21,9 +21,9 @@ class Fit extends \Twig_Extension
public function getFunctions() public function getFunctions()
{ {
return array( return [
'fitIn' => new \Twig_Function_Method($this, 'fitIn') 'fitIn' => new \Twig_Function_Method($this, 'fitIn')
); ];
} }
public function fitIn(array $content, array $box) public function fitIn(array $content, array $box)
@@ -79,11 +79,11 @@ class Fit extends \Twig_Extension
} }
} }
return array( return [
'width' => round($width), 'width' => round($width),
'height' => round($height), 'height' => round($height),
'top' => round($top), 'top' => round($top),
'left' => round($left) 'left' => round($left)
); ];
} }
} }

View File

@@ -30,43 +30,43 @@ class FeedEntryProcessor extends AbstractProcessor implements ProcessorInterface
->email_not_null(true); ->email_not_null(true);
if ($feed->getCollection($this->app)) { if ($feed->getCollection($this->app)) {
$query->on_base_ids(array($feed->getCollection($this->app)->get_base_id())); $query->on_base_ids([$feed->getCollection($this->app)->get_base_id()]);
} }
$start = 0; $start = 0;
$perLoop = 100; $perLoop = 100;
$users = array(); $users = [];
do { do {
$results = $query->limit($start, $perLoop)->execute()->get_results(); $results = $query->limit($start, $perLoop)->execute()->get_results();
foreach ($results as $user) { foreach ($results as $user) {
$users[] = array( $users[] = [
'email' => $user->getEmail(), 'email' => $user->getEmail(),
'firstname' => $user->getFirstname() ?: null, 'firstname' => $user->getFirstname() ?: null,
'lastname' => $user->getLastname() ?: null, 'lastname' => $user->getLastname() ?: null,
); ];
} }
$start += $perLoop; $start += $perLoop;
} while (count($results) > 0); } while (count($results) > 0);
return array( return [
'event' => $this->event->getName(), 'event' => $this->event->getName(),
'users_were_notified' => isset($data->{'notify_email'}) ?: !!$data->{"notify_email"}, 'users_were_notified' => isset($data->{'notify_email'}) ?: !!$data->{"notify_email"},
'feed' => array( 'feed' => [
'id' => $feed->getId(), 'id' => $feed->getId(),
'title' => $feed->getTitle(), 'title' => $feed->getTitle(),
'description' => $feed->getSubtitle(), 'description' => $feed->getSubtitle(),
), ],
'entry' => array( 'entry' => [
'id' => $entry->getId(), 'id' => $entry->getId(),
'author' => array( 'author' => [
'name' => $entry->getAuthorName(), 'name' => $entry->getAuthorName(),
'email' => $entry->getAuthorEmail() 'email' => $entry->getAuthorEmail()
), ],
'title' => $entry->getTitle(), 'title' => $entry->getTitle(),
'description' => $entry->getSubtitle(), 'description' => $entry->getSubtitle(),
), ],
'users' => $users 'users' => $users
); ];
} }
} }

View File

@@ -5,4 +5,4 @@ namespace Alchemy\Phrasea\Webhook\Processor;
interface ProcessorInterface interface ProcessorInterface
{ {
public function process(); public function process();
} }

View File

@@ -279,7 +279,7 @@ class API_OAuth2_Adapter extends OAuth2
/** /**
* *
* Overrides OAuth2::setAuthCode(). * Overrides OAuth2::setAuthCode().
* *
* @param $oauthCode * @param $oauthCode
* @param $accountId * @param $accountId
* @param $redirectUri * @param $redirectUri
@@ -421,7 +421,7 @@ class API_OAuth2_Adapter extends OAuth2
/** /**
* At least one of: existing redirect URI or input redirect URI must be specified * At least one of: existing redirect URI or input redirect URI must be specified
*/ */
if ( ! $redirectUri && ! $input["redirect_uri"]) { if (! $redirectUri && ! $input["redirect_uri"]) {
$this->errorJsonResponse(OAUTH2_HTTP_FOUND, OAUTH2_ERROR_INVALID_REQUEST); $this->errorJsonResponse(OAUTH2_HTTP_FOUND, OAUTH2_ERROR_INVALID_REQUEST);
} }
@@ -642,7 +642,7 @@ class API_OAuth2_Adapter extends OAuth2
$input = filter_input_array(INPUT_POST, $filters); $input = filter_input_array(INPUT_POST, $filters);
// Grant Type must be specified. // Grant Type must be specified.
if ( ! $input["grant_type"]) { if (! $input["grant_type"]) {
$this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST, 'Invalid grant_type parameter or parameter missing'); $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST, 'Invalid grant_type parameter or parameter missing');
} }
@@ -669,7 +669,7 @@ class API_OAuth2_Adapter extends OAuth2
// Do the granting // Do the granting
switch ($input["grant_type"]) { switch ($input["grant_type"]) {
case OAUTH2_GRANT_TYPE_AUTH_CODE: case OAUTH2_GRANT_TYPE_AUTH_CODE:
if ( ! $input["code"] || ! $input["redirect_uri"]) { if (! $input["code"] || ! $input["redirect_uri"]) {
$this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST); $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST);
} }
$stored = $this->getAuthCode($input["code"]); $stored = $this->getAuthCode($input["code"]);
@@ -690,7 +690,7 @@ class API_OAuth2_Adapter extends OAuth2
$this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_UNSUPPORTED_GRANT_TYPE, 'Password grant type is not enable for your client'); $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_UNSUPPORTED_GRANT_TYPE, 'Password grant type is not enable for your client');
} }
if ( ! $input["username"] || ! $input["password"]) { if (! $input["username"] || ! $input["password"]) {
$this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST, 'Missing parameters. "username" and "password" required'); $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST, 'Missing parameters. "username" and "password" required');
} }
@@ -701,7 +701,7 @@ class API_OAuth2_Adapter extends OAuth2
} }
break; break;
case OAUTH2_GRANT_TYPE_ASSERTION: case OAUTH2_GRANT_TYPE_ASSERTION:
if ( ! $input["assertion_type"] || ! $input["assertion"]) { if (! $input["assertion_type"] || ! $input["assertion"]) {
$this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST); $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST);
} }
@@ -713,7 +713,7 @@ class API_OAuth2_Adapter extends OAuth2
break; break;
case OAUTH2_GRANT_TYPE_REFRESH_TOKEN: case OAUTH2_GRANT_TYPE_REFRESH_TOKEN:
if ( ! $input["refresh_token"]) { if (! $input["refresh_token"]) {
$this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST, 'No "refresh_token" parameter found'); $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_REQUEST, 'No "refresh_token" parameter found');
} }
@@ -744,7 +744,7 @@ class API_OAuth2_Adapter extends OAuth2
$this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_SCOPE); $this->errorJsonResponse(OAUTH2_HTTP_BAD_REQUEST, OAUTH2_ERROR_INVALID_SCOPE);
} }
if ( ! $input["scope"]) { if (! $input["scope"]) {
$input["scope"] = null; $input["scope"] = null;
} }

View File

@@ -29,7 +29,7 @@ class API_Webhook
FROM api_webhooks FROM api_webhooks
WHERE id = :id'; WHERE id = :id';
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $id)); $stmt->execute([':id' => $id]);
$row = $stmt->fetch(\PDO::FETCH_ASSOC); $row = $stmt->fetch(\PDO::FETCH_ASSOC);
if (!$row) { if (!$row) {
@@ -48,7 +48,7 @@ class API_Webhook
$sql = 'DELETE FROM api_webhooks WHERE id = :id'; $sql = 'DELETE FROM api_webhooks WHERE id = :id';
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id)); $stmt->execute([':id' => $this->id]);
$stmt->closeCursor(); $stmt->closeCursor();
return; return;
@@ -60,10 +60,10 @@ class API_Webhook
VALUES (null, :type, :data, NOW())'; VALUES (null, :type, :data, NOW())';
$stmt = $appbox->get_connection()->prepare($sql); $stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array( $stmt->execute([
'type' => $type, 'type' => $type,
'data' => json_encode($data), 'data' => json_encode($data),
)); ]);
$stmt->closeCursor(); $stmt->closeCursor();
return new API_Webhook($appbox, $appbox->get_connection()->lastInsertId()); return new API_Webhook($appbox, $appbox->get_connection()->lastInsertId());

View File

@@ -64,7 +64,7 @@ class caption_Field_Value implements cache_cacheableInterface
*/ */
protected $isThesaurusValue; protected $isThesaurusValue;
protected static $localCache = array(); protected static $localCache = [];
/** /**
* *
@@ -396,7 +396,7 @@ class caption_Field_Value implements cache_cacheableInterface
} }
if ($bestnode) { if ($bestnode) {
list($term, $context) = $this->splitTermAndContext(str_replace(array("[[em]]", "[[/em]]"), array("", ""), $value)); list($term, $context) = $this->splitTermAndContext(str_replace(["[[em]]", "[[/em]]"], ["", ""], $value));
// a value has been found in thesaurus, update value & set the query to bounce to the value // a value has been found in thesaurus, update value & set the query to bounce to the value
$this->value = $bestnode->getAttribute('v'); $this->value = $bestnode->getAttribute('v');
$this->qjs = $term . ($context ? '['.$context.']' : ''); $this->qjs = $term . ($context ? '['.$context.']' : '');

View File

@@ -174,24 +174,24 @@ class caption_record implements caption_interface, cache_cacheableInterface
*/ */
public function get_highlight_fields($highlight = '', Array $grep_fields = null, SearchEngineInterface $searchEngine = null, $includeBusiness = false, SearchEngineOptions $options = null) public function get_highlight_fields($highlight = '', Array $grep_fields = null, SearchEngineInterface $searchEngine = null, $includeBusiness = false, SearchEngineOptions $options = null)
{ {
$fields = array(); $fields = [];
foreach ($this->get_fields($grep_fields, $includeBusiness) as $meta_struct_id => $field) { foreach ($this->get_fields($grep_fields, $includeBusiness) as $meta_struct_id => $field) {
$values = array(); $values = [];
foreach ($field->get_values() as $metaId => $v) { foreach ($field->get_values() as $metaId => $v) {
$values[$metaId] = array( $values[$metaId] = [
'value' => $v->getValue(), 'value' => $v->getValue(),
'from_thesaurus' => $highlight ? $v->isThesaurusValue() : false, 'from_thesaurus' => $highlight ? $v->isThesaurusValue() : false,
'qjs' => $v->getQjs(), 'qjs' => $v->getQjs(),
); ];
} }
$fields[$field->get_name()] = array( $fields[$field->get_name()] = [
'values' => $values, 'values' => $values,
'name' => $field->get_name(), 'name' => $field->get_name(),
'label' => $field->get_databox_field()->get_label($this->app['locale']), 'label' => $field->get_databox_field()->get_label($this->app['locale']),
'separator' => $field->get_databox_field()->get_separator(), 'separator' => $field->get_databox_field()->get_separator(),
'sbas_id' => $field->get_databox_field()->get_databox()->get_sbas_id() 'sbas_id' => $field->get_databox_field()->get_databox()->get_sbas_id()
); ];
} }
if ($searchEngine instanceof SearchEngineInterface) { if ($searchEngine instanceof SearchEngineInterface) {

View File

@@ -63,11 +63,11 @@ class databox_status
return; return;
} }
$uniqid = md5(implode('-', array( $uniqid = md5(implode('-', [
$sbas_params[$sbas_id]["host"], $sbas_params[$sbas_id]["host"],
$sbas_params[$sbas_id]["port"], $sbas_params[$sbas_id]["port"],
$sbas_params[$sbas_id]["dbname"] $sbas_params[$sbas_id]["dbname"]
))); ]));
$path = $this->path = $app['root.path'] . "/config/status/" . $uniqid; $path = $this->path = $app['root.path'] . "/config/status/" . $uniqid;
$url = $this->url = "/custom/status/" . $uniqid; $url = $this->url = "/custom/status/" . $uniqid;

View File

@@ -63,7 +63,7 @@ class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
$this->app['manipulator.webhook-event']->create( $this->app['manipulator.webhook-event']->create(
WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::NEW_FEED_ENTRY,
WebhookEvent::FEED_ENTRY_TYPE, WebhookEvent::FEED_ENTRY_TYPE,
array_merge(array('feed_id' => $entry->getFeed()->getId()), $params) array_merge(['feed_id' => $entry->getFeed()->getId()], $params)
); );
$Query = new \User_Query($this->app); $Query = new \User_Query($this->app);

View File

@@ -741,7 +741,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
return; return;
} }
if ($this->app['phraseanet.h264-factory']->isH264Enabled() && in_array($this->mime, array('video/mp4'))) { if ($this->app['phraseanet.h264-factory']->isH264Enabled() && in_array($this->mime, ['video/mp4'])) {
if (null !== $url = $this->app['phraseanet.h264']->getUrl($this->get_pathfile())) { if (null !== $url = $this->app['phraseanet.h264']->getUrl($this->get_pathfile())) {
$this->url = $url; $this->url = $url;

View File

@@ -11,7 +11,6 @@
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\ApiApplication; use Alchemy\Phrasea\Model\Entities\ApiApplication;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class patch_370alpha3a extends patchAbstract class patch_370alpha3a extends patchAbstract
{ {

View File

@@ -11,7 +11,6 @@
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\ApiApplication; use Alchemy\Phrasea\Model\Entities\ApiApplication;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class patch_3715alpha1a extends patchAbstract class patch_3715alpha1a extends patchAbstract
{ {

View File

@@ -19,7 +19,7 @@ class patch_384alpha2a implements patchInterface
private $release = '3.8.4-alpha.2'; private $release = '3.8.4-alpha.2';
/** @var array */ /** @var array */
private $concern = array(base::APPLICATION_BOX); private $concern = [base::APPLICATION_BOX];
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@@ -17,7 +17,7 @@ class patch_384alpha3a implements patchInterface
private $release = '3.8.4-alpha.3'; private $release = '3.8.4-alpha.3';
/** @var array */ /** @var array */
private $concern = array(base::APPLICATION_BOX); private $concern = [base::APPLICATION_BOX];
/** /**
* {@inheritdoc} * {@inheritdoc}
@@ -58,16 +58,16 @@ class patch_384alpha3a implements patchInterface
{ {
$config = $app['phraseanet.configuration']->getConfig(); $config = $app['phraseanet.configuration']->getConfig();
$config['api_cors'] = array( $config['api_cors'] = [
'enabled' => false, 'enabled' => false,
'allow_credentials' => false, 'allow_credentials' => false,
'allow_origin' => array(), 'allow_origin' => [],
'allow_headers' => array(), 'allow_headers' => [],
'allow_methods' => array(), 'allow_methods' => [],
'expose_headers' => array(), 'expose_headers' => [],
'max_age' => 0, 'max_age' => 0,
'hosts' => array(), 'hosts' => [],
); ];
$app['phraseanet.configuration']->setConfig($config); $app['phraseanet.configuration']->setConfig($config);

View File

@@ -17,7 +17,7 @@ class patch_384alpha4a implements patchInterface
private $release = '3.8.4-alpha.4'; private $release = '3.8.4-alpha.4';
/** @var array */ /** @var array */
private $concern = array(base::APPLICATION_BOX); private $concern = [base::APPLICATION_BOX];
/** /**
* {@inheritdoc} * {@inheritdoc}
@@ -58,10 +58,10 @@ class patch_384alpha4a implements patchInterface
{ {
$config = $app['phraseanet.configuration']->getConfig(); $config = $app['phraseanet.configuration']->getConfig();
$config['session'] = array( $config['session'] = [
'idle' => 0, 'idle' => 0,
'lifetime' => 604800, 'lifetime' => 604800,
); ];
$app['phraseanet.configuration']->setConfig($config); $app['phraseanet.configuration']->setConfig($config);

View File

@@ -17,7 +17,7 @@ class patch_384alpha5a implements patchInterface
private $release = '3.8.4-alpha.5'; private $release = '3.8.4-alpha.5';
/** @var array */ /** @var array */
private $concern = array(base::DATA_BOX); private $concern = [base::DATA_BOX];
/** /**
* {@inheritdoc} * {@inheritdoc}

View File

@@ -185,7 +185,6 @@ class patch_390alpha17a extends patchAbstract
); );
} }
private function fillOauthTokenTable(EntityManager $em) private function fillOauthTokenTable(EntityManager $em)
{ {
if (false === $this->tableExists($em, 'api_oauth_tokens')) { if (false === $this->tableExists($em, 'api_oauth_tokens')) {

View File

@@ -896,7 +896,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if (count($fields_to_retrieve) > 0) { if (count($fields_to_retrieve) > 0) {
$retrieved_fields = $this->get_caption()->get_highlight_fields($highlight, $fields_to_retrieve, $searchEngine); $retrieved_fields = $this->get_caption()->get_highlight_fields($highlight, $fields_to_retrieve, $searchEngine);
$titles = array(); $titles = [];
foreach ($retrieved_fields as $value) { foreach ($retrieved_fields as $value) {
foreach ($value['values'] as $v) { foreach ($value['values'] as $v) {
$titles[] = $v['value']; $titles[] = $v['value'];

View File

@@ -761,7 +761,7 @@ class set_export extends set_abstract
$tmplog = []; $tmplog = [];
$files = $list['files']; $files = $list['files'];
$event_name = in_array($type, array(Session_Logger::EVENT_EXPORTMAIL,Session_Logger::EVENT_EXPORTDOWNLOAD)) ? $type : Session_Logger::EVENT_EXPORTDOWNLOAD; $event_name = in_array($type, [Session_Logger::EVENT_EXPORTMAIL,Session_Logger::EVENT_EXPORTDOWNLOAD]) ? $type : Session_Logger::EVENT_EXPORTDOWNLOAD;
foreach ($files as $record) { foreach ($files as $record) {
foreach ($record["subdefs"] as $o => $obj) { foreach ($record["subdefs"] as $o => $obj) {

View File

@@ -8,19 +8,19 @@
* You may wish to use the Minify URI Builder app to suggest * You may wish to use the Minify URI Builder app to suggest
* changes. http://yourdomain/min/builder/ * changes. http://yourdomain/min/builder/
* */ * */
$groups = array( $groups = [
'account' => array( 'account' => [
'//include/jslibs/jquery.contextmenu_scroll.js', '//include/jslibs/jquery.contextmenu_scroll.js',
'//assets/jquery.cookie/jquery.cookie.js', '//assets/jquery.cookie/jquery.cookie.js',
'//include/jquery.common.js', '//include/jquery.common.js',
'//skins/account/account.js' '//skins/account/account.js'
), ],
'authentication_css' => array( 'authentication_css' => [
'//assets/normalize-css/normalize.css', '//assets/normalize-css/normalize.css',
'//assets/build/login.css', '//assets/build/login.css',
'//assets/font-awesome/css/font-awesome.css', '//assets/font-awesome/css/font-awesome.css',
'//assets/jquery.ui/themes/base/jquery.ui.autocomplete.css' '//assets/jquery.ui/themes/base/jquery.ui.autocomplete.css'
), ],
'authentication' => [ 'authentication' => [
'//assets/modernizr/modernizr.js', '//assets/modernizr/modernizr.js',
'//assets/requirejs/require.js', '//assets/requirejs/require.js',
@@ -150,6 +150,6 @@ $groups = array(
'//include/jslibs/SWFUpload/swfupload.js' '//include/jslibs/SWFUpload/swfupload.js'
, '//include/jslibs/SWFUpload/plugins/swfupload.queue.js' , '//include/jslibs/SWFUpload/plugins/swfupload.queue.js'
] ]
); ];
return $groups; return $groups;

View File

@@ -173,9 +173,9 @@ class LightboxTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$this->authenticate(self::$DI['app']); $this->authenticate(self::$DI['app']);
$basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 4); $basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 4);
$path = self::$DI['app']['url_generator']->generate('lightbox_validation', array( $path = self::$DI['app']['url_generator']->generate('lightbox_validation', [
'basket' => $basket->getId() 'basket' => $basket->getId()
)); ]);
$this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
@@ -225,9 +225,9 @@ class LightboxTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$this->authenticate(self::$DI['app']); $this->authenticate(self::$DI['app']);
$entry = self::$DI['app']['EM']->find('Phraseanet:Feed', 1)->getEntries()->first(); $entry = self::$DI['app']['EM']->find('Phraseanet:Feed', 1)->getEntries()->first();
$path = self::$DI['app']['url_generator']->generate('lightbox_feed_entry', array( $path = self::$DI['app']['url_generator']->generate('lightbox_feed_entry', [
'entry_id' => $entry->getId() 'entry_id' => $entry->getId()
)); ]);
$this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']); $this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);

View File

@@ -27,11 +27,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['app']['acl'] = $aclProvider; self::$DI['app']['acl'] = $aclProvider;
$path = self::$DI['app']['url_generator']->generate('datafile', array( $path = self::$DI['app']['url_generator']->generate('datafile', [
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => $subdef, 'subdef' => $subdef,
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -44,11 +44,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
public function testDatafilesNonExistentSubdef() public function testDatafilesNonExistentSubdef()
{ {
$path = self::$DI['app']['url_generator']->generate('datafile', array( $path = self::$DI['app']['url_generator']->generate('datafile', [
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => 'unknown_preview', 'subdef' => 'unknown_preview',
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$this->assertNotFoundResponse(self::$DI['client']->getResponse()); $this->assertNotFoundResponse(self::$DI['client']->getResponse());
@@ -73,11 +73,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['app']['acl'] = $aclProvider; self::$DI['app']['acl'] = $aclProvider;
$path = self::$DI['app']['url_generator']->generate('datafile', array( $path = self::$DI['app']['url_generator']->generate('datafile', [
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => 'preview', 'subdef' => 'preview',
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -94,11 +94,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
public function testDatafilesRouteNotAuthenticated() public function testDatafilesRouteNotAuthenticated()
{ {
self::$DI['app']['authentication']->closeAccount(); self::$DI['app']['authentication']->closeAccount();
$path = self::$DI['app']['url_generator']->generate('datafile', array( $path = self::$DI['app']['url_generator']->generate('datafile', [
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => 'preview', 'subdef' => 'preview',
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$this->assertForbiddenResponse(self::$DI['client']->getResponse()); $this->assertForbiddenResponse(self::$DI['client']->getResponse());
@@ -108,11 +108,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
{ {
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock(); self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
self::$DI['record_5']->move_to_collection(self::$DI['collection_no_access'], self::$DI['app']['phraseanet.appbox']); self::$DI['record_5']->move_to_collection(self::$DI['collection_no_access'], self::$DI['app']['phraseanet.appbox']);
$path = self::$DI['app']['url_generator']->generate('datafile', array( $path = self::$DI['app']['url_generator']->generate('datafile', [
'sbas_id' => self::$DI['record_5']->get_sbas_id(), 'sbas_id' => self::$DI['record_5']->get_sbas_id(),
'record_id' => self::$DI['record_5']->get_record_id(), 'record_id' => self::$DI['record_5']->get_record_id(),
'subdef' => 'preview', 'subdef' => 'preview',
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
@@ -122,11 +122,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
public function testDatafilesRouteNotAuthenticatedUnknownSubdef() public function testDatafilesRouteNotAuthenticatedUnknownSubdef()
{ {
self::$DI['app']['authentication']->closeAccount(); self::$DI['app']['authentication']->closeAccount();
$path = self::$DI['app']['url_generator']->generate('datafile', array( $path = self::$DI['app']['url_generator']->generate('datafile', [
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => 'preview', 'subdef' => 'preview',
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$this->assertForbiddenResponse(self::$DI['client']->getResponse()); $this->assertForbiddenResponse(self::$DI['client']->getResponse());
@@ -145,25 +145,25 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token();
$path = self::$DI['app']['url_generator']->generate('permalinks_permalink' ,array( $path = self::$DI['app']['url_generator']->generate('permalinks_permalink' ,[
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'label' => 'whatever.jpg', 'label' => 'whatever.jpg',
'subdef' => 'preview', 'subdef' => 'preview',
'token' => $token, 'token' => $token,
'download' => '1' 'download' => '1'
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$this->assertRegExp('/^attachment;/', $response->headers->get('content-disposition', '')); $this->assertRegExp('/^attachment;/', $response->headers->get('content-disposition', ''));
$url = self::$DI['app']['url_generator']->generate('permalinks_caption', array( $url = self::$DI['app']['url_generator']->generate('permalinks_caption', [
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'token' => $token, 'token' => $token,
), true); ], true);
$this->assertEquals($url, $response->headers->get("Link")); $this->assertEquals($url, $response->headers->get("Link"));
} }
@@ -193,11 +193,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
public function testCaptionWithaWrongToken() public function testCaptionWithaWrongToken()
{ {
$this->assertTrue(self::$DI['app']['authentication']->isAuthenticated()); $this->assertTrue(self::$DI['app']['authentication']->isAuthenticated());
$path = self::$DI['app']['url_generator']->generate('permalinks_caption', array( $path = self::$DI['app']['url_generator']->generate('permalinks_caption', [
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'token' => 'unexisting_token', 'token' => 'unexisting_token',
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -208,11 +208,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
public function testCaptionWithaWrongRecord() public function testCaptionWithaWrongRecord()
{ {
$this->assertTrue(self::$DI['app']['authentication']->isAuthenticated()); $this->assertTrue(self::$DI['app']['authentication']->isAuthenticated());
$path = self::$DI['app']['url_generator']->generate('permalinks_caption', array( $path = self::$DI['app']['url_generator']->generate('permalinks_caption', [
'sbas_id' => 0, 'sbas_id' => 0,
'record_id' => 4, 'record_id' => 4,
'token' => 'unexisting_token', 'token' => 'unexisting_token',
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -246,11 +246,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['app']['subdef.substituer']->substitute($story, $name, $media); self::$DI['app']['subdef.substituer']->substitute($story, $name, $media);
$path = self::$DI['app']['url_generator']->generate('datafile', array( $path = self::$DI['app']['url_generator']->generate('datafile', [
'sbas_id' => $story->get_sbas_id(), 'sbas_id' => $story->get_sbas_id(),
'record_id' => $story->get_record_id(), 'record_id' => $story->get_record_id(),
'subdef' => $name, 'subdef' => $name,
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -260,11 +260,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
private function get_a_caption(array $headers = []) private function get_a_caption(array $headers = [])
{ {
$path = self::$DI['app']['url_generator']->generate('permalinks_caption', array( $path = self::$DI['app']['url_generator']->generate('permalinks_caption', [
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'token' => self::$DI['record_1']->get_thumbnail()->get_permalink()->get_token(), 'token' => self::$DI['record_1']->get_thumbnail()->get_permalink()->get_token(),
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -288,13 +288,13 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token();
$path = self::$DI['app']['url_generator']->generate('permalinks_permalink_old' ,array( $path = self::$DI['app']['url_generator']->generate('permalinks_permalink_old' ,[
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'label' => 'whatever', 'label' => 'whatever',
'subdef' => 'preview', 'subdef' => 'preview',
'token' => $token 'token' => $token
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -303,11 +303,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertEquals($value, $response->headers->get($name)); $this->assertEquals($value, $response->headers->get($name));
} }
$url = self::$DI['app']['url_generator']->generate('permalinks_caption', array( $url = self::$DI['app']['url_generator']->generate('permalinks_caption', [
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'token' => $token, 'token' => $token,
), true); ], true);
$this->assertEquals($url, $response->headers->get("Link")); $this->assertEquals($url, $response->headers->get("Link"));
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
} }
@@ -318,11 +318,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
$entry = $feed->getEntries()->first(); $entry = $feed->getEntries()->first();
$item = $entry->getItems()->first(); $item = $entry->getItems()->first();
$path = self::$DI['app']['url_generator']->generate('permalinks_permaview', array( $path = self::$DI['app']['url_generator']->generate('permalinks_permaview', [
'sbas_id' => $item->getRecord(self::$DI['app'])->get_sbas_id(), 'sbas_id' => $item->getRecord(self::$DI['app'])->get_sbas_id(),
'record_id' => $item->getRecord(self::$DI['app'])->get_record_id(), 'record_id' => $item->getRecord(self::$DI['app'])->get_record_id(),
'subdef' => 'preview', 'subdef' => 'preview',
)); ]);
self::$DI['app']['authentication']->closeAccount(); self::$DI['app']['authentication']->closeAccount();
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
@@ -333,13 +333,13 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
private function get_a_permaviewBCcompatibility(array $headers = []) private function get_a_permaviewBCcompatibility(array $headers = [])
{ {
$token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token();
$path = self::$DI['app']['url_generator']->generate('permalinks_permaview_old' ,array( $path = self::$DI['app']['url_generator']->generate('permalinks_permaview_old' ,[
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'label' => 'whatever', 'label' => 'whatever',
'subdef' => 'preview', 'subdef' => 'preview',
'token' => $token 'token' => $token
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -354,13 +354,13 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token();
$path = self::$DI['app']['url_generator']->generate('permalinks_permalink' ,array( $path = self::$DI['app']['url_generator']->generate('permalinks_permalink' ,[
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'label' => 'whatever.jpg', 'label' => 'whatever.jpg',
'subdef' => 'preview', 'subdef' => 'preview',
'token' => $token 'token' => $token
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -370,11 +370,11 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertEquals($value, $response->headers->get($name)); $this->assertEquals($value, $response->headers->get($name));
} }
$url = self::$DI['app']['url_generator']->generate('permalinks_caption', array( $url = self::$DI['app']['url_generator']->generate('permalinks_caption', [
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'token' => $token, 'token' => $token,
), true); ], true);
$this->assertEquals($url, $response->headers->get("Link")); $this->assertEquals($url, $response->headers->get("Link"));
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
@@ -389,12 +389,12 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$token = self::$DI['record_1']->get_preview()->get_permalink()->get_token(); $token = self::$DI['record_1']->get_preview()->get_permalink()->get_token();
$path = self::$DI['app']['url_generator']->generate('permalinks_permaview', array( $path = self::$DI['app']['url_generator']->generate('permalinks_permaview', [
'sbas_id' => self::$DI['record_1']->get_sbas_id(), 'sbas_id' => self::$DI['record_1']->get_sbas_id(),
'record_id' => self::$DI['record_1']->get_record_id(), 'record_id' => self::$DI['record_1']->get_record_id(),
'subdef' => 'preview', 'subdef' => 'preview',
'token' => $token 'token' => $token
)); ]);
self::$DI['client']->request('GET', $path); self::$DI['client']->request('GET', $path);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();

View File

@@ -123,10 +123,10 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes();
$databox = array_shift($databoxes); $databox = array_shift($databoxes);
$fieldObjects = array(); $fieldObjects = [];
// create two fields // create two fields
$fields = array( $fields = [
array( [
'sbas-id' => $databox->get_sbas_id(), 'sbas-id' => $databox->get_sbas_id(),
'name' => 'testfield' . mt_rand(), 'name' => 'testfield' . mt_rand(),
'multi' => true, 'multi' => true,
@@ -143,7 +143,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
'dces-element' => null, 'dces-element' => null,
'vocabulary-type' => null, 'vocabulary-type' => null,
'vocabulary-restricted' => false, 'vocabulary-restricted' => false,
), array( ], [
'sbas-id' => $databox->get_sbas_id(), 'sbas-id' => $databox->get_sbas_id(),
'name' => 'testfield' . mt_rand(), 'name' => 'testfield' . mt_rand(),
'multi' => true, 'multi' => true,
@@ -160,7 +160,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
'dces-element' => null, 'dces-element' => null,
'vocabulary-type' => null, 'vocabulary-type' => null,
'vocabulary-restricted' => false, 'vocabulary-restricted' => false,
)); ]];
foreach ($fields as $fieldData) { foreach ($fields as $fieldData) {
$field = \databox_field::create(self::$DI['app'], $databox, $fieldData['name'], $fieldData['multi']); $field = \databox_field::create(self::$DI['app'], $databox, $fieldData['name'], $fieldData['multi']);
@@ -190,7 +190,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
$body[count($body) - 1]['readonly'] = true; $body[count($body) - 1]['readonly'] = true;
$body[count($body) - 1]['required'] = false; $body[count($body) - 1]['required'] = false;
self::$DI['client']->request("PUT", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), array(), array(), array(), json_encode($body)); self::$DI['client']->request("PUT", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), [], [], [], json_encode($body));
$response = self::$DI['client']->getResponse()->getContent(); $response = self::$DI['client']->getResponse()->getContent();
@@ -214,7 +214,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
$databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes();
$databox = array_shift($databoxes); $databox = array_shift($databoxes);
$body = json_encode(array( $body = json_encode([
'sbas-id' => $databox->get_sbas_id(), 'sbas-id' => $databox->get_sbas_id(),
'name' => 'testfield' . mt_rand(), 'name' => 'testfield' . mt_rand(),
'multi' => true, 'multi' => true,
@@ -223,12 +223,12 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
'business' => false, 'business' => false,
'indexable' => true, 'indexable' => true,
'required' => true, 'required' => true,
'labels' => array( 'labels' => [
'en' => 'Label', 'en' => 'Label',
'fr' => 'Libellé', 'fr' => 'Libellé',
'de' => null, 'de' => null,
'nl' => null, 'nl' => null,
), ],
'separator' => '=;', 'separator' => '=;',
'readonly' => false, 'readonly' => false,
'type' => 'string', 'type' => 'string',
@@ -237,9 +237,9 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
'dces-element' => null, 'dces-element' => null,
'vocabulary-type' => 'User', 'vocabulary-type' => 'User',
'vocabulary-restricted' => true, 'vocabulary-restricted' => true,
)); ]);
self::$DI['client']->request("POST", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), array(), array(), array(), $body); self::$DI['client']->request("POST", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), [], [], [], $body);
$response = self::$DI['client']->getResponse()->getContent(); $response = self::$DI['client']->getResponse()->getContent();
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type")); $this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
@@ -308,7 +308,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
$data['business'] = true; $data['business'] = true;
$data['vocabulary-type'] = 'User'; $data['vocabulary-type'] = 'User';
self::$DI['client']->request("PUT", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()), array(), array(), array(), json_encode($data)); self::$DI['client']->request("PUT", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()), [], [], [], json_encode($data));
$response = self::$DI['client']->getResponse()->getContent(); $response = self::$DI['client']->getResponse()->getContent();
$this->assertEquals($data, json_decode($response, true)); $this->assertEquals($data, json_decode($response, true));
@@ -329,7 +329,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
$data['business'] = true; $data['business'] = true;
$data['vocabulary-type'] = 'User'; $data['vocabulary-type'] = 'User';
self::$DI['client']->request("DELETE", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()), array(), array(), array(), json_encode($data)); self::$DI['client']->request("DELETE", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()), [], [], [], json_encode($data));
$response = self::$DI['client']->getResponse()->getContent(); $response = self::$DI['client']->getResponse()->getContent();
$this->assertEquals('', $response); $this->assertEquals('', $response);
@@ -345,7 +345,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
private function assertField($field) private function assertField($field)
{ {
$properties = array( $properties = [
'name', 'name',
'multi', 'multi',
'thumbtitle', 'thumbtitle',
@@ -361,7 +361,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
'dces-element', 'dces-element',
'vocabulary-type', 'vocabulary-type',
'vocabulary-restricted' 'vocabulary-restricted'
); ];
foreach ($properties as $property) { foreach ($properties as $property) {
$this->assertArrayHasKey($property, $field); $this->assertArrayHasKey($property, $field);

View File

@@ -24,13 +24,13 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database']; $connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
$params = array( $params = [
"hostname" => $connexion['host'], "hostname" => $connexion['host'],
"port" => $connexion['port'], "port" => $connexion['port'],
"user" => $connexion['user'], "user" => $connexion['user'],
"password" => $connexion['password'], "password" => $connexion['password'],
"dbname" => $connexion['dbname'], "dbname" => $connexion['dbname'],
); ];
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params); self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -49,13 +49,13 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
public function testRouteMysqlFailed() public function testRouteMysqlFailed()
{ {
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database']; $connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
$params = array( $params = [
"hostname" => $connexion['host'], "hostname" => $connexion['host'],
"port" => $connexion['port'], "port" => $connexion['port'],
"user" => $connexion['user'] . 'fake', "user" => $connexion['user'] . 'fake',
"password" => $connexion['password'], "password" => $connexion['password'],
"dbname" => $connexion['dbname'], "dbname" => $connexion['dbname'],
); ];
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params); self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -75,13 +75,13 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database']; $connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
$params = array( $params = [
"hostname" => $connexion['host'], "hostname" => $connexion['host'],
"port" => $connexion['port'], "port" => $connexion['port'],
"user" => $connexion['user'], "user" => $connexion['user'],
"password" => $connexion['password'], "password" => $connexion['password'],
"dbname" => "fake-database-name" "dbname" => "fake-database-name"
); ];
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params); self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -104,7 +104,7 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
public function testRoutePath() public function testRoutePath()
{ {
$file = new \SplFileObject(__DIR__ . '/../../../../../files/cestlafete.jpg'); $file = new \SplFileObject(__DIR__ . '/../../../../../files/cestlafete.jpg');
self::$DI['client']->request("GET", "/admin/tests/pathurl/path/", array('path' => $file->getPathname())); self::$DI['client']->request("GET", "/admin/tests/pathurl/path/", ['path' => $file->getPathname()]);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
@@ -120,7 +120,7 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
public function testRouteUrl() public function testRouteUrl()
{ {
self::$DI['client']->request("GET", "/admin/tests/pathurl/url/", array('url' => "www.google.com")); self::$DI['client']->request("GET", "/admin/tests/pathurl/url/", ['url' => "www.google.com"]);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());

View File

@@ -48,7 +48,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
$user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), 'test', 'titi@titi.fr'); $user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), 'test', 'titi@titi.fr');
self::giveRightsToUser(self::$DI['app'], self::$DI['app']['authentication']->getUser(), array(self::$DI['collection']->get_base_id()), true); self::giveRightsToUser(self::$DI['app'], self::$DI['app']['authentication']->getUser(), [self::$DI['collection']->get_base_id()], true);
self::$DI['client']->request('POST', '/admin/users/rights/apply/', [ self::$DI['client']->request('POST', '/admin/users/rights/apply/', [
'users' => $user->getId(), 'users' => $user->getId(),
@@ -432,7 +432,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
// create a template // create a template
if (null === self::$DI['app']['repo.users']->findByLogin('csv_template')) { if (null === self::$DI['app']['repo.users']->findByLogin('csv_template')) {
$user = self::$DI['app']['manipulator.user']->createTemplate('csv_template', self::$DI['app']['authentication']->getUser()); $user = self::$DI['app']['manipulator.user']->createTemplate('csv_template', self::$DI['app']['authentication']->getUser());
self::$DI['app']['acl']->get($user)->update_rights_to_base(self::$DI['collection']->get_base_id(), array('actif'=> 1)); self::$DI['app']['acl']->get($user)->update_rights_to_base(self::$DI['collection']->get_base_id(), ['actif'=> 1]);
} }
$nativeQueryMock = $this->getMockBuilder('Alchemy\Phrasea\Model\NativeQueryProvider') $nativeQueryMock = $this->getMockBuilder('Alchemy\Phrasea\Model\NativeQueryProvider')
@@ -456,11 +456,11 @@ CSV;
$filepath = sys_get_temp_dir().'/user.csv'; $filepath = sys_get_temp_dir().'/user.csv';
file_put_contents($filepath,$data); file_put_contents($filepath,$data);
$files = array( $files = [
'files' => new \Symfony\Component\HttpFoundation\File\UploadedFile($filepath, 'user.csv') 'files' => new \Symfony\Component\HttpFoundation\File\UploadedFile($filepath, 'user.csv')
); ];
$crawler = self::$DI['client']->request('POST', '/admin/users/import/file/', array(), $files); $crawler = self::$DI['client']->request('POST', '/admin/users/import/file/', [], $files);
$this->assertGreaterThan(0, $crawler->filter('html:contains("4 Users")')->count()); $this->assertGreaterThan(0, $crawler->filter('html:contains("4 Users")')->count());
} }

View File

@@ -7,7 +7,6 @@ use Alchemy\Phrasea\Border\File;
use Alchemy\Phrasea\Controller\Api\V1; use Alchemy\Phrasea\Controller\Api\V1;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Authentication\Context; use Alchemy\Phrasea\Authentication\Context;
use Alchemy\Phrasea\Model\Entities\ApiApplication;
use Alchemy\Phrasea\Model\Entities\Task; use Alchemy\Phrasea\Model\Entities\Task;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
@@ -52,7 +51,6 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
$this->adminAccessToken = current($tokens); $this->adminAccessToken = current($tokens);
} }
if (null === $this->userAccessToken) { if (null === $this->userAccessToken) {
$tokens = self::$DI['app']['repo.api-oauth-tokens']->findOauthTokens(self::$DI['oauth2-app-acc-user-not-admin']); $tokens = self::$DI['app']['repo.api-oauth-tokens']->findOauthTokens(self::$DI['oauth2-app-acc-user-not-admin']);
if (count($tokens) === 0) { if (count($tokens) === 0) {

View File

@@ -4,7 +4,6 @@ namespace Alchemy\Tests\Phrasea\Controller\Api;
use Alchemy\Phrasea\Core\PhraseaEvents; use Alchemy\Phrasea\Core\PhraseaEvents;
use Alchemy\Phrasea\Authentication\Context; use Alchemy\Phrasea\Authentication\Context;
use Alchemy\Phrasea\Model\Entities\ApiApplication;
class OAuth2Test extends \PhraseanetAuthenticatedWebTestCase class OAuth2Test extends \PhraseanetAuthenticatedWebTestCase
{ {

View File

@@ -44,7 +44,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 1); $basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 1);
self::$DI['client']->request('POST', '/prod/bridge/manager/', array('ssel' => $basket->getId())); self::$DI['client']->request('POST', '/prod/bridge/manager/', ['ssel' => $basket->getId()]);
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
} }
@@ -135,7 +135,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
$url = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $url = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
$account = new \Bridge_Account(self::$DI['app'], self::$api, self::$account->get_id()); $account = new \Bridge_Account(self::$DI['app'], self::$api, self::$account->get_id());
$crawler = self::$DI['client']->request('GET', $url, array("page" => 1)); $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]);
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
$this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent()); $this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent());
} }
@@ -144,7 +144,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
{ {
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
$url = sprintf("/prod/bridge/adapter/%s/load-records/", self::$account->get_id()); $url = sprintf("/prod/bridge/adapter/%s/load-records/", self::$account->get_id());
$crawler = self::$DI['client']->request('GET', $url, array("page" => 1)); $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]);
$elements = \Bridge_Element::get_elements_by_account(self::$DI['app'], self::$account); $elements = \Bridge_Element::get_elements_by_account(self::$DI['app'], self::$account);
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
$this->assertEquals(sizeof($elements), $crawler->filterXPath("//table/tr")->count()); $this->assertEquals(sizeof($elements), $crawler->filterXPath("//table/tr")->count());
@@ -156,7 +156,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['client']->followRedirects(); self::$DI['client']->followRedirects();
self::$account->get_settings()->set("auth_token", null); //deconnected self::$account->get_settings()->set("auth_token", null); //deconnected
$url = sprintf("/prod/bridge/adapter/%s/load-records/", self::$account->get_id()); $url = sprintf("/prod/bridge/adapter/%s/load-records/", self::$account->get_id());
$crawler = self::$DI['client']->request('GET', $url, array("page" => 1)); $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]);
$pageContent = self::$DI['client']->getResponse()->getContent(); $pageContent = self::$DI['client']->getResponse()->getContent();
$this->assertContains($url, $pageContent); $this->assertContains($url, $pageContent);
$this->deconnected($crawler, $pageContent); $this->deconnected($crawler, $pageContent);
@@ -166,7 +166,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
{ {
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
$url = sprintf("/prod/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type()); $url = sprintf("/prod/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
$crawler = self::$DI['client']->request('GET', $url, array("page" => 1)); $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]);
$elements = \Bridge_Element::get_elements_by_account(self::$DI['app'], self::$account); $elements = \Bridge_Element::get_elements_by_account(self::$DI['app'], self::$account);
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
$this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent()); $this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent());
@@ -177,7 +177,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['client']->followRedirects(); self::$DI['client']->followRedirects();
self::$account->get_settings()->set("auth_token", null); //deconnected self::$account->get_settings()->set("auth_token", null); //deconnected
$url = sprintf("/prod/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type()); $url = sprintf("/prod/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
$crawler = self::$DI['client']->request('GET', $url, array("page" => 1)); $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]);
$pageContent = self::$DI['client']->getResponse()->getContent(); $pageContent = self::$DI['client']->getResponse()->getContent();
$this->assertContains($url, $pageContent); $this->assertContains($url, $pageContent);
$this->deconnected($crawler, $pageContent); $this->deconnected($crawler, $pageContent);
@@ -188,7 +188,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['client']->followRedirects(); self::$DI['client']->followRedirects();
self::$account->get_settings()->set("auth_token", null); //deconnected self::$account->get_settings()->set("auth_token", null); //deconnected
$url = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $url = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
$crawler = self::$DI['client']->request('GET', $url, array("page" => 1)); $crawler = self::$DI['client']->request('GET', $url, ["page" => 1]);
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
$pageContent = self::$DI['client']->getResponse()->getContent(); $pageContent = self::$DI['client']->getResponse()->getContent();
$this->assertContains($url, $pageContent); $this->assertContains($url, $pageContent);
@@ -222,14 +222,14 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
$url = sprintf("/prod/bridge/action/%s/ajjfhfjozqd/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $url = sprintf("/prod/bridge/action/%s/ajjfhfjozqd/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
try { try {
$crawler = self::$DI['client']->request('GET', $url, array("elements_list" => "1;2;3")); $crawler = self::$DI['client']->request('GET', $url, ["elements_list" => "1;2;3"]);
$this->fail("expected Exception here"); $this->fail("expected Exception here");
} catch (\Exception $e) { } catch (\Exception $e) {
} }
try { try {
$crawler = self::$DI['client']->request('POST', $url, array("elements_list" => "1;2;3")); $crawler = self::$DI['client']->request('POST', $url, ["elements_list" => "1;2;3"]);
$this->fail("expected Exception here"); $this->fail("expected Exception here");
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -240,14 +240,14 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
{ {
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
$url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
$crawler = self::$DI['client']->request('GET', $url, array("element_list" => "1_2;1_3;1_4")); $crawler = self::$DI['client']->request('GET', $url, ["element_list" => "1_2;1_3;1_4"]);
$redirect = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $redirect = sprintf("/prod/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertContains($redirect, self::$DI['client']->getResponse()->headers->get("location")); $this->assertContains($redirect, self::$DI['client']->getResponse()->headers->get("location"));
$this->assertContains("error=", self::$DI['client']->getResponse()->headers->get("location")); $this->assertContains("error=", self::$DI['client']->getResponse()->headers->get("location"));
$this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent()); $this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent());
self::$DI['client']->request('POST', $url, array("element_list" => "1_2;1_3;1_4")); self::$DI['client']->request('POST', $url, ["element_list" => "1_2;1_3;1_4"]);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
} }
@@ -255,11 +255,11 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
{ {
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
$url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
$crawler = self::$DI['client']->request('GET', $url, array("elements_list" => "element123qcs789")); $crawler = self::$DI['client']->request('GET', $url, ["elements_list" => "element123qcs789"]);
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
$this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent()); $this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent());
self::$DI['client']->request('POST', $url, array("elements_list" => "element123qcs789")); self::$DI['client']->request('POST', $url, ["elements_list" => "element123qcs789"]);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
} }
@@ -268,7 +268,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
self::$account->get_settings()->set("auth_token", "somethingNotNull"); self::$account->get_settings()->set("auth_token", "somethingNotNull");
\Bridge_Api_Apitest::$hasError = true; \Bridge_Api_Apitest::$hasError = true;
$url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
self::$DI['client']->request('POST', $url, array("elements_list" => "element123qcs789")); self::$DI['client']->request('POST', $url, ["elements_list" => "element123qcs789"]);
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
} }
@@ -277,7 +277,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
self::$account->get_settings()->set("auth_token", "somethingNotNull"); self::$account->get_settings()->set("auth_token", "somethingNotNull");
\Bridge_Api_Apitest::$hasException = true; \Bridge_Api_Apitest::$hasException = true;
$url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
self::$DI['client']->request('POST', $url, array("elements_list" => "element123qcs789")); self::$DI['client']->request('POST', $url, ["elements_list" => "element123qcs789"]);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertRegexp('/error/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertRegexp('/error/', self::$DI['client']->getResponse()->headers->get('location'));
} }
@@ -286,17 +286,17 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
{ {
self::$account->get_settings()->set("auth_token", "somethingNotNull"); self::$account->get_settings()->set("auth_token", "somethingNotNull");
$url = sprintf("/prod/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $url = sprintf("/prod/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
self::$DI['client']->request('GET', $url, array("elements_list" => "element123qcs789")); self::$DI['client']->request('GET', $url, ["elements_list" => "element123qcs789"]);
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
\Bridge_Api_Apitest::$hasException = true; \Bridge_Api_Apitest::$hasException = true;
$url = sprintf("/prod/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $url = sprintf("/prod/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
self::$DI['client']->request('POST', $url, array("elements_list" => "element123qcs789")); self::$DI['client']->request('POST', $url, ["elements_list" => "element123qcs789"]);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertRegexp('/error/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertRegexp('/error/', self::$DI['client']->getResponse()->headers->get('location'));
$url = sprintf("/prod/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $url = sprintf("/prod/bridge/action/%s/deleteelement/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
self::$DI['client']->request('POST', $url, array("elements_list" => "element123qcs789")); self::$DI['client']->request('POST', $url, ["elements_list" => "element123qcs789"]);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
} }
@@ -315,7 +315,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertRegexp('/error/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertRegexp('/error/', self::$DI['client']->getResponse()->headers->get('location'));
$url = sprintf("/prod/bridge/action/%s/createcontainer/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type()); $url = sprintf("/prod/bridge/action/%s/createcontainer/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
self::$DI['client']->request('POST', $url, array('title' => 'test', 'description' => 'description')); self::$DI['client']->request('POST', $url, ['title' => 'test', 'description' => 'description']);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertRegexp('/success/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertRegexp('/success/', self::$DI['client']->getResponse()->headers->get('location'));
} }
@@ -328,12 +328,12 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
$this->markTestSkipped("No templates declared for modify a container in any apis"); $this->markTestSkipped("No templates declared for modify a container in any apis");
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
$url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type()); $url = sprintf("/prod/bridge/action/%s/modify/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
$crawler = self::$DI['client']->request('GET', $url, array("elements_list" => "containerudt456shn")); $crawler = self::$DI['client']->request('GET', $url, ["elements_list" => "containerudt456shn"]);
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
$pageContent = self::$DI['client']->getResponse()->getContent(); $pageContent = self::$DI['client']->getResponse()->getContent();
$this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent()); $this->assertNotContains(self::$account->get_api()->generate_login_url(self::$DI['app']['url_generator'], self::$account->get_api()->get_connector()->get_name()), self::$DI['client']->getResponse()->getContent());
self::$DI['client']->request('POST', $url, array("elements_list" => "containerudt456shn")); self::$DI['client']->request('POST', $url, ["elements_list" => "containerudt456shn"]);
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
} }
@@ -341,16 +341,16 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
{ {
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
$url = sprintf("/prod/bridge/action/%s/moveinto/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type()); $url = sprintf("/prod/bridge/action/%s/moveinto/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
$crawler = self::$DI['client']->request('GET', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type())); $crawler = self::$DI['client']->request('GET', $url, ["elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()]);
$this->assertNotContains("http://dev.phrasea.net/prod/bridge/login/youtube/", self::$DI['client']->getResponse()->getContent()); $this->assertNotContains("http://dev.phrasea.net/prod/bridge/login/youtube/", self::$DI['client']->getResponse()->getContent());
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
self::$DI['client']->request('POST', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type())); self::$DI['client']->request('POST', $url, ["elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()]);
$this->assertRegexp('/success/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertRegexp('/success/', self::$DI['client']->getResponse()->headers->get('location'));
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
\Bridge_Api_Apitest::$hasException = true; \Bridge_Api_Apitest::$hasException = true;
self::$DI['client']->request('POST', $url, array("elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type())); self::$DI['client']->request('POST', $url, ["elements_list" => "containerudt456shn", 'destination' => self::$account->get_api()->get_connector()->get_default_container_type()]);
$this->assertRegexp('/error/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertRegexp('/error/', self::$DI['client']->getResponse()->headers->get('location'));
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
} }
@@ -365,22 +365,22 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
{ {
self::$account->get_settings()->set("auth_token", "somethingNotNull"); self::$account->get_settings()->set("auth_token", "somethingNotNull");
$url = "/prod/bridge/upload/"; $url = "/prod/bridge/upload/";
self::$DI['client']->request('GET', $url, array("account_id" => self::$account->get_id())); self::$DI['client']->request('GET', $url, ["account_id" => self::$account->get_id()]);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
$records = array( $records = [
self::$DI['record_1']->get_serialize_key() self::$DI['record_1']->get_serialize_key()
); ];
\Bridge_Api_Apitest::$hasError = true; \Bridge_Api_Apitest::$hasError = true;
$lst = implode(';', $records); $lst = implode(';', $records);
self::$DI['client']->request('POST', $url, array("account_id" => self::$account->get_id(), 'lst' => $lst)); self::$DI['client']->request('POST', $url, ["account_id" => self::$account->get_id(), 'lst' => $lst]);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
self::$DI['client']->request('POST', $url, array("account_id" => self::$account->get_id(), 'lst' => $lst)); self::$DI['client']->request('POST', $url, ["account_id" => self::$account->get_id(), 'lst' => $lst]);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
} }

View File

@@ -61,7 +61,6 @@ class PropertyTest extends \PhraseanetAuthenticatedWebTestCase
$story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']); $story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']);
$story->appendChild($record2); $story->appendChild($record2);
$acl = $this->getMockBuilder('ACL') $acl = $this->getMockBuilder('ACL')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

View File

@@ -93,7 +93,7 @@ class UploadTest extends \PhraseanetAuthenticatedWebTestCase
$record = new \record_adapter(self::$DI['app'], $id[0], $id[1]); $record = new \record_adapter(self::$DI['app'], $id[0], $id[1]);
$this->assertTrue($record->get_thumbnail()->is_physically_present()); $this->assertTrue($record->get_thumbnail()->is_physically_present());
$field = array_pop($record->get_caption()->get_fields(array('FileName'))); $field = array_pop($record->get_caption()->get_fields(['FileName']));
$this->assertEquals($field->get_serialized_values(), 'KIKOO.JPG'); $this->assertEquals($field->get_serialized_values(), 'KIKOO.JPG');
} }
} }

View File

@@ -3,7 +3,6 @@
namespace Alchemy\Tests\Phrasea\Controller\Root; namespace Alchemy\Tests\Phrasea\Controller\Root;
use Alchemy\Phrasea\Model\Entities\ApiApplication; use Alchemy\Phrasea\Model\Entities\ApiApplication;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class DevelopersTest extends \PhraseanetAuthenticatedWebTestCase class DevelopersTest extends \PhraseanetAuthenticatedWebTestCase
{ {

View File

@@ -1779,10 +1779,10 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
public function testLoginPageWithIdleSessionTime() public function testLoginPageWithIdleSessionTime()
{ {
$this->logout(self::$DI['app']); $this->logout(self::$DI['app']);
self::$DI['app']['phraseanet.configuration']['session'] = array( self::$DI['app']['phraseanet.configuration']['session'] = [
'idle' =>10, 'idle' =>10,
'lifetime' => 60475, 'lifetime' => 60475,
); ];
$crawler = self::$DI['client']->request('GET', '/login/'); $crawler = self::$DI['client']->request('GET', '/login/');
@@ -1793,10 +1793,10 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
public function testLoginPageWithNoIdleSessionTime() public function testLoginPageWithNoIdleSessionTime()
{ {
$this->logout(self::$DI['app']); $this->logout(self::$DI['app']);
self::$DI['app']['phraseanet.configuration']['session'] = array( self::$DI['app']['phraseanet.configuration']['session'] = [
'idle' => 0, 'idle' => 0,
'lifetime' => 60475, 'lifetime' => 60475,
); ];
$crawler = self::$DI['client']->request('GET', '/login/'); $crawler = self::$DI['client']->request('GET', '/login/');

View File

@@ -12,17 +12,17 @@ class ApiCorsSubscriberTest extends \PHPUnit_Framework_TestCase
public function testHostRestriction() public function testHostRestriction()
{ {
$response = $this->request(array('enabled' => true, 'hosts' => array('http://api.domain.com'))); $response = $this->request(['enabled' => true, 'hosts' => ['http://api.domain.com']]);
$this->assertArrayNotHasKey('access-control-allow-origin', $response->headers->all()); $this->assertArrayNotHasKey('access-control-allow-origin', $response->headers->all());
$response = $this->request(array('enabled' => true, 'hosts' => array('localhost'))); $response = $this->request(['enabled' => true, 'hosts' => ['localhost']]);
$this->assertArrayHasKey('access-control-allow-origin', $response->headers->all()); $this->assertArrayHasKey('access-control-allow-origin', $response->headers->all());
} }
public function testExposeHeaders() public function testExposeHeaders()
{ {
$response = $this->request( $response = $this->request(
array('enabled' => true, 'allow_origin' => array('*'), 'expose_headers' => array('HTTP_X_CUSTOM')), ['enabled' => true, 'allow_origin' => ['*'], 'expose_headers' => ['HTTP_X_CUSTOM']],
'GET' 'GET'
); );
$this->assertArrayHasKey('access-control-expose-headers', $response->headers->all()); $this->assertArrayHasKey('access-control-expose-headers', $response->headers->all());
@@ -32,17 +32,17 @@ class ApiCorsSubscriberTest extends \PHPUnit_Framework_TestCase
public function testAllowMethods() public function testAllowMethods()
{ {
$response = $this->request( $response = $this->request(
array('enabled' => true, 'allow_origin' => array('*'), 'allow_methods' => array('GET', 'POST', 'PUT')), ['enabled' => true, 'allow_origin' => ['*'], 'allow_methods' => ['GET', 'POST', 'PUT']],
'OPTIONS' 'OPTIONS'
); );
$this->assertArrayHasKey('access-control-allow-methods', $response->headers->all()); $this->assertArrayHasKey('access-control-allow-methods', $response->headers->all());
$this->assertEquals(implode(', ', array('GET', 'POST', 'PUT')), $response->headers->get('access-control-allow-methods')); $this->assertEquals(implode(', ', ['GET', 'POST', 'PUT']), $response->headers->get('access-control-allow-methods'));
} }
public function testAllowHeaders() public function testAllowHeaders()
{ {
$response = $this->request( $response = $this->request(
array('enabled' => true, 'allow_origin' => array('*'), 'allow_headers' => array('HTTP_X_CUSTOM')), ['enabled' => true, 'allow_origin' => ['*'], 'allow_headers' => ['HTTP_X_CUSTOM']],
'OPTIONS' 'OPTIONS'
); );
$this->assertArrayHasKey('access-control-allow-headers', $response->headers->all()); $this->assertArrayHasKey('access-control-allow-headers', $response->headers->all());
@@ -51,26 +51,26 @@ class ApiCorsSubscriberTest extends \PHPUnit_Framework_TestCase
public function testCORSIsEnable() public function testCORSIsEnable()
{ {
$response = $this->request(array('enabled' => true)); $response = $this->request(['enabled' => true]);
$this->assertArrayHasKey('access-control-allow-origin', $response->headers->all()); $this->assertArrayHasKey('access-control-allow-origin', $response->headers->all());
} }
public function testCORSIsDisable() public function testCORSIsDisable()
{ {
$response = $this->request(array('enabled' => false)); $response = $this->request(['enabled' => false]);
$this->assertArrayNotHasKey('access-control-allow-origin', $response->headers->all()); $this->assertArrayNotHasKey('access-control-allow-origin', $response->headers->all());
} }
public function testAllowOrigin() public function testAllowOrigin()
{ {
$response = $this->request(array('enabled' => true, 'allow_origin' => array('*'))); $response = $this->request(['enabled' => true, 'allow_origin' => ['*']]);
$this->assertArrayHasKey('access-control-allow-origin', $response->headers->all()); $this->assertArrayHasKey('access-control-allow-origin', $response->headers->all());
$this->assertEquals($this->origin, $response->headers->get('access-control-allow-origin')); $this->assertEquals($this->origin, $response->headers->get('access-control-allow-origin'));
} }
public function testCredentialIsEnabled() public function testCredentialIsEnabled()
{ {
$response = $this->request(array('enabled' => true, 'allow_credentials' => true, 'allow_origin' => array('*'))); $response = $this->request(['enabled' => true, 'allow_credentials' => true, 'allow_origin' => ['*']]);
$this->assertArrayHasKey('access-control-allow-credentials', $response->headers->all()); $this->assertArrayHasKey('access-control-allow-credentials', $response->headers->all());
} }
@@ -81,7 +81,7 @@ class ApiCorsSubscriberTest extends \PHPUnit_Framework_TestCase
* *
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
private function request(array $conf, $method = 'GET', array $extraHeaders = array()) private function request(array $conf, $method = 'GET', array $extraHeaders = [])
{ {
$app = new Application('test'); $app = new Application('test');
$app['phraseanet.configuration']['api_cors'] = $conf; $app['phraseanet.configuration']['api_cors'] = $conf;
@@ -91,13 +91,13 @@ class ApiCorsSubscriberTest extends \PHPUnit_Framework_TestCase
}); });
$client = new Client($app); $client = new Client($app);
$client->request($method, '/api/v1/test-route', $client->request($method, '/api/v1/test-route',
array(), [],
array(), [],
array_merge( array_merge(
$extraHeaders, $extraHeaders,
array( [
'HTTP_Origin' => $this->origin, 'HTTP_Origin' => $this->origin,
) ]
) )
); );

View File

@@ -13,10 +13,10 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$app = new Application('test'); $app = new Application('test');
$app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app)); $app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app));
$app['phraseanet.configuration']['session'] = array( $app['phraseanet.configuration']['session'] = [
'idle' => 0, 'idle' => 0,
'lifetime' => 60475, 'lifetime' => 60475,
); ];
$app->get('/login', function () { $app->get('/login', function () {
return ''; return '';
@@ -39,10 +39,10 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$app = new Application('test'); $app = new Application('test');
$app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app)); $app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app));
$app['phraseanet.configuration']['session'] = array( $app['phraseanet.configuration']['session'] = [
'idle' => 0, 'idle' => 0,
'lifetime' => 60475, 'lifetime' => 60475,
); ];
$app->get('/login', function () { $app->get('/login', function () {
return ''; return '';
@@ -53,11 +53,11 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
}); });
$client = new Client($app); $client = new Client($app);
$client->request('GET', '/prod', array(), array(), array( $client->request('GET', '/prod', [], [], [
'HTTP_ACCEPT' => 'application/json', 'HTTP_ACCEPT' => 'application/json',
'HTTP_X-Requested-With' => 'XMLHttpRequest', 'HTTP_X-Requested-With' => 'XMLHttpRequest',
)); ]);
$this->assertTrue($client->getResponse()->isClientError()); $this->assertTrue($client->getResponse()->isClientError());
$this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session')); $this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session'));
@@ -79,10 +79,10 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
$app['EM']->expects($this->exactly(4))->method('persist')->will($this->returnValue(null)); $app['EM']->expects($this->exactly(4))->method('persist')->will($this->returnValue(null));
$app['EM']->expects($this->exactly(2))->method('flush')->will($this->returnValue(null)); $app['EM']->expects($this->exactly(2))->method('flush')->will($this->returnValue(null));
$app['phraseanet.configuration']['session'] = array( $app['phraseanet.configuration']['session'] = [
'idle' => 0, 'idle' => 0,
'lifetime' => 60475, 'lifetime' => 60475,
); ];
$app->get('/login', function () { $app->get('/login', function () {
return ''; return '';
})->bind("homepage"); })->bind("homepage");
@@ -114,10 +114,10 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
$app['EM']->expects($this->any())->method('persist')->will($this->returnValue(null)); $app['EM']->expects($this->any())->method('persist')->will($this->returnValue(null));
$app['EM']->expects($this->any())->method('flush')->will($this->returnValue(null)); $app['EM']->expects($this->any())->method('flush')->will($this->returnValue(null));
$app['phraseanet.configuration']['session'] = array( $app['phraseanet.configuration']['session'] = [
'idle' => 10, 'idle' => 10,
'lifetime' => 60475, 'lifetime' => 60475,
); ];
$app->get('/login', function () { $app->get('/login', function () {
return ''; return '';
})->bind("homepage"); })->bind("homepage");
@@ -152,10 +152,10 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
$app['EM']->expects($this->any())->method('persist')->will($this->returnValue(null)); $app['EM']->expects($this->any())->method('persist')->will($this->returnValue(null));
$app['EM']->expects($this->any())->method('flush')->will($this->returnValue(null)); $app['EM']->expects($this->any())->method('flush')->will($this->returnValue(null));
$app['phraseanet.configuration']['session'] = array( $app['phraseanet.configuration']['session'] = [
'idle' => 10, 'idle' => 10,
'lifetime' => 60475, 'lifetime' => 60475,
); ];
$app->get('/login', function () { $app->get('/login', function () {
return ''; return '';
})->bind("homepage"); })->bind("homepage");
@@ -165,10 +165,10 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
}); });
$client = new Client($app); $client = new Client($app);
$client->request('GET', '/prod', array(), array(), array( $client->request('GET', '/prod', [], [], [
'HTTP_ACCEPT' => 'application/json', 'HTTP_ACCEPT' => 'application/json',
'HTTP_X-Requested-With' => 'XMLHttpRequest', 'HTTP_X-Requested-With' => 'XMLHttpRequest',
)); ]);
$this->assertTrue($client->getResponse()->isClientError()); $this->assertTrue($client->getResponse()->isClientError());
$this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session')); $this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session'));
@@ -216,18 +216,18 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
}); });
$client = new Client($app); $client = new Client($app);
$client->request('GET', $route, array(), array(), array( $client->request('GET', $route, [], [], [
'HTTP_CONTENT-TYPE' => 'application/json', 'HTTP_CONTENT-TYPE' => 'application/json',
'HTTP_ACCEPT' => 'application/json', 'HTTP_ACCEPT' => 'application/json',
'HTTP_X-Requested-With' => 'XMLHttpRequest', 'HTTP_X-Requested-With' => 'XMLHttpRequest',
)); ]);
} }
public function forbiddenRouteProvider() public function forbiddenRouteProvider()
{ {
return array( return [
array('/admin/databox/17/informations/documents/'), ['/admin/databox/17/informations/documents/'],
array('/admin/task-manager/tasks/'), ['/admin/task-manager/tasks/'],
); ];
} }
} }

View File

@@ -4,7 +4,6 @@ namespace Alchemy\Tests\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Controller\Api\V1; use Alchemy\Phrasea\Controller\Api\V1;
use Alchemy\Phrasea\Model\Manipulator\ApiAccountManipulator; use Alchemy\Phrasea\Model\Manipulator\ApiAccountManipulator;
use Alchemy\Phrasea\Model\Entities\ApiApplication;
class ApiAccountManipulatorTest extends \PhraseanetTestCase class ApiAccountManipulatorTest extends \PhraseanetTestCase
{ {

View File

@@ -24,7 +24,7 @@ class ApiLogManipulatorTest extends \PhraseanetTestCase
*/ */
public function testsLogHydration($path, $expected) public function testsLogHydration($path, $expected)
{ {
$emMock = $this->getMock('\Doctrine\ORM\EntityManager', array('persist', 'flush'), array(), '', false); $emMock = $this->getMock('\Doctrine\ORM\EntityManager', ['persist', 'flush'], [], '', false);
$account = $this->getMock('\Alchemy\Phrasea\Model\Entities\ApiAccount'); $account = $this->getMock('\Alchemy\Phrasea\Model\Entities\ApiAccount');
$manipulator = new ApiLogManipulator($emMock, self::$DI['app']['repo.api-logs']); $manipulator = new ApiLogManipulator($emMock, self::$DI['app']['repo.api-logs']);
$log = $manipulator->create($account, Request::create($path, 'POST'), new Response()); $log = $manipulator->create($account, Request::create($path, 'POST'), new Response());

View File

@@ -2,11 +2,8 @@
namespace Alchemy\Tests\Phrasea\Model\Manipulator; namespace Alchemy\Tests\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Alchemy\Phrasea\Model\Manipulator\ApiOauthCodeManipulator; use Alchemy\Phrasea\Model\Manipulator\ApiOauthCodeManipulator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class ApiOauthCodeManipulatorTest extends \PhraseanetTestCase class ApiOauthCodeManipulatorTest extends \PhraseanetTestCase
{ {

View File

@@ -2,10 +2,7 @@
namespace Alchemy\Tests\Phrasea\Model\Manipulator; namespace Alchemy\Tests\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Model\Manipulator\ApiLogManipulator;
use Alchemy\Phrasea\Model\Manipulator\ApiOauthTokenManipulator; use Alchemy\Phrasea\Model\Manipulator\ApiOauthTokenManipulator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class ApiOauthTokenManipulatorTest extends \PhraseanetTestCase class ApiOauthTokenManipulatorTest extends \PhraseanetTestCase
{ {

View File

@@ -2,9 +2,7 @@
namespace Alchemy\Tests\Phrasea\Model\Manipulator; namespace Alchemy\Tests\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Controller\Api\V1;
use Alchemy\Phrasea\Model\Manipulator\WebhookEventDeliveryManipulator; use Alchemy\Phrasea\Model\Manipulator\WebhookEventDeliveryManipulator;
use Alchemy\Phrasea\Model\Entities\WebhookEventDelivery;
use Alchemy\Phrasea\Model\Manipulator\ApiApplicationManipulator; use Alchemy\Phrasea\Model\Manipulator\ApiApplicationManipulator;
use Alchemy\Phrasea\Model\Entities\ApiApplication; use Alchemy\Phrasea\Model\Entities\ApiApplication;

View File

@@ -3,7 +3,6 @@
namespace Alchemy\Tests\Phrasea\Model\Manipulator; namespace Alchemy\Tests\Phrasea\Model\Manipulator;
use Alchemy\Phrasea\Model\Manipulator\WebhookEventManipulator; use Alchemy\Phrasea\Model\Manipulator\WebhookEventManipulator;
use Alchemy\Phrasea\Model\Entities\WebhookEventDelivery;
use Alchemy\Phrasea\Model\Entities\WebhookEvent; use Alchemy\Phrasea\Model\Entities\WebhookEvent;
class WebhookEventManipulatorTest extends \PhraseanetTestCase class WebhookEventManipulatorTest extends \PhraseanetTestCase
@@ -12,18 +11,18 @@ class WebhookEventManipulatorTest extends \PhraseanetTestCase
{ {
$manipulator = new WebhookEventManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.webhook-delivery']); $manipulator = new WebhookEventManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.webhook-delivery']);
$nbEvents = count(self::$DI['app']['repo.webhook-event']->findAll()); $nbEvents = count(self::$DI['app']['repo.webhook-event']->findAll());
$event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, array( $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, [
'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId()
)); ]);
$this->assertGreaterThan($nbEvents, count(self::$DI['app']['repo.webhook-event']->findAll())); $this->assertGreaterThan($nbEvents, count(self::$DI['app']['repo.webhook-event']->findAll()));
} }
public function testDelete() public function testDelete()
{ {
$manipulator = new WebhookEventManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.webhook-event']); $manipulator = new WebhookEventManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.webhook-event']);
$event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, array( $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, [
'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId()
)); ]);
$countBefore = count(self::$DI['app']['repo.webhook-event']->findAll()); $countBefore = count(self::$DI['app']['repo.webhook-event']->findAll());
$manipulator->delete($event); $manipulator->delete($event);
$this->assertGreaterThan(count(self::$DI['app']['repo.webhook-event']->findAll()), $countBefore); $this->assertGreaterThan(count(self::$DI['app']['repo.webhook-event']->findAll()), $countBefore);
@@ -32,9 +31,9 @@ class WebhookEventManipulatorTest extends \PhraseanetTestCase
public function testUpdate() public function testUpdate()
{ {
$manipulator = new WebhookEventManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.webhook-event']); $manipulator = new WebhookEventManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.webhook-event']);
$event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, array( $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, [
'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId()
)); ]);
$event->setProcessed(true); $event->setProcessed(true);
$manipulator->update($event); $manipulator->update($event);
$event = self::$DI['app']['repo.webhook-event']->find($event->getId()); $event = self::$DI['app']['repo.webhook-event']->find($event->getId());
@@ -44,9 +43,9 @@ class WebhookEventManipulatorTest extends \PhraseanetTestCase
public function testProcessed() public function testProcessed()
{ {
$manipulator = new WebhookEventManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.webhook-event']); $manipulator = new WebhookEventManipulator(self::$DI['app']['EM'], self::$DI['app']['repo.webhook-event']);
$event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, array( $event = $manipulator->create(WebhookEvent::NEW_FEED_ENTRY, WebhookEvent::FEED_ENTRY_TYPE, [
'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId() 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'entry_id' => self::$DI['feed_public_entry']->getId()
)); ]);
$manipulator->processed($event); $manipulator->processed($event);
$this->assertTrue($event->isProcessed()); $this->assertTrue($event->isProcessed());
} }

View File

@@ -2,8 +2,6 @@
namespace Alchemy\Tests\Phrasea\Model\Repositories; namespace Alchemy\Tests\Phrasea\Model\Repositories;
use Alchemy\Phrasea\Model\Entities\ApiApplication;
class ApiOauthCodeRepositoryTest extends \PhraseanetTestCase class ApiOauthCodeRepositoryTest extends \PhraseanetTestCase
{ {
public function testFindByAccount() public function testFindByAccount()

View File

@@ -2,8 +2,6 @@
namespace Alchemy\Tests\Phrasea\Model\Repositories; namespace Alchemy\Tests\Phrasea\Model\Repositories;
use Alchemy\Phrasea\Model\Entities\ApiApplication;
class ApiOauthTokenRepositoryTest extends \PhraseanetTestCase class ApiOauthTokenRepositoryTest extends \PhraseanetTestCase
{ {
public function testFindDeveloperToken() public function testFindDeveloperToken()

View File

@@ -3,7 +3,6 @@
namespace Alchemy\Tests\Phrasea\Notification\Mail; namespace Alchemy\Tests\Phrasea\Notification\Mail;
use Alchemy\Phrasea\Notification\Mail\MailInterface; use Alchemy\Phrasea\Notification\Mail\MailInterface;
use Symfony\Component\Routing\RequestContext;
abstract class MailTestCase extends \PhraseanetTestCase abstract class MailTestCase extends \PhraseanetTestCase
{ {

View File

@@ -735,17 +735,17 @@ abstract class SearchEngineAbstractTest extends \PhraseanetAuthenticatedTestCase
foreach ($foundRecord->get_caption()->get_fields() as $field) { foreach ($foundRecord->get_caption()->get_fields() as $field) {
foreach ($field->get_values() as $metaId => $v) { foreach ($field->get_values() as $metaId => $v) {
$values[$metaId] = array( $values[$metaId] = [
'value' => $v->getValue(), 'value' => $v->getValue(),
'from_thesaurus' => false, 'from_thesaurus' => false,
'qjs' => null, 'qjs' => null,
); ];
} }
$fields[$field->get_name()] = array( $fields[$field->get_name()] = [
'values' => $values, 'values' => $values,
'separator' => ';', 'separator' => ';',
); ];
} }
$found = false; $found = false;

View File

@@ -4,7 +4,7 @@ namespace Alchemy\Tests\Phrasea\TaskManager\Job;
use Alchemy\Phrasea\TaskManager\Job\WebhookJob; use Alchemy\Phrasea\TaskManager\Job\WebhookJob;
class WebhookJobTestJobTest extends JobTestCase class WebhookJobTest extends JobTestCase
{ {
protected function getJob() protected function getJob()
{ {

View File

@@ -30,8 +30,8 @@ class EventProcessorFactoryTest extends \PhraseanetTestCase
public function eventProvider() public function eventProvider()
{ {
return array( return [
array(WebhookEvent::FEED_ENTRY_TYPE, 'Alchemy\Phrasea\Webhook\Processor\FeedEntryProcessor'), [WebhookEvent::FEED_ENTRY_TYPE, 'Alchemy\Phrasea\Webhook\Processor\FeedEntryProcessor'],
); ];
} }
} }

View File

@@ -11,10 +11,10 @@ class FeedEntryProcessorTest extends \PhraseanetTestCase
public function testProcessWithNoFeedId() public function testProcessWithNoFeedId()
{ {
$event = new WebhookEvent(); $event = new WebhookEvent();
$event->setData(array( $event->setData([
'feed_id' => 0, 'feed_id' => 0,
'entry_id' => 0 'entry_id' => 0
)); ]);
$event->setName(WebhookEvent::NEW_FEED_ENTRY); $event->setName(WebhookEvent::NEW_FEED_ENTRY);
$event->setType(WebhookEvent::FEED_ENTRY_TYPE); $event->setType(WebhookEvent::FEED_ENTRY_TYPE);
$processor = new FeedEntryProcessor($event, self::$DI['app']); $processor = new FeedEntryProcessor($event, self::$DI['app']);
@@ -24,23 +24,22 @@ class FeedEntryProcessorTest extends \PhraseanetTestCase
public function testProcessWithMissingDataProperty() public function testProcessWithMissingDataProperty()
{ {
$event = new WebhookEvent(); $event = new WebhookEvent();
$event->setData(array( $event->setData([
'feed_id' => 0, 'feed_id' => 0,
)); ]);
$event->setName(WebhookEvent::NEW_FEED_ENTRY); $event->setName(WebhookEvent::NEW_FEED_ENTRY);
$event->setType(WebhookEvent::FEED_ENTRY_TYPE); $event->setType(WebhookEvent::FEED_ENTRY_TYPE);
$processor = new FeedEntryProcessor($event, self::$DI['app']); $processor = new FeedEntryProcessor($event, self::$DI['app']);
$this->assertEquals($processor->process(), null); $this->assertEquals($processor->process(), null);
} }
public function testProcess() public function testProcess()
{ {
$event = new WebhookEvent(); $event = new WebhookEvent();
$event->setData(array( $event->setData([
'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(), 'feed_id' => self::$DI['feed_public_entry']->getFeed()->getId(),
'entry_id' => self::$DI['feed_public_entry']->getId() 'entry_id' => self::$DI['feed_public_entry']->getId()
)); ]);
$event->setName(WebhookEvent::NEW_FEED_ENTRY); $event->setName(WebhookEvent::NEW_FEED_ENTRY);
$event->setType(WebhookEvent::FEED_ENTRY_TYPE); $event->setType(WebhookEvent::FEED_ENTRY_TYPE);
$processor = new FeedEntryProcessor($event, self::$DI['app']); $processor = new FeedEntryProcessor($event, self::$DI['app']);

View File

@@ -115,6 +115,7 @@ class PhraseanetPHPUnitListener implements PHPUnit_Framework_TestListener
private static function generateName(PHPUnit_Framework_Test $test) private static function generateName(PHPUnit_Framework_Test $test)
{ {
$reflect = new \ReflectionClass($test); $reflect = new \ReflectionClass($test);
return $reflect->getShortName() . '::' . $test->getName(); return $reflect->getShortName() . '::' . $test->getName();
} }
} }