This commit is contained in:
Nicolas Le Goff
2013-12-24 15:18:34 +01:00
parent 5635553f71
commit 3b0fe2eb75
48 changed files with 66 additions and 96 deletions

View File

@@ -18,7 +18,6 @@ use Browser;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Alchemy\Phrasea\Model\Entities\Session; use Alchemy\Phrasea\Model\Entities\Session;
use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Authenticator class Authenticator
{ {

View File

@@ -152,7 +152,7 @@ class Dashboard implements ControllerProviderInterface
} }
if ($admins > 0) { if ($admins > 0) {
$app['manipulator.user']->promote(array_filter(array_map(function($id) use ($app) { $app['manipulator.user']->promote(array_filter(array_map(function ($id) use ($app) {
return $app['manipulator.user']->getRepository()->find($id); return $app['manipulator.user']->getRepository()->find($id);
}, $admins))); }, $admins)));
$app['manipulator.acl']->resetAdminRights($app['manipulator.user']->getRepository()->findAdmins()); $app['manipulator.acl']->resetAdminRights($app['manipulator.user']->getRepository()->findAdmins());

View File

@@ -12,7 +12,6 @@
namespace Alchemy\Phrasea\Controller\Prod; namespace Alchemy\Phrasea\Controller\Prod;
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions; use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
use Alchemy\Phrasea\Model\Entities\UserQuery;
use Silex\Application; use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;

View File

@@ -91,7 +91,6 @@ class DisplaySettingService
return $user->getSettings()->get($name)->getValue(); return $user->getSettings()->get($name)->getValue();
} }
/** /**
* Return a user notification setting given a user. * Return a user notification setting given a user.
* *
@@ -104,7 +103,6 @@ class DisplaySettingService
public function getUserNotificationSetting(User $user, $name, $default = true) public function getUserNotificationSetting(User $user, $name, $default = true)
{ {
if (false === $user->getNotificationSettings()->containsKey($name)) { if (false === $user->getNotificationSettings()->containsKey($name)) {
return $default; return $default;
} }

View File

@@ -12,7 +12,6 @@
namespace Alchemy\Phrasea\Feed; namespace Alchemy\Phrasea\Feed;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Exception\LogicException; use Alchemy\Phrasea\Exception\LogicException;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Model\Entities; namespace Alchemy\Phrasea\Model\Entities;
use Alchemy\Phrasea\Application;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Model\Entities; namespace Alchemy\Phrasea\Model\Entities;
use Alchemy\Phrasea\Application;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Model\Entities; namespace Alchemy\Phrasea\Model\Entities;
use Alchemy\Phrasea\Application;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Model\Entities; namespace Alchemy\Phrasea\Model\Entities;
use Alchemy\Phrasea\Application;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Model\Entities; namespace Alchemy\Phrasea\Model\Entities;
use Alchemy\Phrasea\Application;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Model\Entities; namespace Alchemy\Phrasea\Model\Entities;
use Alchemy\Phrasea\Application;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Model\Entities; namespace Alchemy\Phrasea\Model\Entities;
use Alchemy\Phrasea\Application;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Model\Entities; namespace Alchemy\Phrasea\Model\Entities;
use Alchemy\Phrasea\Application;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Model\Entities; namespace Alchemy\Phrasea\Model\Entities;
use Alchemy\Phrasea\Application;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**

View File

@@ -46,7 +46,7 @@ class ACLManipulator implements ManipulatorInterface
*/ */
public function resetAdminRights($users) public function resetAdminRights($users)
{ {
foreach($this->makeTraversable($users) as $user) { foreach ($this->makeTraversable($users) as $user) {
$this->doResetAdminRights($user); $this->doResetAdminRights($user);
} }
} }

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Model; namespace Alchemy\Phrasea\Model;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\Query\ResultSetMappingBuilder; use Doctrine\ORM\Query\ResultSetMappingBuilder;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;

View File

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

View File

@@ -11,7 +11,6 @@
namespace Alchemy\Phrasea\Model\Repositories; namespace Alchemy\Phrasea\Model\Repositories;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\UsrList; use Alchemy\Phrasea\Model\Entities\UsrList;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;

View File

