Add getAuthenticator usage

Replace $app['authentication']->getUser() by $app->getAuthenticatedUser()
replace twig app['authentication'].getUser() with corresponding method
This commit is contained in:
Benoît Burnichon
2015-06-30 19:51:02 +02:00
parent 3804eb5408
commit 4880f2bf5a
113 changed files with 437 additions and 428 deletions

View File

@@ -54,7 +54,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
$user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), 'test', 'titi@titi.fr');
self::giveRightsToUser(self::$DI['app'], self::$DI['app']['authentication']->getUser(), [self::$DI['collection']->get_base_id()], true);
self::giveRightsToUser(self::$DI['app'], self::$DI['app']->getAuthenticatedUser(), [self::$DI['collection']->get_base_id()], true);
self::$DI['client']->request('POST', '/admin/users/rights/apply/', [
'users' => $user->getId(),
@@ -435,7 +435,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
{
// create a 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']->getAuthenticatedUser());
self::$DI['app']['acl']->get($user)->update_rights_to_base(self::$DI['collection']->get_base_id(), ['actif'=> 1]);
}

View File

@@ -376,7 +376,7 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
public function testDeleteAccount()
{
$account = \Bridge_Account::create(self::$DI['app'], self::$api, self::$DI['app']['authentication']->getUser(), 'hello', 'you');
$account = \Bridge_Account::create(self::$DI['app'], self::$api, self::$DI['app']->getAuthenticatedUser(), 'hello', 'you');
$url = "/prod/bridge/adapter/" . $account->get_id() . "/delete/";
self::$DI['client']->request('POST', $url);
$response = self::$DI['client']->getResponse();

View File

@@ -46,7 +46,7 @@ class QueryTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['record_2'];
$options = new SearchEngineOptions();
$options->onCollections(self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser())->get_granted_base());
$options->onCollections(self::$DI['app']['acl']->get(self::$DI['app']->getAuthenticatedUser())->get_granted_base());
$serializedOptions = $options->serialize();
self::$DI['client']->request('POST', '/prod/query/answer-train/', [

View File

@@ -122,7 +122,7 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['record_1'];
$options = new SearchEngineOptions();
$acl = self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser());
$acl = self::$DI['app']['acl']->get(self::$DI['app']->getAuthenticatedUser());
$options->onCollections($acl->get_granted_base());
$serializedOptions = $options->serialize();

View File

@@ -17,7 +17,7 @@ class StoryTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
$route = "/prod/story/";
$collections = self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser())
$collections = self::$DI['app']['acl']->get(self::$DI['app']->getAuthenticatedUser())
->get_granted_base(['canaddrecord']);
$collection = array_shift($collections);
@@ -46,7 +46,7 @@ class StoryTest extends \PhraseanetAuthenticatedWebTestCase
{
$route = "/prod/story/";
$collections = self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser())
$collections = self::$DI['app']['acl']->get(self::$DI['app']->getAuthenticatedUser())
->get_granted_base(['canaddrecord']);
$collection = array_shift($collections);

View File

@@ -78,7 +78,7 @@ class RecordsRequestTest extends \PhraseanetAuthenticatedTestCase
public function testSimpleWithoutSbasRights()
{
self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser())
self::$DI['app']['acl']->get(self::$DI['app']->getAuthenticatedUser())
->update_rights_to_sbas(self::$DI['record_2']->get_sbas_id(), ['bas_chupub' => 0]);
$request = new Request([
@@ -104,7 +104,7 @@ class RecordsRequestTest extends \PhraseanetAuthenticatedTestCase
public function testSimpleWithoutBasRights()
{
self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser())
self::$DI['app']['acl']->get(self::$DI['app']->getAuthenticatedUser())
->update_rights_to_base(self::$DI['record_2']->get_base_id(), ['chgstatus' => 0]);
$request = new Request([

View File

@@ -225,7 +225,7 @@ class AccountTest extends \PhraseanetAuthenticatedWebTestCase
public function testPostResetMailBadEmail()
{
$password = self::$DI['app']['random.low']->generateString(8);
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']['authentication']->getUser(), $password);
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']->getAuthenticatedUser(), $password);
self::$DI['client']->request('POST', '/account/reset-email/', [
'form_password' => $password,
'form_email' => "invalid#!&&@@email.x",
@@ -245,7 +245,7 @@ class AccountTest extends \PhraseanetAuthenticatedWebTestCase
public function testPostResetMailEmailNotIdentical()
{
$password = self::$DI['app']['random.low']->generateString(8);
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']['authentication']->getUser(), $password);
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']->getAuthenticatedUser(), $password);
self::$DI['client']->request('POST', '/account/reset-email/', [
'form_password' => $password,
'form_email' => 'email1@email.com',
@@ -268,7 +268,7 @@ class AccountTest extends \PhraseanetAuthenticatedWebTestCase
$password = self::$DI['app']['random.low']->generateString(8);
self::$DI['app']['manipulator.user']->setPassword(
self::$DI['app']['authentication']->getUser(),
self::$DI['app']->getAuthenticatedUser(),
$password
);
self::$DI['client']->request('POST', '/account/reset-email/', [
@@ -368,7 +368,7 @@ class AccountTest extends \PhraseanetAuthenticatedWebTestCase
$this->markTestSkipped('No collections');
}
foreach (self::$DI['app']['events-manager']->list_notifications_available(self::$DI['app']['authentication']->getUser()) as $notifications) {
foreach (self::$DI['app']['events-manager']->list_notifications_available(self::$DI['app']->getAuthenticatedUser()) as $notifications) {
foreach ($notifications as $notification) {
$notifs[] = $notification['id'];
}
@@ -403,10 +403,10 @@ class AccountTest extends \PhraseanetAuthenticatedWebTestCase
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isRedirect());
$this->assertEquals('minet', self::$DI['app']['authentication']->getUser()->getLastName());
$this->assertEquals('minet', self::$DI['app']->getAuthenticatedUser()->getLastName());
$rs = self::$DI['app']['orm.em']->getRepository('Phraseanet:Registration')->findBy([
'user' => self::$DI['app']['authentication']->getUser()->getId(),
'user' => self::$DI['app']->getAuthenticatedUser()->getId(),
'pending' => true
]);
@@ -470,7 +470,7 @@ class AccountTest extends \PhraseanetAuthenticatedWebTestCase
*/
public function testPostRenewPasswordBadArguments($oldPassword, $password, $passwordConfirm)
{
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']['authentication']->getUser(), $oldPassword);
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']->getAuthenticatedUser(), $oldPassword);
$crawler = self::$DI['client']->request('POST', '/account/reset-password/', [
'password' => [
@@ -507,7 +507,7 @@ class AccountTest extends \PhraseanetAuthenticatedWebTestCase
{
$password = self::$DI['app']['random.low']->generateString(8);
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']['authentication']->getUser(), $password);
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']->getAuthenticatedUser(), $password);
$crawler = self::$DI['client']->request('POST', '/account/reset-password/', [
'password' => [
@@ -527,7 +527,7 @@ class AccountTest extends \PhraseanetAuthenticatedWebTestCase
{
$password = self::$DI['app']['random.low']->generateString(8);
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']['authentication']->getUser(), $password);
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']->getAuthenticatedUser(), $password);
self::$DI['client']->request('POST', '/account/reset-password/', [
'password' => [

View File

@@ -1194,10 +1194,10 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
public function testAuthenticate()
{
$password = self::$DI['app']['random.low']->generateString(8);
$login = self::$DI['app']['authentication']->getUser()->getLogin();
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']['authentication']->getUser(), $password);
self::$DI['app']['authentication']->getUser()->setMailLocked(false);
self::$DI['app']['orm.em']->persist(self::$DI['app']['authentication']->getUser());
$login = self::$DI['app']->getAuthenticatedUser()->getLogin();
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']->getAuthenticatedUser(), $password);
self::$DI['app']->getAuthenticatedUser()->setMailLocked(false);
self::$DI['app']['orm.em']->persist(self::$DI['app']->getAuthenticatedUser());
self::$DI['app']['orm.em']->flush();
$this->logout(self::$DI['app']);
@@ -1219,9 +1219,9 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
{
$password = self::$DI['app']['random.low']->generateString(8);
$login = self::$DI['app']['authentication']->getUser()->getLogin();
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']['authentication']->getUser(), $password);
self::$DI['app']['authentication']->getUser()->setMailLocked(false);
$login = self::$DI['app']->getAuthenticatedUser()->getLogin();
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']->getAuthenticatedUser(), $password);
self::$DI['app']->getAuthenticatedUser()->setMailLocked(false);
$this->logout(self::$DI['app']);
@@ -1265,8 +1265,8 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
{
$password = self::$DI['app']['random.low']->generateString(8);
$login = self::$DI['app']['authentication']->getUser()->getLogin();
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']['authentication']->getUser(), $password);
$login = self::$DI['app']->getAuthenticatedUser()->getLogin();
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']->getAuthenticatedUser(), $password);
$this->logout(self::$DI['app']);

View File

@@ -97,7 +97,7 @@ class SessionTest extends \PhraseanetAuthenticatedWebTestCase
$session->expects($this->any())
->method('getUser')
->will($this->returnValue(self::$DI['app']['authentication']->getUser()));
->will($this->returnValue(self::$DI['app']->getAuthenticatedUser()));
$em = $this->createEntityManagerMock();

View File

@@ -71,7 +71,7 @@ class NotificationsTest extends \PhraseanetAuthenticatedWebTestCase
->disableOriginalConstructor()
->getMock());
self::$DI['app']['authentication']->getUser()->expects($this->once())
self::$DI['app']->getAuthenticatedUser()->expects($this->once())
->method('isGuest')
->will($this->returnValue(true));