@@ -10,7 +10,6 @@
*/ */
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\User;
class patch_381alpha3a implements patchInterface class patch_381alpha3a implements patchInterface
{ {

View File

@@ -244,7 +244,6 @@ class AuthenticatorTest extends \PhraseanetTestCase
$session->set('usr_id', self::$DI['user']->getId()); $session->set('usr_id', self::$DI['user']->getId());
$session->set('session_id', 1); $session->set('session_id', 1);
$authenticator = new Authenticator($app, $browser, $session, $app['EM']); $authenticator = new Authenticator($app, $browser, $session, $app['EM']);
$this->assertTrue($authenticator->isAuthenticated()); $this->assertTrue($authenticator->isAuthenticated());
$this->assertEquals(self::$DI['user'], $authenticator->getUser()); $this->assertEquals(self::$DI['user'], $authenticator->getUser());

View File

@@ -110,7 +110,7 @@ class AdminDashboardTest extends \PhraseanetAuthenticatedWebTestCase
{ {
$this->setAdmin(true); $this->setAdmin(true);
$admins = array_map(function(User $user) { $admins = array_map(function (User $user) {
return $user->getId(); return $user->getId();
}, self::$DI['app']['manipulator.user']->getRepository()->findAdmins()); }, self::$DI['app']['manipulator.user']->getRepository()->findAdmins());

View File

@@ -4,7 +4,6 @@ namespace Alchemy\Tests\Phrasea\Controller\Prod;
use Alchemy\Phrasea\Model\Entities\Order; use Alchemy\Phrasea\Model\Entities\Order;
use Alchemy\Phrasea\Model\Entities\OrderElement; use Alchemy\Phrasea\Model\Entities\OrderElement;
use Alchemy\Phrasea\Application as SilexApplication;
class OrderTest extends \PhraseanetAuthenticatedWebTestCase class OrderTest extends \PhraseanetAuthenticatedWebTestCase
{ {

View File

@@ -214,7 +214,7 @@ class RecordsRequestTest extends \PhraseanetAuthenticatedTestCase
$serialized = $records->serializedList(); $serialized = $records->serializedList();
$exploded = explode(';', $serialized); $exploded = explode(';', $serialized);
$expected = ''; $expected = '';
foreach($story->getRecord(self::$DI['app'])->get_children() as $record) { foreach ($story->getRecord(self::$DI['app'])->get_children() as $record) {
$expected .= $expected === '' ? $record->get_serialize_key() : ';' . $record->get_serialize_key(); $expected .= $expected === '' ? $record->get_serialize_key() : ';' . $record->get_serialize_key();
} }
$this->assertEquals($expected, $serialized); $this->assertEquals($expected, $serialized);

View File

@@ -1800,7 +1800,7 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
self::$termsOfUse[$databox->get_sbas_id()] = $databox->get_cgus(); self::$termsOfUse[$databox->get_sbas_id()] = $databox->get_cgus();
foreach( self::$termsOfUse[$databox->get_sbas_id()]as $lng => $tou) { foreach ( self::$termsOfUse[$databox->get_sbas_id()]as $lng => $tou) {
$databox->update_cgus($lng, '', false); $databox->update_cgus($lng, '', false);
} }
} }
@@ -1814,7 +1814,7 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
self::$termsOfUse[$databox->get_sbas_id()] = $databox->get_cgus(); self::$termsOfUse[$databox->get_sbas_id()] = $databox->get_cgus();
foreach( self::$termsOfUse[$databox->get_sbas_id()]as $lng => $tou) { foreach ( self::$termsOfUse[$databox->get_sbas_id()]as $lng => $tou) {
$databox->update_cgus($lng, 'something', false); $databox->update_cgus($lng, 'something', false);
} }
} }

View File

@@ -2,13 +2,9 @@
namespace Alchemy\Tests\Phrasea\Core\Provider; namespace Alchemy\Tests\Phrasea\Core\Provider;
use Alchemy\Geonames\GeonamesServiceProvider;
use Alchemy\Phrasea\Application as PhraseaApplication;
use Alchemy\Phrasea\Core\Provider\ManipulatorServiceProvider;
use Alchemy\Phrasea\Core\Provider\TokensServiceProvider; use Alchemy\Phrasea\Core\Provider\TokensServiceProvider;
use Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider; use Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider;
use Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider; use Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider;
use Silex\Application;
/** /**
* @covers Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider * @covers Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider
@@ -156,7 +152,7 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase
self::$DI['app']['conf']->set(['authentication', 'auto-create'], ['templates' => [$template1->getId(), $template2->getId()]]); self::$DI['app']['conf']->set(['authentication', 'auto-create'], ['templates' => [$template1->getId(), $template2->getId()]]);
$this->assertEquals([$template1->getLogin(), $template2->getLogin()], array_map(function($u) { $this->assertEquals([$template1->getLogin(), $template2->getLogin()], array_map(function ($u) {
return $u->getLogin(); return $u->getLogin();
}, self::$DI['app']['authentication.providers.account-creator']->getTemplates())); }, self::$DI['app']['authentication.providers.account-creator']->getTemplates()));

View File

@@ -1,8 +1,5 @@
<?php <?php
use Alchemy\Phrasea\Application;
use Doctrine\ORM\UnitOfWork;
class ACLTest extends \PhraseanetAuthenticatedTestCase class ACLTest extends \PhraseanetAuthenticatedTestCase
{ {
/** /**

View File

@@ -1,7 +1,5 @@
<?php <?php
use Alchemy\Phrasea\Application;
require_once __DIR__ . '/Bridge_datas.inc'; require_once __DIR__ . '/Bridge_datas.inc';
class Bridge_AccountTest extends \PhraseanetAuthenticatedTestCase class Bridge_AccountTest extends \PhraseanetAuthenticatedTestCase

View File

@@ -1,7 +1,6 @@
<?php <?php
use Silex\Application; use Silex\Application;
use Symfony\Component\HttpKernel\Client;
use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Crawler;
abstract class PhraseanetAuthenticatedWebTestCase extends \PhraseanetAuthenticatedTestCase abstract class PhraseanetAuthenticatedWebTestCase extends \PhraseanetAuthenticatedTestCase

View File

@@ -289,7 +289,7 @@ abstract class PhraseanetTestCase extends WebTestCase
$app['translator'] = $this->createTranslatorMock(); $app['translator'] = $this->createTranslatorMock();
$app['EM'] = $app->share(function($app) { $app['EM'] = $app->share(function ($app) {
return $app['EM.test']; return $app['EM.test'];
}); });
@@ -305,7 +305,7 @@ abstract class PhraseanetTestCase extends WebTestCase
return $em; return $em;
}); });
$app['EM.prod'] = $app->share(function($app){ $app['EM.prod'] = $app->share(function ($app) {
try { try {
$em = EntityManager::create($app['conf']->get(['main', 'database']), $app['EM.config'], $app['EM.events-manager']); $em = EntityManager::create($app['conf']->get(['main', 'database']), $app['EM.config'], $app['EM.events-manager']);
} catch (\Exception $e) { } catch (\Exception $e) {