Fix test suite

This commit is contained in:
Nicolas Le Goff
2013-11-22 11:16:13 +01:00
parent d18c5afb10
commit ed4ae71819
97 changed files with 979 additions and 1367 deletions

View File

@@ -55,7 +55,7 @@ class NativeAuthentication implements PasswordAuthenticationInterface
// we need a quick update and continue // we need a quick update and continue
if ($this->oldEncoder->isPasswordValid($user->getPassword(), $password, $user->getNonce())) { if ($this->oldEncoder->isPasswordValid($user->getPassword(), $password, $user->getNonce())) {
$user->setSaltedPassword(true); $user->setSaltedPassword(true);
$this->userManipulator->setPassword($user, $user->getPassword()); $this->userManipulator->setPassword($user, $password);
} }
} }

View File

@@ -145,6 +145,11 @@ class RegenerateSqliteDb extends Command
$fs->remove($target); $fs->remove($target);
$fs->dumpFile($json, json_encode($fixtures, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0)); $fs->dumpFile($json, json_encode($fixtures, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
$this->container['manipulator.user']->createUser('test_phpunit', 'test_phpunit', 'noone@example.com', true);
$this->container['manipulator.user']->createUser('test_phpunit_not_admin', 'test_phpunit_not_admin', 'noone_not_admin@example.com');
$this->container['manipulator.user']->createUser('test_phpunit_alt1', 'test_phpunit_alt1', 'noonealt1@example.com');
$this->container['manipulator.user']->createUser('test_phpunit_alt2', 'test_phpunit_alt2', 'noonealt2@example.com');
return 0; return 0;
} }

View File

@@ -365,18 +365,17 @@ class Users implements ControllerProviderInterface
$models = $app['manipulator.user']->getRepository()->findModelOf($app['authentication']->getUser()); $models = $app['manipulator.user']->getRepository()->findModelOf($app['authentication']->getUser());
$rsm = new ResultSetMappingBuilder($app['EM']); $rsm = new ResultSetMappingBuilder($app['EM']);
$rsm->addRootEntityFromClassMetadata('Alchemy\Phrasea\Model\Entities\User', 'u');
$rsm->addScalarResult('date_demand', 'date_demand'); $rsm->addScalarResult('date_demand', 'date_demand');
$rsm->addScalarResult('base_demand', 'base_demand'); $rsm->addScalarResult('base_demand', 'base_demand');
$selectClause = $rsm->generateSelectClause([ $selectClause = $rsm->generateSelectClause();
'u' => 't1'
]);
$query = $app['EM']->createNativeQuery(" $query = $app['EM']->createNativeQuery("
SELECT d.date_modif AS date_demand, d.base_id AS base_demand, " . $selectClause . " SELECT d.date_modif AS date_demand, d.base_id AS base_demand, " . $selectClause . "
FROM (demand d INNER JOIN Users t1 ON d.usr_id=t1.id FROM (demand d INNER JOIN Users u ON d.usr_id=u.id
AND d.en_cours=1 AND d.en_cours=1
AND t1.deleted=0 AND u.deleted=0
) )
WHERE (base_id='" . implode("' OR base_id='", $basList) . "') WHERE (base_id='" . implode("' OR base_id='", $basList) . "')
ORDER BY d.usr_id DESC, d.base_id ASC ORDER BY d.usr_id DESC, d.base_id ASC
@@ -712,19 +711,18 @@ class Users implements ControllerProviderInterface
} }
$rsm = new ResultSetMappingBuilder($app['EM']); $rsm = new ResultSetMappingBuilder($app['EM']);
$rsm->addRootEntityFromClassMetadata('Alchemy\Phrasea\Model\Entities\User', 'u');
$selectClause = $rsm->generateSelectClause([ $selectClause = $rsm->generateSelectClause();
'u' => 't1'
]);
$query = $app['EM']->createNativeQuery(" $query = $app['EM']->createNativeQuery("
SELECT " . $selectClause . " SELECT " . $selectClause . "
FROM Users t1 FROM Users u
INNER JOIN basusr b ON (b.usr_id=t1.id) INNER JOIN basusr b ON (b.usr_id=u.id)
WHERE t1.model_of = :user_id WHERE u.model_of = :user_id
AND b.base_id IN (" . implode(', ', array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['manage']))) . ") AND b.base_id IN (" . implode(', ', array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base(['manage']))) . ")
AND t1.deleted='0' AND u.deleted='0'
GROUP BY t1.id" GROUP BY u.id"
); );
$query->setParameter(':user_id', $app['authentication']->getUser()->getId()); $query->setParameter(':user_id', $app['authentication']->getUser()->getId());
$models = $query->getResult(); $models = $query->getResult();

View File

@@ -49,7 +49,7 @@ class Feed implements ControllerProviderInterface
$app->abort(404, "Feed not found"); $app->abort(404, "Feed not found");
} }
$publisher = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedPublisher')->findOneBy(['feed' => $feed, 'usrId' => $app['authentication']->getUser()->getId()]); $publisher = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\FeedPublisher')->findOneBy(['feed' => $feed, 'user' => $app['authentication']->getUser()->getId()]);
if ('' === $title = trim($request->request->get('title', ''))) { if ('' === $title = trim($request->request->get('title', ''))) {
$app->abort(400, "Bad request"); $app->abort(400, "Bad request");

View File

@@ -278,8 +278,6 @@ class Push implements ControllerProviderInterface
try { try {
$pusher = new RecordHelper\Push($app, $app['request']); $pusher = new RecordHelper\Push($app, $app['request']);
$repository = $app['EM']->getRepository('Phraseanet:Basket');
$validation_name = $request->request->get('name', $app->trans('Validation from %user%', ['%user%' => $app['authentication']->getUser()->getDisplayName()])); $validation_name = $request->request->get('name', $app->trans('Validation from %user%', ['%user%' => $app['authentication']->getUser()->getDisplayName()]));
$validation_description = $request->request->get('validation_description'); $validation_description = $request->request->get('validation_description');
@@ -337,15 +335,15 @@ class Push implements ControllerProviderInterface
} }
$found = false; $found = false;
foreach ($participants as $key => $participant) { foreach ($participants as $participant) {
if ($participant['usr_id'] == $app['authentication']->getUser()->getId()) { if ($participant['usr_id'] === $app['authentication']->getUser()->getId()) {
$found = true; $found = true;
break; break;
} }
} }
if (!$found) { if (!$found) {
$participants[$app['authentication']->getUser()->getId()] = [ $participants[] = [
'see_others' => 1, 'see_others' => 1,
'usr_id' => $app['authentication']->getUser()->getId(), 'usr_id' => $app['authentication']->getUser()->getId(),
'agree' => 0, 'agree' => 0,
@@ -429,7 +427,7 @@ class Push implements ControllerProviderInterface
$params = [ $params = [
'from' => $app['authentication']->getUser()->getId(), 'from' => $app['authentication']->getUser()->getId(),
'from_email' => $app['authentication']->getUser()->getEmail(), 'from_email' => $app['authentication']->getUser()->getEmail(),
'to' => $participant_user->get_id(), 'to' => $participant_user->getId(),
'to_email' => $participant_user->getEmail(), 'to_email' => $participant_user->getEmail(),
'to_name' => $participant_user->getDisplayName(), 'to_name' => $participant_user->getDisplayName(),
'url' => $url, 'url' => $url,

View File

@@ -242,7 +242,6 @@ class RecordsRequest extends ArrayCollection
$to_remove = []; $to_remove = [];
foreach ($elements as $id => $record) { foreach ($elements as $id => $record) {
if (!$app['acl']->get($app['authentication']->getUser())->has_access_to_record($record)) { if (!$app['acl']->get($app['authentication']->getUser())->has_access_to_record($record)) {
$to_remove[] = $id; $to_remove[] = $id;
continue; continue;

View File

@@ -340,7 +340,6 @@ class Login implements ControllerProviderInterface
$inscOK = []; $inscOK = [];
foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) { foreach ($databox->get_collections() as $collection) {
if (null !== $selected && !in_array($collection->get_base_id(), $selected)) { if (null !== $selected && !in_array($collection->get_base_id(), $selected)) {
continue; continue;
@@ -387,6 +386,9 @@ class Login implements ControllerProviderInterface
} }
} }
$app['EM']->persist($user);
$app['EM']->flush();
if (null !== $provider) { if (null !== $provider) {
$this->attachProviderToUser($app['EM'], $provider, $user); $this->attachProviderToUser($app['EM'], $provider, $user);
$app['EM']->flush(); $app['EM']->flush();
@@ -395,14 +397,14 @@ class Login implements ControllerProviderInterface
$demandOK = []; $demandOK = [];
if ($app['conf']->get(['registry', 'registration', 'auto-register-enabled'])) { if ($app['conf']->get(['registry', 'registration', 'auto-register-enabled'])) {
$template_user = $app['manipulator.user']->getRepository()->findByLogin(User::USER_AUTOREGISTER);
$template_user = $app['manipulator.user']->getRepository()->findbyLogin('autoregister');
$base_ids = []; $base_ids = [];
foreach (array_keys($inscOK) as $base_id) { foreach (array_keys($inscOK) as $base_id) {
$base_ids[] = $base_id; $base_ids[] = $base_id;
} }
$app['acl']->get($user)->apply_model($template_user, $base_ids); $app['acl']->get($user)->apply_model($template_user, $base_ids);
} }
@@ -808,7 +810,8 @@ class Login implements ControllerProviderInterface
$context = new Context(Context::CONTEXT_GUEST); $context = new Context(Context::CONTEXT_GUEST);
$app['dispatcher']->dispatch(PhraseaEvents::PRE_AUTHENTICATE, new PreAuthenticate($request, $context)); $app['dispatcher']->dispatch(PhraseaEvents::PRE_AUTHENTICATE, new PreAuthenticate($request, $context));
$invite_user = $app['manipulator.user']->createUser('invite', \random::generatePassword(24)); $user = $app['manipulator.user']->createUser(uniqid('guest'), \random::generatePassword(24));
$invite_user = $app['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST);
$usr_base_ids = array_keys($app['acl']->get($user)->get_granted_base()); $usr_base_ids = array_keys($app['acl']->get($user)->get_granted_base());
$app['acl']->get($user)->revoke_access_from_bases($usr_base_ids); $app['acl']->get($user)->revoke_access_from_bases($usr_base_ids);

View File

@@ -138,6 +138,10 @@ class Session implements ControllerProviderInterface
$app->abort(404, 'Unknown session'); $app->abort(404, 'Unknown session');
} }
if (null === $session->getUser()) {
$app->abort(403, 'Unauthorized');
}
if ($session->getUser()->getId() !== $app['authentication']->getUser()->getId()) { if ($session->getUser()->getId() !== $app['authentication']->getUser()->getId()) {
$app->abort(403, 'Unauthorized'); $app->abort(403, 'Unauthorized');
} }

View File

@@ -768,7 +768,7 @@ class Thesaurus implements ControllerProviderInterface
(Users u INNER JOIN sbasusr (Users u INNER JOIN sbasusr
ON u.id = :usr_id ON u.id = :usr_id
AND u.id = sbasusr.usr_id AND u.id = sbasusr.usr_id
AND u.model_of = 0) AND u.model_of IS NULL)
INNER JOIN INNER JOIN
sbas ON sbas.sbas_id = sbasusr.sbas_id sbas ON sbas.sbas_id = sbasusr.sbas_id
HAVING bas_edit_thesaurus > 0 HAVING bas_edit_thesaurus > 0

View File

@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Core\Provider; namespace Alchemy\Phrasea\Core\Provider;
use Alchemy\Phrasea\Form\Constraint\NewLogin; use Alchemy\Phrasea\Form\Constraint\NewLogin;
use Alchemy\Phrasea\Model\Entities\User;
use Silex\Application; use Silex\Application;
use Silex\ServiceProviderInterface; use Silex\ServiceProviderInterface;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
@@ -56,9 +57,9 @@ class RegistrationServiceProvider implements ServiceProviderInterface
'multiple' => false, 'multiple' => false,
'expanded' => false, 'expanded' => false,
'choices' => [ 'choices' => [
'0' => 'admin::compte-utilisateur:sexe: mademoiselle', User::GENDER_MISS => 'admin::compte-utilisateur:sexe: mademoiselle',
'1' => 'admin::compte-utilisateur:sexe: madame', User::GENDER_MRS => 'admin::compte-utilisateur:sexe: madame',
'2' => 'admin::compte-utilisateur:sexe: monsieur', User::GENDER_MR => 'admin::compte-utilisateur:sexe: monsieur',
] ]
], ],
'firstname' => [ 'firstname' => [

View File

@@ -80,7 +80,7 @@ class Aggregate implements FeedInterface
public static function createFromUser(Application $app, User $user) public static function createFromUser(Application $app, User $user)
{ {
$feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['acl']->get($user)); $feeds = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\Feed')->getAllForUser($app['acl']->get($user));
$token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(['usrId' => $user->getId()]); $token = $app['EM']->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')->findOneBy(['user' => $user->getId()]);
return new static($app['EM'], $feeds, $token); return new static($app['EM'], $feeds, $token);
} }

View File

@@ -132,12 +132,12 @@ class AggregateLinkGenerator implements LinkGeneratorInterface
{ {
$token = $this->em $token = $this->em
->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken') ->getRepository('Alchemy\Phrasea\Model\Entities\AggregateToken')
->findOneBy(['usrId' => $user->getId()]); ->findOneBy(['user' => $user->getId()]);
if (null === $token || true === $renew) { if (null === $token || true === $renew) {
if (null === $token) { if (null === $token) {
$token = new AggregateToken(); $token = new AggregateToken();
$token->setUsrId($user->getId()); $token->setUser($user);
} }
$token->setValue($this->random->generatePassword(12, \random::LETTERS_AND_NUMBERS)); $token->setValue($this->random->generatePassword(12, \random::LETTERS_AND_NUMBERS));

View File

@@ -140,13 +140,13 @@ class FeedLinkGenerator implements LinkGeneratorInterface
{ {
$token = $this->em $token = $this->em
->getRepository('Alchemy\Phrasea\Model\Entities\FeedToken') ->getRepository('Alchemy\Phrasea\Model\Entities\FeedToken')
->findOneBy(['usrId' => $user->getId(), 'feed' => $feed->getId()]); ->findOneBy(['user' => $user->getId(), 'feed' => $feed->getId()]);
if (null === $token || true === $renew) { if (null === $token || true === $renew) {
if (null === $token) { if (null === $token) {
$token = new FeedToken(); $token = new FeedToken();
$token->setFeed($feed); $token->setFeed($feed);
$token->setUsrId($user->getId()); $token->setUser($user);
$feed->addToken($token); $feed->addToken($token);
$this->em->persist($feed); $this->em->persist($feed);

View File

@@ -191,7 +191,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
{ {
$this->base_id = (int) $this->request->get('base_id'); $this->base_id = (int) $this->request->get('base_id');
$sql = "SELECT u.usr_id, restrict_dwnld, remain_dwnld, month_dwnld_max $sql = "SELECT u.id, restrict_dwnld, remain_dwnld, month_dwnld_max
FROM (Users u INNER JOIN basusr bu ON u.id = bu.usr_id) FROM (Users u INNER JOIN basusr bu ON u.id = bu.usr_id)
WHERE (u.id = " . implode(' OR u.id = ', $this->users) . ") WHERE (u.id = " . implode(' OR u.id = ', $this->users) . ")
AND bu.base_id = :base_id"; AND bu.base_id = :base_id";
@@ -314,7 +314,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
{ {
$this->base_id = (int) $this->request->get('base_id'); $this->base_id = (int) $this->request->get('base_id');
$sql = "SELECT u.usr_id, time_limited, limited_from, limited_to $sql = "SELECT u.id, time_limited, limited_from, limited_to
FROM (Users u INNER JOIN basusr bu ON u.id = bu.usr_id) FROM (Users u INNER JOIN basusr bu ON u.id = bu.usr_id)
WHERE (u.id = " . implode(' OR u.id = ', $this->users) . ") WHERE (u.id = " . implode(' OR u.id = ', $this->users) . ")
AND bu.base_id = :base_id"; AND bu.base_id = :base_id";
@@ -368,7 +368,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
{ {
$sbas_id = (int) $this->request->get('sbas_id'); $sbas_id = (int) $this->request->get('sbas_id');
$sql = "SELECT u.usr_id, time_limited, limited_from, limited_to $sql = "SELECT u.id, time_limited, limited_from, limited_to
FROM (Users u FROM (Users u
INNER JOIN basusr bu ON u.id = bu.usr_id INNER JOIN basusr bu ON u.id = bu.usr_id
INNER JOIN bas b ON b.base_id = bu.base_id) INNER JOIN bas b ON b.base_id = bu.base_id)
@@ -588,7 +588,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
, 'fax' , 'fax'
]; ];
$parm = $this->unserializedRequestData($this->app['request'], $infos, 'user_infos'); $parm = $this->unserializedRequestData($this->request, $infos, 'user_infos');
if ($parm['email'] && !\Swift_Validate::email($parm['email'])) { if ($parm['email'] && !\Swift_Validate::email($parm['email'])) {
throw new \Exception_InvalidArgument('Email addess is not valid'); throw new \Exception_InvalidArgument('Email addess is not valid');
@@ -644,7 +644,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
{ {
$template = $this->app['manipulator.user']->getRepository()->find($this->request->get('template')); $template = $this->app['manipulator.user']->getRepository()->find($this->request->get('template'));
if ($template->getLastModel()->getId() !== $this->app['authentication']->getUser()->getId()) { if (null === $template->getModelOf() || $template->getModelOf()->getId() !== $this->app['authentication']->getUser()->getId()) {
throw new AccessDeniedHttpException('You are not the owner of the template'); throw new AccessDeniedHttpException('You are not the owner of the template');
} }
@@ -736,7 +736,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
if ($user->isTemplate()) { if ($user->isTemplate()) {
$template = $user; $template = $user;
if ($template->getLastModel()->getId() !== $this->app['authentication']->getUser()->getId()) { if (null === $template->getModelOf() || $template->getModelOf()->getId() !== $this->app['authentication']->getUser()->getId()) {
continue; continue;
} }
} }
@@ -758,7 +758,13 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
private function unserializedRequestData(Request $request, array $indexes, $requestIndex) private function unserializedRequestData(Request $request, array $indexes, $requestIndex)
{ {
$parameters = $data = []; $parameters = $data = [];
parse_str($request->get($requestIndex), $data); $requestValue = $request->get($requestIndex);
if (is_array($requestValue)) {
$data = $requestValue;
} else {
parse_str($requestValue, $data);
}
if (count($data) > 0) { if (count($data) > 0) {
foreach ($indexes as $index) { foreach ($indexes as $index) {

View File

@@ -112,11 +112,11 @@ class Manage extends Helper
->execute(); ->execute();
if (null === $invite = $this->app['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST)) { if (null === $invite = $this->app['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST)) {
$this->app['manipulator.user']->createUser(User::USER_GUEST, User::USER_GUEST); $invite = $this->app['manipulator.user']->createUser(User::USER_GUEST, User::USER_GUEST);
} }
if (null == $autoregister = $this->app['manipulator.user']->getRepository()->findByLogin(User::USER_AUTOREGISTER)) { if (null == $autoregister = $this->app['manipulator.user']->getRepository()->findByLogin(User::USER_AUTOREGISTER)) {
$this->app['manipulator.user']->createUser(User::USER_AUTOREGISTER, User::USER_AUTOREGISTER); $autoregister = $this->app['manipulator.user']->createUser(User::USER_AUTOREGISTER, User::USER_AUTOREGISTER);
} }
foreach ($this->query_parms as $k => $v) { foreach ($this->query_parms as $k => $v) {
@@ -198,7 +198,7 @@ class Manage extends Helper
} }
$created_user = $this->app['manipulator.user']->getRepository()->find($name, \random::generatePassword(16)); $created_user = $this->app['manipulator.user']->getRepository()->find($name, \random::generatePassword(16));
$created_user->setModel($this->app['authentication']->getUser()); $created_user->setModelOf($this->app['authentication']->getUser());
$this->usr_id = $this->app['authentication']->getUser()->getId(); $this->usr_id = $this->app['authentication']->getUser()->getId();
return $created_user; return $created_user;

View File

@@ -234,7 +234,7 @@ class Basket
public function getPusher(Application $app) public function getPusher(Application $app)
{ {
if ($this->getPusherId()) { if ($this->getPusherId()) {
return $this->pusher; return $this->pusher = $app['EM']->find('Alchemy\Phrasea\Model\Entities\User', $this->getPusherId());
} }
} }

View File

@@ -225,7 +225,7 @@ class User
private $updated; private $updated;
/** /**
* @ORM\OneToOne(targetEntity="User") * @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="model_of", referencedColumnName="id") * @ORM\JoinColumn(name="model_of", referencedColumnName="id")
* *
* @var User * @var User

View File

@@ -239,7 +239,7 @@ class UsrList
/** /**
* Return true if one of the entry is related to the given user * Return true if one of the entry is related to the given user
* *
* @param \User_Adapter $user * @param User $user
* @return boolean * @return boolean
*/ */
public function has(User $user, Application $app) public function has(User $user, Application $app)

View File

@@ -159,6 +159,21 @@ class UserManager
} }
} }
/**
* Removes user providers.
*
* @param User $user
*/
private function cleanAuthProvider(User $user)
{
$providers = $this->objectManager->getRepository('Alchemy\Phrasea\Model\Entities\UsrAuthProvider')
->findBy(['user' => $user->getId()]);
foreach ($providers as $provider) {
$this->objectManager->remove($provider);
}
}
/** /**
* Removes all user's properties. * Removes all user's properties.
* *
@@ -180,6 +195,7 @@ class UserManager
$this->cleanFtpCredentials($user); $this->cleanFtpCredentials($user);
$this->cleanOrders($user); $this->cleanOrders($user);
$this->cleanFtpExports($user); $this->cleanFtpExports($user);
$this->cleanAuthProvider($user);
} }
/** /**

View File

@@ -207,7 +207,7 @@ class UserManipulator implements ManipulatorInterface
$notifSetting = new UserNotificationSetting(); $notifSetting = new UserNotificationSetting();
$notifSetting->setName($name); $notifSetting->setName($name);
$notifSetting->setValue($value); $notifSetting->setValue($value);
$notifSetting->setUsrId($user); $notifSetting->setUser($user);
$user->addNotificationSettings($notifSetting); $user->addNotificationSettings($notifSetting);
$this->manager->update($user); $this->manager->update($user);

View File

@@ -33,7 +33,7 @@ class BasketElementRepository extends EntityRepository
LEFT JOIN e.validation_datas vd LEFT JOIN e.validation_datas vd
LEFT JOIN b.validation s LEFT JOIN b.validation s
LEFT JOIN s.participants p LEFT JOIN s.participants p
WHERE (b.usr_id = :usr_id OR p.usr_id = :same_usr_id) WHERE (b.user = :usr_id OR p.user = :same_usr_id)
AND e.id = :element_id'; AND e.id = :element_id';
$params = [ $params = [
@@ -108,7 +108,7 @@ class BasketElementRepository extends EntityRepository
JOIN e.basket b JOIN e.basket b
LEFT JOIN b.validation s LEFT JOIN b.validation s
LEFT JOIN s.participants p LEFT JOIN s.participants p
WHERE b.usr_id = :usr_id WHERE b.user = :usr_id
AND b.pusher_id IS NOT NULL AND b.pusher_id IS NOT NULL
AND e.record_id = :record_id AND e.record_id = :record_id
AND e.sbas_id = :sbas_id'; AND e.sbas_id = :sbas_id';
@@ -132,7 +132,7 @@ class BasketElementRepository extends EntityRepository
JOIN e.basket b JOIN e.basket b
JOIN b.validation v JOIN b.validation v
JOIN v.participants p JOIN v.participants p
WHERE p.usr_id = :usr_id WHERE p.user = :usr_id
AND e.record_id = :record_id AND e.record_id = :record_id
AND e.sbas_id = :sbas_id'; AND e.sbas_id = :sbas_id';

View File

@@ -36,7 +36,7 @@ class BasketRepository extends EntityRepository
$dql = 'SELECT b $dql = 'SELECT b
FROM Phraseanet:Basket b FROM Phraseanet:Basket b
LEFT JOIN b.elements e LEFT JOIN b.elements e
WHERE b.usr_id = :usr_id WHERE b.user = :usr_id
AND b.archived = false'; AND b.archived = false';
if ($sort == 'date') { if ($sort == 'date') {
@@ -66,9 +66,9 @@ class BasketRepository extends EntityRepository
LEFT JOIN s.participants p LEFT JOIN s.participants p
WHERE b.archived = false WHERE b.archived = false
AND ( AND (
(b.usr_id = :usr_id_owner AND b.is_read = false) (b.user = :usr_id_owner AND b.is_read = false)
OR (b.usr_id != :usr_id_ownertwo OR (b.user != :usr_id_ownertwo
AND p.usr_id = :usr_id_participant AND p.user = :usr_id_participant
AND p.is_aware = false) AND p.is_aware = false)
) )
AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP())'; AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP())';
@@ -100,7 +100,7 @@ class BasketRepository extends EntityRepository
JOIN e.validation_datas v JOIN e.validation_datas v
JOIN b.validation s JOIN b.validation s
JOIN s.participants p JOIN s.participants p
WHERE b.usr_id != ?1 AND p.usr_id = ?2 WHERE b.user != ?1 AND p.user = ?2
AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP()) '; AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP()) ';
if ($sort == 'date') { if ($sort == 'date') {
@@ -167,7 +167,7 @@ class BasketRepository extends EntityRepository
FROM Phraseanet:Basket b FROM Phraseanet:Basket b
JOIN b.elements e JOIN b.elements e
WHERE e.record_id = :record_id AND e.sbas_id = e.sbas_id WHERE e.record_id = :record_id AND e.sbas_id = e.sbas_id
AND b.usr_id = :usr_id'; AND b.user = :usr_id';
$params = [ $params = [
'record_id' => $record->get_record_id(), 'record_id' => $record->get_record_id(),
@@ -189,7 +189,7 @@ class BasketRepository extends EntityRepository
$dql = 'SELECT b $dql = 'SELECT b
FROM Phraseanet:Basket b FROM Phraseanet:Basket b
JOIN b.elements e JOIN b.elements e
WHERE b.usr_id = :usr_id AND b.pusher_id IS NOT NULL'; WHERE b.user = :usr_id AND b.pusher_id IS NOT NULL';
$params = [ $params = [
'usr_id' => $user->getId() 'usr_id' => $user->getId()
]; ];
@@ -200,7 +200,7 @@ class BasketRepository extends EntityRepository
JOIN b.elements e JOIN b.elements e
JOIN b.validation s JOIN b.validation s
JOIN s.participants p JOIN s.participants p
WHERE b.usr_id != ?1 AND p.usr_id = ?2'; WHERE b.user != ?1 AND p.user = ?2';
$params = [ $params = [
1 => $user->getId() 1 => $user->getId()
, 2 => $user->getId() , 2 => $user->getId()
@@ -211,7 +211,7 @@ class BasketRepository extends EntityRepository
FROM Phraseanet:Basket b FROM Phraseanet:Basket b
JOIN b.elements e JOIN b.elements e
JOIN b.validation v JOIN b.validation v
WHERE b.usr_id = :usr_id'; WHERE b.user = :usr_id';
$params = [ $params = [
'usr_id' => $user->getId() 'usr_id' => $user->getId()
]; ];
@@ -222,7 +222,7 @@ class BasketRepository extends EntityRepository
LEFT JOIN b.elements e LEFT JOIN b.elements e
LEFT JOIN b.validation s LEFT JOIN b.validation s
LEFT JOIN s.participants p LEFT JOIN s.participants p
WHERE (b.usr_id = :usr_id OR p.usr_id = :validating_usr_id)'; WHERE (b.user = :usr_id OR p.user = :validating_usr_id)';
$params = [ $params = [
'usr_id' => $user->getId(), 'usr_id' => $user->getId(),
'validating_usr_id' => $user->getId() 'validating_usr_id' => $user->getId()
@@ -234,7 +234,7 @@ class BasketRepository extends EntityRepository
LEFT JOIN b.elements e LEFT JOIN b.elements e
LEFT JOIN b.validation s LEFT JOIN b.validation s
LEFT JOIN s.participants p LEFT JOIN s.participants p
WHERE (b.usr_id = :usr_id)'; WHERE (b.user = :usr_id)';
$params = [ $params = [
'usr_id' => $user->getId() 'usr_id' => $user->getId()
]; ];
@@ -281,8 +281,8 @@ class BasketRepository extends EntityRepository
LEFT JOIN b.elements e LEFT JOIN b.elements e
LEFT JOIN b.validation s LEFT JOIN b.validation s
LEFT JOIN s.participants p LEFT JOIN s.participants p
WHERE (b.usr_id = :usr_id AND b.archived = false) WHERE (b.user = :usr_id AND b.archived = false)
OR (b.usr_id != :usr_id AND p.usr_id = :usr_id OR (b.user != :usr_id AND p.user = :usr_id
AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP()) AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP())
)'; )';

View File

@@ -69,6 +69,6 @@ class FtpExportRepository extends EntityRepository
*/ */
public function findByUser(User $user) public function findByUser(User $user)
{ {
return $this->findBy(['usrId' => $user->getId()]); return $this->findBy(['user' => $user->getId()]);
} }
} }

View File

@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Model\Repositories;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NoResultException;
/** /**
* OrderRepository * OrderRepository
@@ -31,7 +32,7 @@ class OrderRepository extends EntityRepository
*/ */
public function findByUser(User $user) public function findByUser(User $user)
{ {
return $this->findBy(['usrId' => $user->getId()]); return $this->findBy(['user' => $user->getId()]);
} }
/** /**
@@ -89,6 +90,10 @@ class OrderRepository extends EntityRepository
$qb->groupBy('o.id'); $qb->groupBy('o.id');
return $qb->getQuery()->getSingleScalarResult(); try {
return $qb->getQuery()->getSingleScalarResult();
} catch (NoResultException $e) {
return 0;
}
} }
} }

View File

@@ -28,7 +28,7 @@ class StoryWZRepository extends EntityRepository
public function findByUser(Application $app, User $user, $sort) public function findByUser(Application $app, User $user, $sort)
{ {
$dql = 'SELECT s FROM Phraseanet:StoryWZ s WHERE s.usr_id = :usr_id '; $dql = 'SELECT s FROM Alchemy\Phrasea\Model\Entities\StoryWZ s WHERE s.user = :usr_id ';
if ($sort == 'date') { if ($sort == 'date') {
$dql .= ' ORDER BY s.created DESC'; $dql .= ' ORDER BY s.created DESC';
@@ -98,7 +98,7 @@ class StoryWZRepository extends EntityRepository
{ {
$story = $this->findOneBy( $story = $this->findOneBy(
[ [
'usr_id' => $user->getId(), 'user' => $user->getId(),
'sbas_id' => $Story->get_sbas_id(), 'sbas_id' => $Story->get_sbas_id(),
'record_id' => $Story->get_record_id(), 'record_id' => $Story->get_record_id(),
] ]

View File

@@ -81,7 +81,7 @@ class UserRepository extends EntityRepository
$qb->where($qb->expr()->eq('u.login', $qb->expr()->literal($login))) $qb->where($qb->expr()->eq('u.login', $qb->expr()->literal($login)))
->andWhere($qb->expr()->isNotNull('u.email')) ->andWhere($qb->expr()->isNotNull('u.email'))
->andWhere($qb->expr()->eq('u.modelOf', $qb->expr()->literal('0'))) ->andWhere($qb->expr()->isNull('u.modelOf'))
->andWhere($qb->expr()->eq('u.guest', $qb->expr()->literal('0'))) ->andWhere($qb->expr()->eq('u.guest', $qb->expr()->literal('0')))
->andWhere($qb->expr()->eq('u.deleted', $qb->expr()->literal(false))); ->andWhere($qb->expr()->eq('u.deleted', $qb->expr()->literal(false)));

View File

@@ -25,8 +25,8 @@ class UsrAuthProviderRepository extends EntityRepository
public function findByUser(User $user) public function findByUser(User $user)
{ {
$dql = 'SELECT u $dql = 'SELECT u
FROM Phraseanet:UsrAuthProvider u FROM Alchemy\Phrasea\Model\Entities\UsrAuthProvider u
WHERE u.usr_id = :usrId'; WHERE u.user = :usrId';
$params = ['usrId' => $user->getId()]; $params = ['usrId' => $user->getId()];

View File

@@ -35,8 +35,8 @@ class UsrListEntryRepository extends EntityRepository
*/ */
public function findUserList(User $user) public function findUserList(User $user)
{ {
$dql = 'SELECT e FROM Phraseanet:UsrListEntry e $dql = 'SELECT e FROM Alchemy\Phrasea\Model\Entities\UsrListEntry e
WHERE e.usr_id = :usr_id'; WHERE e.user = :usr_id';
$params = [ $params = [
'usr_id' => $user->getId(), 'usr_id' => $user->getId(),
@@ -68,7 +68,7 @@ class UsrListEntryRepository extends EntityRepository
{ {
$dql = 'SELECT e FROM Phraseanet:UsrListEntry e $dql = 'SELECT e FROM Phraseanet:UsrListEntry e
JOIN e.list l JOIN e.list l
WHERE e.usr_id = :usr_id AND l.id = :list_id'; WHERE e.user = :usr_id AND l.id = :list_id';
$params = [ $params = [
'usr_id' => $usr_id, 'usr_id' => $usr_id,

View File

@@ -60,7 +60,7 @@ class UsrListOwnerRepository extends EntityRepository
{ {
$dql = 'SELECT o FROM Phraseanet:UsrListOwner o $dql = 'SELECT o FROM Phraseanet:UsrListOwner o
JOIN o.list l JOIN o.list l
WHERE l.id = :list_id AND o.usr_id = :usr_id'; WHERE l.id = :list_id AND o.user = :usr_id';
$params = [ $params = [
'usr_id' => $usr_id, 'usr_id' => $usr_id,

View File

@@ -37,7 +37,7 @@ class UsrListRepository extends EntityRepository
{ {
$dql = 'SELECT l FROM Phraseanet:UsrList l $dql = 'SELECT l FROM Phraseanet:UsrList l
JOIN l.owners o JOIN l.owners o
WHERE o.usr_id = :usr_id'; WHERE o.user = :usr_id';
$params = [ $params = [
'usr_id' => $user->getId(), 'usr_id' => $user->getId(),
@@ -82,7 +82,7 @@ class UsrListRepository extends EntityRepository
{ {
$dql = 'SELECT l FROM Phraseanet:UsrList l $dql = 'SELECT l FROM Phraseanet:UsrList l
JOIN l.owners o JOIN l.owners o
WHERE o.usr_id = :usr_id AND l.name LIKE :name'; WHERE o.user = :usr_id AND l.name LIKE :name';
$params = [ $params = [
'usr_id' => $user->getId(), 'usr_id' => $user->getId(),

View File

@@ -107,6 +107,12 @@ class Installer
return $user; return $user;
} }
private function createDefaultUsers()
{
$this->app['manipulator.user']->createUser(User::USER_AUTOREGISTER, User::USER_AUTOREGISTER);
$this->app['manipulator.user']->createUser(User::USER_GUEST, User::USER_GUEST);
}
private function rollbackInstall(\connection_interface $abConn, \connection_interface $dbConn = null) private function rollbackInstall(\connection_interface $abConn, \connection_interface $dbConn = null)
{ {
$structure = simplexml_load_file(__DIR__ . "/../../../conf.d/bases_structure.xml"); $structure = simplexml_load_file(__DIR__ . "/../../../conf.d/bases_structure.xml");
@@ -148,8 +154,6 @@ class Installer
private function createAB() private function createAB()
{ {
$this->app['phraseanet.appbox']->insert_datas();
$metadatas = $this->app['EM']->getMetadataFactory()->getAllMetadata(); $metadatas = $this->app['EM']->getMetadataFactory()->getAllMetadata();
if (!empty($metadatas)) { if (!empty($metadatas)) {
@@ -159,6 +163,8 @@ class Installer
$tool->dropSchema($metadatas); $tool->dropSchema($metadatas);
$tool->createSchema($metadatas); $tool->createSchema($metadatas);
} }
$this->app['phraseanet.appbox']->insert_datas($this->app);
} }
private function createConfigFile($abConn, $serverName, $binaryData) private function createConfigFile($abConn, $serverName, $binaryData)

View File

@@ -94,6 +94,10 @@ class UserProvider implements ControlProviderInterface
{ {
$user = $this->app['manipulator.user']->getRepository()->find($id); $user = $this->app['manipulator.user']->getRepository()->find($id);
if (null === $user) {
throw new \Exception('User unknown');
}
return $user->getDisplayName(); return $user->getDisplayName();
} }

View File

@@ -234,11 +234,11 @@ class User_Query implements User_QueryInterface
} }
$sql .= ' AND model_of = ' . $this->app['authentication']->getUser()->getId(); $sql .= ' AND model_of = ' . $this->app['authentication']->getUser()->getId();
} elseif ($this->include_templates === false) { } elseif ($this->include_templates === false) {
$sql .= ' AND model_of=0'; $sql .= ' AND model_of IS NULL';
} elseif ($this->app['authentication']->getUser()) { } elseif ($this->app['authentication']->getUser()) {
$sql .= ' AND (model_of=0 OR model_of = ' . $this->app['authentication']->getUser()->getId() . ' ) '; $sql .= ' AND (model_of IS NULL OR model_of = ' . $this->app['authentication']->getUser()->getId() . ' ) ';
} else { } else {
$sql .= ' AND model_of=0'; $sql .= ' AND model_of IS NULL';
} }
if ($this->activities) { if ($this->activities) {
@@ -512,7 +512,7 @@ class User_Query implements User_QueryInterface
$users = new ArrayCollection(); $users = new ArrayCollection();
foreach ($rs as $row) { foreach ($rs as $row) {
$users[] = $this->app['manipulator.user']->getRepository()->find($row['usr_id']); $users[] = $this->app['manipulator.user']->getRepository()->find($row['id']);
} }
$this->results = $users; $this->results = $users;

View File

@@ -12,6 +12,7 @@
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Version as PhraseaVersion; use Alchemy\Phrasea\Core\Version as PhraseaVersion;
use vierbergenlars\SemVer\version; use vierbergenlars\SemVer\version;
use Alchemy\Phrasea\Model\Entities\User;
abstract class base implements cache_cacheableInterface abstract class base implements cache_cacheableInterface
{ {
@@ -834,14 +835,11 @@ abstract class base implements cache_cacheableInterface
$version = $app['doctrine-migration.configuration']->getVersion($doctrineVersion); $version = $app['doctrine-migration.configuration']->getVersion($doctrineVersion);
$version->getMigration()->setEntityManager($app['EM']); $version->getMigration()->setEntityManager($app['EM']);
if (false === $version->isMigrated()) { if (false === $version->isMigrated()) {
echo "Before executing Patch ".$patch->get_release()." \n";
echo "Executing migration ".$version->getversion()." \n";
$version->execute('up'); $version->execute('up');
} }
} }
if (false === $patch->apply($this, $app)) { if (false === $patch->apply($this, $app)) {
echo "Executing Patch ".$patch->get_release()." \n";
$success = false; $success = false;
} }

View File

@@ -30,10 +30,10 @@ function giveMeBases(Application $app, $usr = null)
AND bas.base_id = basusr.base_id ) AND bas.base_id = basusr.base_id )
LEFT JOIN demand ON ( demand.usr_id = u.id LEFT JOIN demand ON ( demand.usr_id = u.id
AND bas.base_id = demand.base_id ) AND bas.base_id = demand.base_id )
WHERE bas.active >0 WHERE bas.active > 0
AND bas.sbas_id = sbas.sbas_id AND bas.sbas_id = sbas.sbas_id
AND u.id = :usr_id AND u.id = :usr_id
AND u.model_of = 0 AND u.model_of IS NULL
'; ';
$stmt = $conn->prepare($sqlU); $stmt = $conn->prepare($sqlU);

View File

@@ -12,6 +12,7 @@
use Alchemy\Phrasea\Notification\Receiver; use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Notification\Mail\MailInfoSomebodyAutoregistered; use Alchemy\Phrasea\Notification\Mail\MailInfoSomebodyAutoregistered;
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
{ {
@@ -39,11 +40,7 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
*/ */
public function fire($event, $params, &$object) public function fire($event, $params, &$object)
{ {
$default = [ $default = [ 'usr_id' => '' , 'autoregister' => []];
'usr_id' => ''
, 'autoregister' => []
];
$params = array_merge($default, $params); $params = array_merge($default, $params);
$base_ids = array_keys($params['autoregister']); $base_ids = array_keys($params['autoregister']);
@@ -54,19 +51,18 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
$mailColl = []; $mailColl = [];
$rsm = new ResultSetMappingBuilder($this->app['EM']); $rsm = new ResultSetMappingBuilder($this->app['EM']);
$rsm->addRootEntityFromClassMetadata('Alchemy\Phrasea\Model\Entities\User', 'u');
$rsm->addScalarResult('base_id', 'base_id'); $rsm->addScalarResult('base_id', 'base_id');
$selectClause = $rsm->generateSelectClause([ $selectClause = $rsm->generateSelectClause();
'u' => 't1'
]);
$query = $this->app['EM']->createNativeQuery(' $query = $this->app['EM']->createNativeQuery('
SELECT b.base_id, '.$selectClause.' FROM Users u, basusr b SELECT b.base_id, '.$selectClause.' FROM Users u, basusr b
WHERE u.id = b.usr_id WHERE u.id = b.usr_id
AND b.base_id IN (' . implode(', ', array_keys($base_ids)) . ') AND b.base_id IN (' . implode(', ', array_keys($base_ids)) . ')
AND u.model_of="0" AND u.model_of IS NULL
AND b.actif="1" AND b.actif="1"
AND b.canadmin="1" AND b.canadmin="1"
AND u.deleted="0"' AND u.deleted="0"', $rsm
); );
try { try {
@@ -82,7 +78,6 @@ class eventsmanager_notify_autoregister extends eventsmanager_notifyAbstract
$mailColl[$user->getId()][] = $row['base_id']; $mailColl[$user->getId()][] = $row['base_id'];
} }
} catch (Exception $e) { } catch (Exception $e) {
} }
$dom_xml = new DOMDocument('1.0', 'UTF-8'); $dom_xml = new DOMDocument('1.0', 'UTF-8');

View File

@@ -108,7 +108,7 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
if ($readyToSend) { if ($readyToSend) {
$url = $this->app->url('lightbox_compare', [ $url = $this->app->url('lightbox_compare', [
'ssel_id' => $basket->getId(), 'basket' => $basket->getId(),
'LOG' => $this->app['tokens']->getUrlToken( 'LOG' => $this->app['tokens']->getUrlToken(
\random::TYPE_VIEW, \random::TYPE_VIEW,
$user_to->getId(), $user_to->getId(),

View File

@@ -54,25 +54,22 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
$mailColl = []; $mailColl = [];
$rsm = new ResultSetMappingBuilder($this->app['EM']); $rsm = new ResultSetMappingBuilder($this->app['EM']);
$rsm->addRootEntityFromClassMetadata('Alchemy\Phrasea\Model\Entities\User', 'u');
$rsm->addScalarResult('base_id', 'base_id'); $rsm->addScalarResult('base_id', 'base_id');
$selectClause = $rsm->generateSelectClause([ $selectClause = $rsm->generateSelectClause();
'u' => 't1'
]);
$query = $this->app['EM']->createNativeQuery(' $query = $this->app['EM']->createNativeQuery('
SELECT b.base_id, '.$selectClause.' FROM Users u, basusr b SELECT b.base_id, '.$selectClause.' FROM Users u, basusr b
WHERE u.id = b.usr_id WHERE u.id = b.usr_id
AND b.base_id IN (' . implode(', ', array_keys($base_ids)) . ') AND b.base_id IN (' . implode(', ', array_keys($base_ids)) . ')
AND u.model_of="0" AND u.model_of IS NULL
AND b.actif="1" AND b.actif="1"
AND b.canadmin="1" AND b.canadmin="1"
AND u.deleted="0"' AND u.deleted="0"',
); $rsm);
try { try {
$rs = $query->getResult(); foreach ($query->getResult() as $row) {
foreach ($rs as $row) {
$user = $row[0]; $user = $row[0];
if (!isset($mailColl[$user->getId()])) { if (!isset($mailColl[$user->getId()])) {
@@ -82,7 +79,6 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
$mailColl[$user->getId()][] = $row['base_id']; $mailColl[$user->getId()][] = $row['base_id'];
} }
} catch (Exception $e) { } catch (Exception $e) {
} }
$dom_xml = new DOMDocument('1.0', 'UTF-8'); $dom_xml = new DOMDocument('1.0', 'UTF-8');

View File

@@ -151,7 +151,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
} }
$bask_link = '<a href="' $bask_link = '<a href="'
. $this->app->url('lightbox_validation', ['ssel_id' => (string) $sx->ssel_id]) . $this->app->url('lightbox_validation', ['basket' => (string) $sx->ssel_id])
. '" target="_blank">' . '" target="_blank">'
. $basket_name . '</a>'; . $basket_name . '</a>';

View File

@@ -62,13 +62,11 @@ class module_console_systemUpgrade extends Command
try { try {
$upgrader = new Setup_Upgrade($this->container, $input->getOption('force')); $upgrader = new Setup_Upgrade($this->container, $input->getOption('force'));
$queries = $this->getService('phraseanet.appbox')->forceUpgrade($upgrader, $this->container);
} catch (\Exception_Setup_FixBadEmailAddresses $e) { } catch (\Exception_Setup_FixBadEmailAddresses $e) {
return $output->writeln(sprintf('<error>You have to fix your database before upgrade with the system:mailCheck command </error>')); return $output->writeln(sprintf('<error>You have to fix your database before upgrade with the system:mailCheck command </error>'));
} catch (\Exception $e) {
echo $e->getTraceAsString() . "\n";
} }
$queries = $this->getService('phraseanet.appbox')->forceUpgrade($upgrader, $this->container);
if ($input->getOption('dump') || $input->getOption('stderr')) { if ($input->getOption('dump') || $input->getOption('stderr')) {
if (0 < count($queries)) { if (0 < count($queries)) {

View File

@@ -60,7 +60,7 @@ class patch_381alpha3a implements patchInterface
$propSql = $propArgs = []; $propSql = $propArgs = [];
$n = 0; $n = 0;
foreach (User::$defaultUserSettings as $prop => $value) { foreach ($app['settings']->getUsersSettings() as $prop => $value) {
if ('start_page_query' === $prop) { if ('start_page_query' === $prop) {
continue; continue;
} }

View File

@@ -189,8 +189,8 @@ class queries
$history = '<ul>'; $history = '<ul>';
$queries = $app['EM'] $queries = $app['EM']
->getRepository('Phraseanet:UserQuery') ->getRepository('Alchemy\Phrasea\Model\Entities\UserQuery')
->findBy(['usrId' => $usrId], ['created' => 'ASC'], 25, 0); ->findBy(['user' => $usrId], ['created' => 'ASC'], 25, 0);
foreach ($queries as $query) { foreach ($queries as $query) {
$history .= '<li onclick="doSpecialSearch(\'' . str_replace(["'", '"'], ["\'", '&quot;'], $query->getQuery()) . '\')">' . $query->getQuery() . '</li>'; $history .= '<li onclick="doSpecialSearch(\'' . str_replace(["'", '"'], ["\'", '&quot;'], $query->getQuery()) . '\')">' . $query->getQuery() . '</li>';

View File

@@ -1681,7 +1681,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
':site' => $this->app['conf']->get(['main', 'key']), ':site' => $this->app['conf']->get(['main', 'key']),
':usr_id' => $this->app['authentication']->getUser()->getId(), ':usr_id' => $this->app['authentication']->getUser()->getId(),
':record_id' => $this->get_record_id(), ':record_id' => $this->get_record_id(),
); ];
} else { } else {
$sql = 'SELECT record_id $sql = 'SELECT record_id
FROM regroup g FROM regroup g
@@ -1728,11 +1728,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface
ON (g.rid_parent = r.record_id) ON (g.rid_parent = r.record_id)
WHERE rid_child = :record_id'; WHERE rid_child = :record_id';
$params = [ $params = array(
':GV_site' => $this->app['conf']->get(['main', 'key']) ':GV_site' => $this->app['conf']->get(['main', 'key'])
, ':usr_id' => $this->app['authentication']->getUser()->get_id() , ':usr_id' => $this->app['authentication']->getUser()->get_id()
, ':record_id' => $this->get_record_id() , ':record_id' => $this->get_record_id()
); ];
$stmt = $this->get_databox()->get_connection()->prepare($sql); $stmt = $this->get_databox()->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);

View File

@@ -230,7 +230,7 @@ class set_export extends set_abstract
$lst_base_id = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base()); $lst_base_id = array_keys($app['acl']->get($app['authentication']->getUser())->get_granted_base());
if ($hasadminright) { if ($hasadminright) {
$sql = "SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.mail AS usr_mail, FtpCredential.* $sql = "SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.email AS usr_mail, FtpCredential.*
FROM ( FROM (
FtpCredential INNER JOIN Users ON ( FtpCredential INNER JOIN Users ON (
FtpCredential.active = 1 AND FtpCredential.user_id = Users.id FtpCredential.active = 1 AND FtpCredential.user_id = Users.id
@@ -244,7 +244,7 @@ class set_export extends set_abstract
GROUP BY Users.id "; GROUP BY Users.id ";
$params = []; $params = [];
} elseif ($this->app['conf']->get(['registry', 'ftp', 'ftp-user-access'])) { } elseif ($this->app['conf']->get(['registry', 'ftp', 'ftp-user-access'])) {
$sql = "SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.mail AS usr_mail, FtpCredential.* $sql = "SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.email AS usr_mail, FtpCredential.*
FROM ( FROM (
FtpCredential INNER JOIN Users ON ( FtpCredential INNER JOIN Users ON (
FtpCredential.active = 1 AND FtpCredential.id = Users.id FtpCredential.active = 1 AND FtpCredential.id = Users.id

View File

@@ -1,45 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhraseaFixture;
use Doctrine\Common\DataFixtures\AbstractFixture;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
abstract class AbstractWZ extends AbstractFixture
{
protected $user;
protected $record;
public function getUser()
{
return $this->user;
}
public function setUser(\User_Adapter $user)
{
$this->user = $user;
}
public function getRecord()
{
return $this->record;
}
public function setRecord(\record_adapter $record)
{
$this->record = $record;
}
}

View File

@@ -172,7 +172,7 @@
</div> </div>
{% endif %} {% endif %}
{% if table['user'] | length > 0 %} {% if table['users'] | length > 0 %}
<form id="accept-demand" action="{{ path('users_submit_demands') }}" method="post"> <form id="accept-demand" action="{{ path('users_submit_demands') }}" method="post">
<div class="btn-group btn-all-action"> <div class="btn-group btn-all-action">
<button data-event="deny" class="btn deny-checker" type="button"> <button data-event="deny" class="btn deny-checker" type="button">

View File

@@ -147,9 +147,11 @@
<td> <td>
{{usr.getCountry()}} {{usr.getCountry()}}
</td> </td>
<td> {% if usr.getLastModel() is not none %}
{{usr.getLastModel()->getDisplayName()}} <td>
</td> {{ usr.getLastModel().getDisplayName()}}
</td>
{% endif %}
<td> <td>
{{ app['date-formatter'].getDate(usr.getCreated()) }} {{ app['date-formatter'].getDate(usr.getCreated()) }}
</td> </td>

View File

@@ -326,7 +326,7 @@
<div class="control-group"> <div class="control-group">
<label class="control-label" for="usr_mail"> {{ 'admin::compte-utilisateur email' | trans }}</label> <label class="control-label" for="usr_mail"> {{ 'admin::compte-utilisateur email' | trans }}</label>
<div class="controls"> <div class="controls">
<input class="required" type="text" name="usr_mail" id="usr_mail" value="{{ app['authentication'].getUser().ggetEmail) }}"/> <input class="required" type="text" name="usr_mail" id="usr_mail" value="{{ app['authentication'].getUser().getEmail() }}"/>
</div> </div>
</div> </div>

View File

@@ -33,7 +33,7 @@
<input type="hidden" name="usr_id" value="{{ owner.getUser().getId() }}" /> <input type="hidden" name="usr_id" value="{{ owner.getUser().getId() }}" />
</td> </td>
<td style="padding-right:10px;min-width:100px;"> <td style="padding-right:10px;min-width:100px;">
{% if app['authentication'].getUser().ggetId()== owner.getUser().gegetId()} {% if app['authentication'].getUser().getId() == owner.getUser().getId() %}
{% if owner.getRole() == constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_ADMIN') %} {% if owner.getRole() == constant('Alchemy\\Phrasea\\Model\\Entities\\UsrListOwner::ROLE_ADMIN') %}
{{ 'You are Admin' | trans }} {{ 'You are Admin' | trans }}
{% endif %} {% endif %}
@@ -53,7 +53,7 @@
{% endif %} {% endif %}
</td> </td>
<td style="width:15px"> <td style="width:15px">
{% if app['authentication'].getUser().getgetId() owner.getUser().getId() %} {% if app['authentication'].getUser().getId() == owner.getUser().getId() %}
<a href="#" class="deleter"> <a href="#" class="deleter">
<img src="/skins/prod/Push/close_badge.png" title="{{ 'Remove' | trans }}"/> <img src="/skins/prod/Push/close_badge.png" title="{{ 'Remove' | trans }}"/>
</a> </a>

View File

@@ -63,18 +63,14 @@ class AccountCreatorTest extends \PhraseanetTestCase
public function testCreateWithTemplates() public function testCreateWithTemplates()
{ {
$random = self::$DI['app']['tokens']; $template1 = self::$DI['app']['manipulator.user']->createTemplate('template1', self::$DI['user']);
$template1 = self::$DI['app']['manipulator.user']->createUser('template' . $random->generatePassword(), $random->generatePassword()); $template2 = self::$DI['app']['manipulator.user']->createTemplate('template2', self::$DI['user']);
$template1->setModel(self::$DI['user']); $template3 = self::$DI['app']['manipulator.user']->createTemplate('template3', self::$DI['user']);
$template2 = self::$DI['app']['manipulator.user']->createUser('template' . $random->generatePassword(), $random->generatePassword());
$template2->setModel(self::$DI['user']);
$template3 = self::$DI['app']['manipulator.user']->createUser('template' . $random->generatePassword(), $random->generatePassword());
$template3->setModel(self::$DI['user']);
$templates = [$template1, $template2]; $templates = [$template1, $template2];
$extra = [$template3]; $extra = [$template3];
$creator = new AccountCreator($random, self::$DI['app']['phraseanet.appbox'], true, $templates); $creator = new AccountCreator(self::$DI['app']['tokens'], self::$DI['app']['phraseanet.appbox'], true, $templates);
$user = $creator->create(self::$DI['app'], self::$DI['app']['tokens']->generatePassword(), null, $extra); $user = $creator->create(self::$DI['app'], self::$DI['app']['tokens']->generatePassword(), null, $extra);
$this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $user); $this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $user);

View File

@@ -15,11 +15,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
{ {
$app = $this->loadApp(); $app = $this->loadApp();
$app['browser'] = $browser = $this->getBrowserMock(); $authenticator = new Authenticator(self::$DI['app'], $browser, $session, $em);
$app['session'] = $session = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock();
$authenticator = new Authenticator($app, $browser, $session, $em);
$this->assertNull($authenticator->getUser()); $this->assertNull($authenticator->getUser());
} }
/** /**
@@ -31,19 +27,19 @@ class AuthenticatorTest extends \PhraseanetTestCase
$user = self::$DI['user']; $user = self::$DI['user'];
$app['browser'] = $browser = $this->getBrowserMock(); self::$DI['app']['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $session = $this->getSessionMock(); self::$DI['app']['session'] = $session = $this->getSessionMock();
$sessionEntity = new Session(); $sessionEntity = new Session();
$sessionEntity->setUser($user); $sessionEntity->setUser($user);
$sessionEntity->setUserAgent(''); $sessionEntity->setUserAgent('');
$app['EM']->persist($sessionEntity); self::$DI['app']['EM']->persist($sessionEntity);
$app['EM']->flush(); self::$DI['app']['EM']->flush();
$session->set('usr_id', $user->getId()); $session->set('usr_id', $user->getId());
$session->set('session_id', $sessionEntity->getId()); $session->set('session_id', $sessionEntity->getId());
$authenticator = new Authenticator($app, $browser, $session, $app['EM']); $authenticator = new Authenticator(self::$DI['app'], $browser, $session, self::$DI['app']['EM']);
$this->assertEquals($user, $authenticator->getUser()); $this->assertEquals($user, $authenticator->getUser());
} }
@@ -54,15 +50,11 @@ class AuthenticatorTest extends \PhraseanetTestCase
{ {
$app = $this->loadApp(); $app = $this->loadApp();
$app['browser'] = $browser = $this->getBrowserMock(); $user = $this->getMockBuilder('Alchemy\Phrasea\Model\Entities\User')
$app['session'] = $session = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock();
$user = $this->getMockBuilder('')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$authenticator = new Authenticator($app, $browser, $session, $em); $authenticator = new Authenticator(self::$DI['app'], $browser, $session, $em);
$authenticator->setUser($user); $authenticator->setUser($user);
$this->assertEquals($user, $authenticator->getUser()); $this->assertEquals($user, $authenticator->getUser());
$authenticator->setUser(null); $authenticator->setUser(null);
@@ -77,9 +69,9 @@ class AuthenticatorTest extends \PhraseanetTestCase
$app = $this->loadApp(); $app = $this->loadApp();
$capturedSession = null; $capturedSession = null;
$app['browser'] = $browser = $this->getBrowserMock(); self::$DI['app']['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $session = $this->getSessionMock(); self::$DI['app']['session'] = $session = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock(); self::$DI['app']['EM'] = $em = $this->getEntityManagerMock();
$user = $this->getMockBuilder('Alchemy\Phrasea\Model\Entities\User') $user = $this->getMockBuilder('Alchemy\Phrasea\Model\Entities\User')
->disableOriginalConstructor() ->disableOriginalConstructor()
@@ -102,7 +94,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
->method('get') ->method('get')
->will($this->returnValue($acl)); ->will($this->returnValue($acl));
$app['acl'] = $aclProvider; self::$DI['app']['acl'] = $aclProvider;
$em->expects($this->at(0)) $em->expects($this->at(0))
->method('persist') ->method('persist')
@@ -113,7 +105,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
$em->expects($this->at(1)) $em->expects($this->at(1))
->method('flush'); ->method('flush');
$authenticator = new Authenticator($app, $browser, $session, $em); $authenticator = new Authenticator(self::$DI['app'], $browser, $session, $em);
$phsession = $authenticator->openAccount($user); $phsession = $authenticator->openAccount($user);
$this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\Session', $phsession); $this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\Session', $phsession);
@@ -129,9 +121,9 @@ class AuthenticatorTest extends \PhraseanetTestCase
$user = self::$DI['user']; $user = self::$DI['user'];
$app['browser'] = $browser = $this->getBrowserMock(); self::$DI['app']['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $SFsession = $this->getSessionMock(); self::$DI['app']['session'] = $SFsession = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock(); self::$DI['app']['EM'] = $em = $this->getEntityManagerMock();
$sessionId = 4224242; $sessionId = 4224242;
@@ -157,7 +149,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
->with($this->equalTo('Phraseanet:Session')) ->with($this->equalTo('Phraseanet:Session'))
->will($this->returnValue($repo)); ->will($this->returnValue($repo));
$authenticator = new Authenticator($app, $browser, $SFsession, $em); $authenticator = new Authenticator(self::$DI['app'], $browser, $SFsession, $em);
$this->assertEquals($session, $authenticator->refreshAccount($session)); $this->assertEquals($session, $authenticator->refreshAccount($session));
} }
@@ -170,9 +162,9 @@ class AuthenticatorTest extends \PhraseanetTestCase
$user = self::$DI['user']; $user = self::$DI['user'];
$app['browser'] = $browser = $this->getBrowserMock(); self::$DI['app']['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $SFsession = $this->getSessionMock(); self::$DI['app']['session'] = $SFsession = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock(); self::$DI['app']['EM'] = $em = $this->getEntityManagerMock();
$sessionId = 4224242; $sessionId = 4224242;
@@ -198,7 +190,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
->with($this->equalTo('Phraseanet:Session')) ->with($this->equalTo('Phraseanet:Session'))
->will($this->returnValue($repo)); ->will($this->returnValue($repo));
$authenticator = new Authenticator($app, $browser, $SFsession, $em); $authenticator = new Authenticator(self::$DI['app'], $browser, $SFsession, $em);
try { try {
$authenticator->refreshAccount($session); $authenticator->refreshAccount($session);
$this->fail('Should have raised an exception'); $this->fail('Should have raised an exception');
@@ -240,19 +232,19 @@ class AuthenticatorTest extends \PhraseanetTestCase
$user = self::$DI['user']; $user = self::$DI['user'];
$app['browser'] = $browser = $this->getBrowserMock(); self::$DI['app']['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $session = $this->getSessionMock(); self::$DI['app']['session'] = $session = $this->getSessionMock();
$sessionEntity = new Session(); $sessionEntity = new Session();
$sessionEntity->setUser($user); $sessionEntity->setUser($user);
$sessionEntity->setUserAgent(''); $sessionEntity->setUserAgent('');
$app['EM']->persist($sessionEntity); self::$DI['app']['EM']->persist($sessionEntity);
$app['EM']->flush(); self::$DI['app']['EM']->flush();
$session->set('usr_id', $user->getId()); $session->set('usr_id', $user->getId());
$session->set('session_id', $sessionEntity->getId()); $session->set('session_id', $sessionEntity->getId());
$authenticator = new Authenticator($app, $browser, $session, $app['EM']); $authenticator = new Authenticator(self::$DI['app'], $browser, $session, self::$DI['app']['EM']);
$this->assertTrue($authenticator->isAuthenticated()); $this->assertTrue($authenticator->isAuthenticated());
} }
@@ -263,11 +255,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
{ {
$app = $this->loadApp(); $app = $this->loadApp();
$app['browser'] = $browser = $this->getBrowserMock(); $authenticator = new Authenticator(self::$DI['app'], $browser, $session, $em);
$app['session'] = $session = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock();
$authenticator = new Authenticator($app, $browser, $session, $em);
$this->assertFalse($authenticator->isAuthenticated()); $this->assertFalse($authenticator->isAuthenticated());
} }

View File

@@ -4,67 +4,51 @@ namespace Alchemy\Tests\Phrasea\Authentication\Phrasea;
use Alchemy\Phrasea\Authentication\Phrasea\NativeAuthentication; use Alchemy\Phrasea\Authentication\Phrasea\NativeAuthentication;
use Alchemy\Phrasea\Authentication\Exception\AccountLockedException; use Alchemy\Phrasea\Authentication\Exception\AccountLockedException;
use Alchemy\Phrasea\Model\Entities\User;
class NativeAuthenticationTest extends \PhraseanetTestCase class NativeAuthenticationTest extends \PhraseanetTestCase
{ {
/** public function testAuthenticationSpecialUser()
* @dataProvider provideReservedUsernames
*/
public function testReservedAreValid($username)
{ {
$password = 'popo42';
$encoder = $this->getEncoderMock(); $encoder = $this->getEncoderMock();
$oldEncoder = $this->getOldEncoderMock(); $oldEncoder = $this->getOldEncoderMock();
$conn = $this->getMock('connection_interface');
$request = $this->getRequestMock(); $request = $this->getRequestMock();
$auth = new NativeAuthentication($encoder, $oldEncoder, $conn); $specialUser = $this->getMock('Alchemy\Phrasea\Model\Entities\User');
$this->assertNull($auth->getUsrId($username, $password, $request)); $specialUser->expects($this->any())->method('isSpecial')->will($this->returnValue(true));
}
public function provideReservedUsernames() $manipulator = $this->getUserManipulatorMock($specialUser);
{
return [ $auth = new NativeAuthentication($encoder, $oldEncoder, $manipulator);
['autoregister'], $this->assertNull($auth->getUsrId('a_login', 'a_password', $request));
['invite'],
];
} }
public function testNotFoundIsNotValid() public function testNotFoundIsNotValid()
{ {
$username = 'romainneutron';
$password = 'popo42';
$encoder = $this->getEncoderMock(); $encoder = $this->getEncoderMock();
$oldEncoder = $this->getOldEncoderMock(); $oldEncoder = $this->getOldEncoderMock();
$conn = $this->getConnectionMock($username, null);
$request = $this->getRequestMock(); $request = $this->getRequestMock();
$manipulator = $this->getUserManipulatorMock(null);
$auth = new NativeAuthentication($encoder, $oldEncoder, $conn); $auth = new NativeAuthentication($encoder, $oldEncoder, $manipulator);
$this->assertNull($auth->getUsrId($username, $password, $request)); $this->assertNull($auth->getUsrId('a_login', 'a_password', $request));
} }
public function testLockAccountThrowsAnException() public function testLockAccountThrowsAnException()
{ {
$username = 'romainneutron';
$password = 'popo42';
$encoder = $this->getEncoderMock(); $encoder = $this->getEncoderMock();
$oldEncoder = $this->getOldEncoderMock(); $oldEncoder = $this->getOldEncoderMock();
$conn = $this->getConnectionMock($username, [
'nonce' => 'dfqsdgqsd',
'salted_password' => '1',
'mail_locked' => '1',
'usr_id' => '1',
'usr_password' => 'qsdfsqdfqsd',
]);
$request = $this->getRequestMock(); $request = $this->getRequestMock();
$auth = new NativeAuthentication($encoder, $oldEncoder, $conn); $mailLockedUser = $this->getMock('Alchemy\Phrasea\Model\Entities\User');
$mailLockedUser->expects($this->any())->method('isMailLocked')->will($this->returnValue(true));
$manipulator = $this->getUserManipulatorMock($mailLockedUser);
$auth = new NativeAuthentication($encoder, $oldEncoder, $manipulator);
try { try {
$auth->getUsrId($username, $password, $request); $auth->getUsrId('a_login', 'a_password', $request);
$this->fail('Should have raised an exception'); $this->fail('Should have raised an exception');
} catch (AccountLockedException $e) { } catch (AccountLockedException $e) {
@@ -73,23 +57,26 @@ class NativeAuthenticationTest extends \PhraseanetTestCase
public function testGetUsrIdWithCorrectCredentials() public function testGetUsrIdWithCorrectCredentials()
{ {
$username = 'romainneutron';
$password = 'popo42'; $password = 'popo42';
$encoded = 'qsdfsqdfqsd'; $encoded = 'qsdfsqdfqsd';
$nonce = 'dfqsdgqsd'; $nonce = 'dfqsdgqsd';
$usr_id = '42'; $userId = 42;
$encoder = $this->getEncoderMock(); $encoder = $this->getEncoderMock();
$oldEncoder = $this->getOldEncoderMock(); $oldEncoder = $this->getOldEncoderMock();
$conn = $this->getConnectionMock($username, [
'nonce' => $nonce,
'salted_password' => '1',
'mail_locked' => '0',
'usr_id' => $usr_id,
'usr_password' => $encoded,
]);
$request = $this->getRequestMock(); $request = $this->getRequestMock();
$user = $this->getMock('Alchemy\Phrasea\Model\Entities\User');
$user->expects($this->any())->method('getId')->will($this->returnValue($userId));
$user->expects($this->any())->method('isSpecial')->will($this->returnValue(false));
$user->expects($this->any())->method('isMailLocked')->will($this->returnValue(false));
$user->expects($this->any())->method('isSaltedPassword')->will($this->returnValue(true));
$user->expects($this->any())->method('getPassword')->will($this->returnValue($encoded));
$user->expects($this->any())->method('getNonce')->will($this->returnValue($nonce));
$manipulator = $this->getUserManipulatorMock($user);
$oldEncoder->expects($this->never()) $oldEncoder->expects($this->never())
->method('isPasswordValid'); ->method('isPasswordValid');
@@ -98,30 +85,33 @@ class NativeAuthenticationTest extends \PhraseanetTestCase
->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce)) ->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce))
->will($this->returnValue(true)); ->will($this->returnValue(true));
$auth = new NativeAuthentication($encoder, $oldEncoder, $conn); $auth = new NativeAuthentication($encoder, $oldEncoder, $manipulator);
$this->assertEquals($usr_id, $auth->getUsrId($username, $password, $request)); $this->assertEquals($userId, $auth->getUsrId('a_login', $password, $request));
} }
public function testIsNotValidWithIncorrectCredentials() public function testIsNotValidWithIncorrectCredentials()
{ {
$username = 'romainneutron';
$password = 'popo42'; $password = 'popo42';
$encoded = 'qsdfsqdfqsd'; $encoded = 'qsdfsqdfqsd';
$nonce = 'dfqsdgqsd'; $nonce = 'dfqsdgqsd';
$usr_id = '42'; $userId = 42;
$encoder = $this->getEncoderMock(); $encoder = $this->getEncoderMock();
$oldEncoder = $this->getOldEncoderMock(); $oldEncoder = $this->getOldEncoderMock();
$conn = $this->getConnectionMock($username, [
'nonce' => $nonce,
'salted_password' => '1',
'mail_locked' => '0',
'usr_id' => $usr_id,
'usr_password' => $encoded,
]);
$request = $this->getRequestMock(); $request = $this->getRequestMock();
$user = $this->getMock('Alchemy\Phrasea\Model\Entities\User');
$user->expects($this->any())->method('getId')->will($this->returnValue($userId));
$user->expects($this->any())->method('isSpecial')->will($this->returnValue(false));
$user->expects($this->any())->method('isMailLocked')->will($this->returnValue(false));
$user->expects($this->any())->method('isSaltedPassword')->will($this->returnValue(true));
$user->expects($this->any())->method('getPassword')->will($this->returnValue($encoded));
$user->expects($this->any())->method('getNonce')->will($this->returnValue($nonce));
$manipulator = $this->getUserManipulatorMock($user);
$oldEncoder->expects($this->never()) $oldEncoder->expects($this->never())
->method('isPasswordValid'); ->method('isPasswordValid');
@@ -130,30 +120,33 @@ class NativeAuthenticationTest extends \PhraseanetTestCase
->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce)) ->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce))
->will($this->returnValue(false)); ->will($this->returnValue(false));
$auth = new NativeAuthentication($encoder, $oldEncoder, $conn); $auth = new NativeAuthentication($encoder, $oldEncoder, $manipulator);
$this->assertEquals(false, $auth->getUsrId($username, $password, $request)); $this->assertEquals(false, $auth->getUsrId('a_login', $password, $request));
} }
public function testIsNotValidWithIncorrectOldCredentials() public function testIsNotValidWithIncorrectOldCredentials()
{ {
$username = 'romainneutron';
$password = 'popo42'; $password = 'popo42';
$encoded = 'qsdfsqdfqsd'; $encoded = 'qsdfsqdfqsd';
$nonce = 'dfqsdgqsd'; $nonce = 'dfqsdgqsd';
$usr_id = '42'; $userId = 42;
$encoder = $this->getEncoderMock(); $encoder = $this->getEncoderMock();
$oldEncoder = $this->getOldEncoderMock(); $oldEncoder = $this->getOldEncoderMock();
$conn = $this->getConnectionMock($username, [
'nonce' => $nonce,
'salted_password' => '0',
'mail_locked' => '0',
'usr_id' => $usr_id,
'usr_password' => $encoded,
]);
$request = $this->getRequestMock(); $request = $this->getRequestMock();
$user = $this->getMock('Alchemy\Phrasea\Model\Entities\User');
$user->expects($this->any())->method('getId')->will($this->returnValue($userId));
$user->expects($this->any())->method('isSpecial')->will($this->returnValue(false));
$user->expects($this->any())->method('isMailLocked')->will($this->returnValue(false));
$user->expects($this->any())->method('isSaltedPassword')->will($this->returnValue(false));
$user->expects($this->any())->method('getPassword')->will($this->returnValue($encoded));
$user->expects($this->any())->method('getNonce')->will($this->returnValue($nonce));
$manipulator = $this->getUserManipulatorMock($user);
$oldEncoder->expects($this->once()) $oldEncoder->expects($this->once())
->method('isPasswordValid') ->method('isPasswordValid')
->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce)) ->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce))
@@ -164,62 +157,36 @@ class NativeAuthenticationTest extends \PhraseanetTestCase
->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce)) ->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce))
->will($this->returnValue(false)); ->will($this->returnValue(false));
$auth = new NativeAuthentication($encoder, $oldEncoder, $conn); $auth = new NativeAuthentication($encoder, $oldEncoder, $manipulator);
$this->assertEquals(false, $auth->getUsrId($username, $password, $request)); $this->assertEquals(false, $auth->getUsrId('a_login', $password, $request));
} }
public function testGetUsrIdWithCorrectOldCredentials() public function testGetUsrIdWithCorrectOldCredentials()
{ {
$username = 'romainneutron';
$password = 'popo42'; $password = 'popo42';
$encoded = 'qsdfsqdfqsd'; $encoded = 'qsdfsqdfqsd';
$nonce = 'dfqsdgqsd'; $nonce = 'dfqsdgqsd';
$usr_id = '42'; $userId = 42;
$encoder = $this->getEncoderMock(); $encoder = $this->getEncoderMock();
$oldEncoder = $this->getOldEncoderMock(); $oldEncoder = $this->getOldEncoderMock();
$conn = $this->getMock('connection_interface');
$statement = $this->getMock('PDOStatement');
$statement
->expects($this->once())
->method('execute')
->with($this->equalTo([':login' => $username]));
$statement->expects($this->once())
->method('fetch')
->with($this->equalTo(\PDO::FETCH_ASSOC))
->will($this->returnValue([
'nonce' => $nonce,
'salted_password' => '0',
'mail_locked' => '0',
'usr_id' => $usr_id,
'usr_password' => $encoded,
]));
$catchParameters = $catchTestPassword = null;
$statement2 = $this->getMock('PDOStatement');
$statement2
->expects($this->once())
->method('execute')
->will($this->returnCallback(function ($parameters) use (&$catchParameters) {
$catchParameters = $parameters;
}));
$conn->expects($this->at(0))
->method('prepare')
->with($this->isType('string'))
->will($this->returnValue($statement));
$conn->expects($this->at(1))
->method('prepare')
->with($this->isType('string'))
->will($this->returnValue($statement2));
$request = $this->getRequestMock(); $request = $this->getRequestMock();
$user = $this->getMock('Alchemy\Phrasea\Model\Entities\User');
$user->expects($this->any())->method('getId')->will($this->returnValue($userId));
$user->expects($this->any())->method('isSpecial')->will($this->returnValue(false));
$user->expects($this->any())->method('isMailLocked')->will($this->returnValue(false));
$user->expects($this->any())->method('isSaltedPassword')->will($this->returnValue(false));
$user->expects($this->any())->method('getPassword')->will($this->returnValue($encoded));
$user->expects($this->any())->method('getNonce')->will($this->returnValue($nonce));
$user->expects($this->once())->method('setSaltedPassword')->with($this->equalTo(true));
$manipulator = $this->getUserManipulatorMock($user);
$manipulator->expects($this->once())->method('setPassword')->with($this->equalTo($user), $this->equalTo($password));
$oldEncoder->expects($this->once()) $oldEncoder->expects($this->once())
->method('isPasswordValid') ->method('isPasswordValid')
->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce)) ->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce))
@@ -237,37 +204,8 @@ class NativeAuthenticationTest extends \PhraseanetTestCase
return true; return true;
})); }));
$auth = new NativeAuthentication($encoder, $oldEncoder, $conn); $auth = new NativeAuthentication($encoder, $oldEncoder, $manipulator);
$this->assertEquals($usr_id, $auth->getUsrId($username, $password, $request)); $this->assertEquals($userId, $auth->getUsrId('a_login', $password, $request));
$this->assertEquals($catchParameters[':password'], $catchTestPassword['encoded']);
$this->assertEquals($password, $catchTestPassword['pass']);
$this->assertEquals($catchParameters[':nonce'], $catchTestPassword['nonce']);
$this->assertEquals($usr_id, $catchParameters[':usr_id']);
}
private function getConnectionMock($username, $row = null)
{
$conn = $this->getMock('connection_interface');
$statement = $this->getMock('PDOStatement');
$statement
->expects($this->once())
->method('execute')
->with($this->equalTo([':login' => $username]));
$statement->expects($this->once())
->method('fetch')
->with($this->equalTo(\PDO::FETCH_ASSOC))
->will($this->returnValue($row));
$conn->expects($this->once())
->method('prepare')
->with($this->isType('string'))
->will($this->returnValue($statement));
return $conn;
} }
private function getEncoderMock() private function getEncoderMock()
@@ -297,4 +235,15 @@ class NativeAuthenticationTest extends \PhraseanetTestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
} }
private function getUserManipulatorMock(User $user = null)
{
$repoMock = $this->getMockBuilder('Alchemy\Phrasea\Model\Repositories\UserRepository')->disableOriginalConstructor()->getMock();
$repoMock->expects($this->any())->method('findRealUserByLogin')->will($this->returnValue($user));
$manipulator = $this->getMockBuilder('Alchemy\Phrasea\Model\Manipulator\UserManipulator')->disableOriginalConstructor()->getMock();
$manipulator->expects($this->any())->method('getRepository')->will($this->returnValue($repoMock));
return $manipulator;
}
} }

View File

@@ -16,10 +16,15 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['app'] = $this->loadApp(); self::$DI['app'] = $this->loadApp();
self::dropDatabase(); self::dropDatabase();
parent::setUp(); parent::setUp();
self::dropDatabase();
} }
public static function tearDownAfterClass() public function tearDown()
{ {
if (!self::$createdCollections) {
return;
}
foreach (self::$createdCollections as $collection) { foreach (self::$createdCollections as $collection) {
try { try {
$collection->unmount_collection(self::$DI['app']); $collection->unmount_collection(self::$DI['app']);
@@ -35,15 +40,6 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
} }
self::$createdCollections = null; self::$createdCollections = null;
self::dropDatabase();
parent::tearDownAfterClass();
}
public function tearDown()
{
self::dropDatabase();
parent::tearDown();
} }
public function getJson($response) public function getJson($response)

View File

@@ -37,8 +37,8 @@ class SearchEngineTest extends \PhraseanetAuthenticatedWebTestCase
$app = $this->loadApp(); $app = $this->loadApp();
return [ return [
[new PhraseaEngine($app)], [new PhraseaEngine(new Application('test'))],
[new SphinxSearchEngine($app, 'localhost', 9306, 'localhost', 9308)], [new SphinxSearchEngine(new Application('test'), 'localhost', 9306, 'localhost', 9308)],
]; ];
} }

View File

@@ -4,7 +4,6 @@ namespace Alchemy\Tests\Phrasea\Controller\Admin;
class UsersTest extends \PhraseanetAuthenticatedWebTestCase class UsersTest extends \PhraseanetAuthenticatedWebTestCase
{ {
protected $client;
protected $usersParameters; protected $usersParameters;
public function setUp() public function setUp()
@@ -29,10 +28,10 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
public function testRouteDelete() public function testRouteDelete()
{ {
$user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), "test"); $user = self::$DI['app']['manipulator.user']->createUser('login', "test");
self::$DI['client']->request('POST', '/admin/users/delete/', ['users' => $user->getId()]); self::$DI['client']->request('POST', '/admin/users/delete/', ['users' => $user->getId()]);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertNull(self::$DI['app']['manipulator.user']->getRepository()->find($user->getId())); $this->assertTrue($user->isDeleted());
} }
public function testRouteDeleteCurrentUserDoesNothing() public function testRouteDeleteCurrentUserDoesNothing()
@@ -40,25 +39,25 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['client']->request('POST', '/admin/users/delete/', ['users' => self::$DI['user']->getId()]); self::$DI['client']->request('POST', '/admin/users/delete/', ['users' => self::$DI['user']->getId()]);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isRedirect()); $this->assertTrue($response->isRedirect());
$this->assertNotNull(self::$DI['app']['manipulator.user']->getRepository()->findByLogin(self::$DI['user']->getLogin())); $this->assertNotNull(self::$DI['app']['manipulator.user']->getRepository()->findByLogin(self::$DI['user']->getLogin()));
} }
public function testRouteRightsApply() public function testRouteRightsApply()
{ {
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate', 2); $this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailSuccessEmailUpdate', 2);
$user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), 'test');
$user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), "test"); self::$DI['client']->request('POST', '/admin/users/rights/apply/', [
'users' => $user->getId(),
'values' => 'canreport_' . self::$DI['collection']->get_base_id() . '=1&manage_' . self::$DI['collection']->get_base_id() . '=1&canpush_' . self::$DI['collection']->get_base_id() . '=1',
'user_infos' => [ 'email' => 'toto@toto.fr' ]
]);
$base_id = self::$DI['collection']->get_base_id(); $base_id = self::$DI['collection']->get_base_id();
$_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . $base_id . '=1&canpush_' . $base_id . '=1'; $_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . $base_id . '=1&canpush_' . $base_id . '=1';
$_GET['user_infos'] = "user_infos[email]=" . $user->getEmail(); $_GET['user_infos'] = "user_infos[email]=" . $user->getEmail();
self::$DI['client']->request('POST', '/admin/users/rights/apply/', [ self::$DI['client']->request('POST', '/admin/users/rights/apply/', ['users' => $user->getId()]);
'users' => $user->getId(),
'values' => 'canreport_' . $base_id . '=1&manage_' . self::$DI['collection']->get_base_id() . '=1&canpush_' . self::$DI['collection']->get_base_id() . '=1',
'user_infos' => "user_infos[email]=" . $user->get_email(),
]);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type")); $this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -66,28 +65,29 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertTrue(is_object($datas)); $this->assertTrue(is_object($datas));
$datas = json_decode($response->getContent()); $datas = json_decode($response->getContent());
$this->assertFalse($datas->error); $this->assertFalse($datas->error);
$this->assertTrue(self::$DI['app']['acl']->get($user)->has_right_on_base($base_id, "manage"));
$this->assertTrue(self::$DI['app']['acl']->get($user)->has_right_on_base($base_id, "canpush")); $this->assertTrue(self::$DI['app']['acl']->get($user)->has_right_on_base(self::$DI['collection']->get_base_id(), "manage"));
$this->assertTrue(self::$DI['app']['acl']->get($user)->has_right_on_base($base_id, "canreport")); $this->assertTrue(self::$DI['app']['acl']->get($user)->has_right_on_base(self::$DI['collection']->get_base_id(), "canpush"));
$this->assertTrue(self::$DI['app']['acl']->get($user)->has_right_on_base(self::$DI['collection']->get_base_id(), "canreport"));
self::$DI['app']['EM']->refresh($user);
self::$DI['app']['model.user-manager']->delete($user); self::$DI['app']['model.user-manager']->delete($user);
} }
public function testRouteRightsApplyException() public function testRouteRightsApplyException()
{ {
$this->markTestIncomplete(); $this->markTestIncomplete();
$_GET = []; self::$DI['client']->request('POST', '/admin/users/rights/apply/', [
$user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), "test"); 'users' => 'unknow_id',
$base_id = self::$DI['collection']->get_base_id(); 'values' => 'canreport_' . self::$DI['collection']->get_base_id() . '=1&manage_' . self::$DI['collection']->get_base_id() . '=1&canpush_' . self::$DI['collection']->get_base_id() . '=1',
$_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . self::$DI['collection']->get_base_id() . '=1&canpush_' . self::$DI['collection']->get_base_id() . '=1'; 'user_infos' => "user_infos[email]=toto@toto.fr"
$_GET['user_infos'] = "user_infos[email]=" . $user->getEmail(); ]);
self::$DI['client']->request('POST', '/admin/users/rights/apply/', ['users' => $user->getId()]);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type")); $this->assertEquals("application/json", $response->headers->get("content-type"));
$datas = json_decode($response->getContent()); $data = json_decode($response->getContent());
$this->assertTrue(is_object($datas)); $this->assertTrue(is_object($data));
$this->assertTrue($datas->error); $this->assertTrue($data->error);
self::$DI['app']['model.user-manager']->delete($user);
} }
public function testRouteQuota() public function testRouteQuota()
@@ -95,7 +95,6 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
$keys = array_keys(self::$DI['app']['acl']->get(self::$DI['user'])->get_granted_base()); $keys = array_keys(self::$DI['app']['acl']->get(self::$DI['user'])->get_granted_base());
$base_id = array_pop($keys); $base_id = array_pop($keys);
$params = ['base_id' => $base_id, 'users' => self::$DI['user']->getId()]; $params = ['base_id' => $base_id, 'users' => self::$DI['user']->getId()];
self::$DI['client']->request('POST', '/admin/users/rights/quotas/', $params); self::$DI['client']->request('POST', '/admin/users/rights/quotas/', $params);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
@@ -136,9 +135,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
public function testRouteRightTimeSbas() public function testRouteRightTimeSbas()
{ {
$sbas_id = self::$DI['record_1']->get_databox()->get_sbas_id(); $sbas_id = self::$DI['record_1']->get_databox()->get_sbas_id();
$params = ['sbas_id' => $sbas_id, 'users' => self::$DI['user']->getId()]; self::$DI['client']->request('POST', '/admin/users/rights/time/sbas/', ['sbas_id' => $sbas_id, 'users' => self::$DI['user']->getId()]);
self::$DI['client']->request('POST', '/admin/users/rights/time/sbas/', $params);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOK()); $this->assertTrue($response->isOK());
} }
@@ -237,14 +234,13 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
public function testRouteApplyTp() public function testRouteApplyTp()
{ {
$this->authenticate(self::$DI['app']);
$template = self::$DI['app']['manipulator.user']->createUser(uniqid('template_'), "test"); $template = self::$DI['app']['manipulator.user']->createUser(uniqid('template_'), "test");
$template->setModel(self::$DI['user']); $template->setModelOf(self::$DI['user']);
$user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), "test"); $user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), "test");
self::$DI['client']->request('POST', '/admin/users/apply_template/', [ self::$DI['client']->request('POST', '/admin/users/apply_template/', [
'template' => $template->getId() 'template' => $template->getId(),
, 'users' => $user->getId()] 'users' => $user->getId()]
); );
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -293,7 +289,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertTrue(is_object($datas)); $this->assertTrue(is_object($datas));
$this->assertFalse($datas->error); $this->assertFalse($datas->error);
$this->assertNotNull($user = (self::$DI['app']['manipulator.user']->getRepository((int) $datas->data))); $this->assertNotNull($user = (self::$DI['app']['manipulator.user']->getRepository()->find((int) $datas->data)));
self::$DI['app']['model.user-manager']->delete($user); self::$DI['app']['model.user-manager']->delete($user);
} }
@@ -316,7 +312,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertTrue(is_object($datas)); $this->assertTrue(is_object($datas));
$this->assertFalse($datas->error); $this->assertFalse($datas->error);
$this->assertNotNull($user = (self::$DI['app']['manipulator.user']->getRepository((int) $datas->data))); $this->assertNotNull($user = (self::$DI['app']['manipulator.user']->getRepository()->find((int) $datas->data)));
self::$DI['app']['model.user-manager']->delete($user); self::$DI['app']['model.user-manager']->delete($user);
} }
@@ -374,10 +370,13 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['app']['model.user-manager']->delete($user); self::$DI['app']['model.user-manager']->delete($user);
} }
/**
* environment prod
*/
public function testRenderDemands() public function testRenderDemands()
{ {
$this->setConnectionEnvironment('prod');
self::$DI['client']->request('GET', '/admin/users/demands/'); self::$DI['client']->request('GET', '/admin/users/demands/');
$this->assertTrue(self::$DI['client']->getResponse()->isOk()); $this->assertTrue(self::$DI['client']->getResponse()->isOk());
} }

View File

@@ -324,8 +324,7 @@ class BasketTest extends \PhraseanetAuthenticatedWebTestCase
public function testAddElementToValidationPost() public function testAddElementToValidationPost()
{ {
$datas = self::$DI['app']['EM']->getRepository('Phraseanet:ValidationData')->findAll(); $countData = count(self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\ValidationData')->findAll());
$countDatas = count($datas);
$basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 4); $basket = self::$DI['app']['EM']->find('Phraseanet:Basket', 4);
$this->assertCount(2, $basket->getElements()); $this->assertCount(2, $basket->getElements());

View File

@@ -367,25 +367,10 @@ class BridgeTest extends \PhraseanetAuthenticatedWebTestCase
public function testUpload() public function testUpload()
{ {
self::$account->get_settings()->set("auth_token", "somethingNotNull"); self::$account->get_settings()->set("auth_token", "somethingNotNull");
$url = "/prod/bridge/upload/"; self::$DI['client']->request('GET', "/prod/bridge/upload/", ["account_id" => self::$account->get_id(), 'lst' => self::$DI['record_1']->get_serialize_key()]);
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 = [
self::$DI['record_1']->get_serialize_key()
];
\Bridge_Api_Apitest::$hasError = true;
$lst = implode(';', $records);
self::$DI['client']->request('POST', $url, ["account_id" => self::$account->get_id(), 'lst' => $lst]);
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
self::$DI['client']->request('POST', $url, ["account_id" => self::$account->get_id(), 'lst' => $lst]);
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isRedirect());
} }
public function testDeleteAccount() public function testDeleteAccount()

View File

@@ -28,7 +28,6 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['client']->request('POST', '/prod/export/multi-export/', ['lst' => self::$DI['record_1']->get_serialize_key()]); self::$DI['client']->request('POST', '/prod/export/multi-export/', ['lst' => self::$DI['record_1']->get_serialize_key()]);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
unset($response);
} }
/** /**

View File

@@ -44,17 +44,13 @@ class PushTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['record_2']->get_serialize_key(), self::$DI['record_2']->get_serialize_key(),
]; ];
$receivers = [ self::$DI['client']->request('POST', $route, [
['usr_id' => self::$DI['user_alt1']->getId(), 'HD' => 1] 'lst' => implode(';', $records),
, ['usr_id' => self::$DI['user_alt2']->getId(), 'HD' => 0] 'participants' => [
]; ['usr_id' => self::$DI['user_alt1']->getId(), 'HD' => 1],
['usr_id' => self::$DI['user_alt2']->getId(), 'HD' => 0]
$params = [ ]
'lst' => implode(';', $records) ]);
, 'participants' => $receivers
];
self::$DI['client']->request('POST', $route, $params);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
@@ -80,27 +76,20 @@ class PushTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['record_2']->get_serialize_key(), self::$DI['record_2']->get_serialize_key(),
]; ];
$participants = [ self::$DI['client']->request('POST', $route, [
[ 'lst' => implode(';', $records),
'participants' => [[
'usr_id' => self::$DI['user_alt1']->getId(), 'usr_id' => self::$DI['user_alt1']->getId(),
'agree' => 0, 'agree' => 0,
'see_others' => 1, 'see_others' => 1,
'HD' => 0, 'HD' => 0,
] ], [
, [
'usr_id' => self::$DI['user_alt2']->getId(), 'usr_id' => self::$DI['user_alt2']->getId(),
'agree' => 1, 'agree' => 1,
'see_others' => 0, 'see_others' => 0,
'HD' => 1, 'HD' => 1,
] ]]
]; ]);
$params = [
'lst' => implode(';', $records)
, 'participants' => $participants
];
self::$DI['client']->request('POST', $route, $params);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();

View File

@@ -12,8 +12,7 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['client']->request('GET', '/prod/'); self::$DI['client']->request('GET', '/prod/');
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
/* @var $response \Symfony\Component\HttpFoundation\Response */ $this->assertTrue($response->isOk());
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('UTF-8', $response->getCharset()); $this->assertEquals('UTF-8', $response->getCharset());
} }
} }

View File

@@ -24,8 +24,6 @@ class WorkZoneTest extends \PhraseanetAuthenticatedWebTestCase
$route = sprintf("/prod/WorkZone/attachStories/"); $route = sprintf("/prod/WorkZone/attachStories/");
self::$DI['client']->request('POST', $route); self::$DI['client']->request('POST', $route);
$response = self::$DI['client']->getResponse();
$this->assertBadResponse(self::$DI['client']->getResponse()); $this->assertBadResponse(self::$DI['client']->getResponse());
} }
@@ -35,7 +33,6 @@ class WorkZoneTest extends \PhraseanetAuthenticatedWebTestCase
$route = sprintf("/prod/WorkZone/attachStories/"); $route = sprintf("/prod/WorkZone/attachStories/");
self::$DI['client']->request('POST', $route, ['stories' => [$story->get_serialize_key()]]); self::$DI['client']->request('POST', $route, ['stories' => [$story->get_serialize_key()]]);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertEquals(302, $response->getStatusCode()); $this->assertEquals(302, $response->getStatusCode());
$em = self::$DI['app']['EM']; $em = self::$DI['app']['EM'];

View File

@@ -150,12 +150,11 @@ class InformationsTest extends \PhraseanetAuthenticatedWebTestCase
'sbasid' => self::$DI['collection']->get_sbas_id(), 'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(), 'collection' => self::$DI['collection']->get_coll_id(),
'from' => 'GEN', 'from' => 'GEN',
'on' => 'usr_mail', 'on' => 'email',
'user' => self::$DI['user']->getEmail() 'user' => self::$DI['user']->getEmail()
]); ]);
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk()); $this->assertTrue($response->isOk());
} }
@@ -167,7 +166,7 @@ class InformationsTest extends \PhraseanetAuthenticatedWebTestCase
'sbasid' => self::$DI['collection']->get_sbas_id(), 'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(), 'collection' => self::$DI['collection']->get_coll_id(),
'from' => 'CNX', 'from' => 'CNX',
'on' => 'usr_mail', 'on' => 'email',
'user' => self::$DI['user']->getEmail() 'user' => self::$DI['user']->getEmail()
]); ]);
@@ -184,7 +183,7 @@ class InformationsTest extends \PhraseanetAuthenticatedWebTestCase
'sbasid' => self::$DI['collection']->get_sbas_id(), 'sbasid' => self::$DI['collection']->get_sbas_id(),
'collection' => self::$DI['collection']->get_coll_id(), 'collection' => self::$DI['collection']->get_coll_id(),
'from' => 'ASK', 'from' => 'ASK',
'on' => 'usr_mail', 'on' => 'email',
'user' => self::$DI['user']->getEmail() 'user' => self::$DI['user']->getEmail()
]); ]);

View File

@@ -589,80 +589,80 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
{ {
return [ return [
[[//required field missing [[//required field missing
"password" => [ "password" => [
'password' => 'password', 'password' => 'password',
'confirm' => 'password' 'confirm' => 'password'
], ],
"collections" => null, "collections" => null,
], [], 1], ], [], 1],
[[//required extra-field missing [[//required extra-field missing
"password" => [ "password" => [
'password' => 'password', 'password' => 'password',
'confirm' => 'password' 'confirm' => 'password'
], ],
"email" => $this->generateEmail(), "email" => $this->generateEmail(),
"collections" => null "collections" => null
], [ ], [
[ [
'name' => 'login', 'name' => 'login',
'required' => true, 'required' => true,
] ]
], 1], ], 1],
[[//password mismatch [[//password mismatch
"password" => [ "password" => [
'password' => 'password', 'password' => 'password',
'confirm' => 'passwordMismatch' 'confirm' => 'passwordMismatch'
], ],
"email" => $this->generateEmail(), "email" => $this->generateEmail(),
"collections" => null "collections" => null
], [], 1], ], [], 1],
[[//password tooshort [[//password tooshort
"password" => [ "password" => [
'password' => 'min', 'password' => 'min',
'confirm' => 'min' 'confirm' => 'min'
], ],
"email" => $this->generateEmail(), "email" => $this->generateEmail(),
"collections" => null "collections" => null
], [], 1], ], [], 1],
[[//email invalid [[//email invalid
"password" => [ "password" => [
'password' => 'password', 'password' => 'password',
'confirm' => 'password' 'confirm' => 'password'
], ],
"email" => 'invalid.email', "email" => 'invalid.email',
"collections" => null "collections" => null
], [], 1], ], [], 1],
[[//login exists [[//login exists
"login" => null, "login" => null,
"password" => [ "password" => [
'password' => 'password', 'password' => 'password',
'confirm' => 'password' 'confirm' => 'password'
], ],
"email" => $this->generateEmail(), "email" => $this->generateEmail(),
"collections" => null "collections" => null
], [ ], [
[ [
'name' => 'login', 'name' => 'login',
'required' => true, 'required' => true,
] ]
], 1], ], 1],
[[//mails exists [[//mails exists
"password" => [ "password" => [
'password' => 'password', 'password' => 'password',
'confirm' => 'password' 'confirm' => 'password'
], ],
"email" => null, "email" => null,
"collections" => null "collections" => null
], [], 1], ], [], 1],
[[//tou declined [[//tou declined
"password" => [ "password" => [
'password' => 'password', 'password' => 'password',
'confirm' => 'password' 'confirm' => 'password'
], ],
"email" => $this->generateEmail(), "email" => $this->generateEmail(),
"collections" => null, "collections" => null,
"accept-tou" => '1' "accept-tou" => '1'
], [], 1] ], [], 1]
]; ];
} }
@@ -670,152 +670,152 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
{ {
return [ return [
[[ [[
"password" => [ "password" => [
'password' => 'password', 'password' => 'password',
'confirm' => 'password' 'confirm' => 'password'
], ],
"email" => $this->generateEmail(), "email" => $this->generateEmail(),
"collections" => null, "collections" => null,
], []], ], []],
[[ [[
"password" => [ "password" => [
'password' => 'password', 'password' => 'password',
'confirm' => 'password' 'confirm' => 'password'
], ],
"email" => $this->generateEmail(), "email" => $this->generateEmail(),
"collections" => null "collections" => null
], [ ], [
[ [
'name' => 'login', 'name' => 'login',
'required' => false, 'required' => false,
] ]
]], ]],
[[//extra-fields are not required [[//extra-fields are not required
"password" => [ "password" => [
'password' => 'password', 'password' => 'password',
'confirm' => 'password' 'confirm' => 'password'
], ],
"email" => $this->generateEmail(), "email" => $this->generateEmail(),
"collections" => null "collections" => null
], [ ], [
[ [
'name' => 'login', 'name' => 'login',
'required' => false, 'required' => false,
], ],
[ [
'name' => 'gender', 'name' => 'gender',
'required' => false, 'required' => false,
], ],
[ [
'name' => 'firstname', 'name' => 'firstname',
'required' => false, 'required' => false,
], ],
[ [
'name' => 'lastname', 'name' => 'lastname',
'required' => false, 'required' => false,
], ],
[ [
'name' => 'address', 'name' => 'address',
'required' => false, 'required' => false,
], ],
[ [
'name' => 'zipcode', 'name' => 'zipcode',
'required' => false, 'required' => false,
], ],
[ [
'name' => 'geonameid', 'name' => 'geonameid',
'required' => false, 'required' => false,
], ],
[ [
'name' => 'position', 'name' => 'position',
'required' => false, 'required' => false,
], ],
[ [
'name' => 'company', 'name' => 'company',
'required' => false, 'required' => false,
], ],
[ [
'name' => 'job', 'name' => 'job',
'required' => false, 'required' => false,
], ],
[ [
'name' => 'tel', 'name' => 'tel',
'required' => false, 'required' => false,
], ],
[ [
'name' => 'fax', 'name' => 'fax',
'required' => false, 'required' => false,
] ]
]], ]],
[[//extra-fields are required [[//extra-fields are required
"password" => [ "password" => [
'password' => 'password', 'password' => 'password',
'confirm' => 'password' 'confirm' => 'password'
], ],
"email" => $this->generateEmail(), "email" => $this->generateEmail(),
"collections" => null, "collections" => null,
"login" => 'login-'.\random::generatePassword(), "login" => 'login-'.\random::generatePassword(),
"gender" => '1', "gender" => User::GENDER_MR,
"firstname" => 'romain', "firstname" => 'romain',
"lastname" => 'neutron', "lastname" => 'neutron',
"address" => '30 place saint georges', "address" => '30 place saint georges',
"zipcode" => 'zip', "zipcode" => 'zip',
"geonameid" => 123456, "geonameid" => 123456,
"position" => 'position', "position" => 'position',
"company" => 'company', "company" => 'company',
"job" => 'job', "job" => 'job',
"tel" => 'tel', "tel" => 'tel',
"fax" => 'fax', "fax" => 'fax',
], [ ], [
[ [
'name' => 'login', 'name' => 'login',
'required' => true, 'required' => true,
], ],
[ [
'name' => 'gender', 'name' => 'gender',
'required' => true, 'required' => true,
], ],
[ [
'name' => 'firstname', 'name' => 'firstname',
'required' => true, 'required' => true,
], ],
[ [
'name' => 'lastname', 'name' => 'lastname',
'required' => true, 'required' => true,
], ],
[ [
'name' => 'address', 'name' => 'address',
'required' => true, 'required' => true,
], ],
[ [
'name' => 'zipcode', 'name' => 'zipcode',
'required' => true, 'required' => true,
], ],
[ [
'name' => 'geonameid', 'name' => 'geonameid',
'required' => true, 'required' => true,
], ],
[ [
'name' => 'position', 'name' => 'position',
'required' => true, 'required' => true,
], ],
[ [
'name' => 'company', 'name' => 'company',
'required' => true, 'required' => true,
], ],
[ [
'name' => 'job', 'name' => 'job',
'required' => true, 'required' => true,
], ],
[ [
'name' => 'tel', 'name' => 'tel',
'required' => true, 'required' => true,
], ],
[ [
'name' => 'fax', 'name' => 'fax',
'required' => true, 'required' => true,
] ]
]], ]],
]; ];
} }
@@ -830,7 +830,6 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
$entity = $this->getMock('Alchemy\Phrasea\Model\Entities\UsrAuthProvider'); $entity = $this->getMock('Alchemy\Phrasea\Model\Entities\UsrAuthProvider');
$entity->expects($this->any()) $entity->expects($this->any())
->method('getUser') ->method('getUser')
->with(self::$DI['app'])
->will($this->returnValue(self::$DI['user'])); ->will($this->returnValue(self::$DI['user']));
$token = new Token($provider, 42); $token = new Token($provider, 42);
@@ -846,7 +845,6 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
'confirm' => 'password' 'confirm' => 'password'
], ],
"email" => $this->generateEmail(), "email" => $this->generateEmail(),
"accept-tou" => '1',
"collections" => null, "collections" => null,
"provider-id" => 'provider-test', "provider-id" => 'provider-test',
]); ]);
@@ -864,7 +862,6 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
} }
self::$DI['client']->request('POST', '/login/register-classic/', $parameters); self::$DI['client']->request('POST', '/login/register-classic/', $parameters);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertEquals('/prod/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertEquals('/prod/', self::$DI['client']->getResponse()->headers->get('location'));
} }
@@ -917,7 +914,7 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
->will($this->throwException(new NotAuthenticatedException('Not authenticated'))); ->will($this->throwException(new NotAuthenticatedException('Not authenticated')));
$parameters = array_merge(['_token' => 'token'], [ $parameters = array_merge(['_token' => 'token'], [
"password" => [ "password" => [
'password' => 'password', 'password' => 'password',
'confirm' => 'password' 'confirm' => 'password'
], ],
@@ -946,7 +943,11 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertEquals('/login/register/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertEquals('/login/register/', self::$DI['client']->getResponse()->headers->get('location'));
} }
public function testPostRegisterWithProviderId() /**
*
* @environment prod
*/
public function testPostRegisterWithProviderIdAndAccountNotCreatedYet()
{ {
self::$DI['app']['registration.fields'] = []; self::$DI['app']['registration.fields'] = [];
$this->logout(self::$DI['app']); $this->logout(self::$DI['app']);
@@ -965,7 +966,6 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
'confirm' => 'password' 'confirm' => 'password'
], ],
"email" => $this->generateEmail(), "email" => $this->generateEmail(),
"accept-tou" => '1',
"collections" => null, "collections" => null,
"provider-id" => 'provider-test', "provider-id" => 'provider-test',
]); ]);
@@ -979,6 +979,41 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
->method('getToken') ->method('getToken')
->will($this->returnValue($token)); ->will($this->returnValue($token));
$repo = $this->getMockBuilder('Doctrine\ORM\EntityRepository\UsrAuthProviderRepository')
->setMethods(['findWithProviderAndId'])
->disableOriginalConstructor()
->getMock();
$repo->expects($this->any())
->method('findWithProviderAndId')
->with('provider-test', $token->getId())
->will($this->returnValue(null));
$em = self::$DI['app']['EM'];
self::$DI['app']['EM'] = $this->getMockBuilder('Doctrine\ORM\EntityManager')
->setMethods(['getRepository', 'getClassMetadata', 'persist', 'flush', 'getConnection', 'getUnitOfWork'])
->disableOriginalConstructor()
->getMock();
self::$DI['app']['EM']->expects($this->at(0))
->method('getRepository')
->with('Alchemy\Phrasea\Model\Entities\UsrAuthProvider')
->will($this->returnValue($repo));
self::$DI['app']['EM']->expects($this->any())
->method('getClassMetadata')
->with($this->equalTo('Alchemy\Phrasea\Model\Entities\User'))
->will($this->returnValue($em->getClassMetadata('Alchemy\Phrasea\Model\Entities\User')));
self::$DI['app']['EM']->expects($this->any())
->method('getConnection')
->will($this->returnValue($em->getConnection()));
self::$DI['app']['EM']->expects($this->any())
->method('getUnitOfWork')
->will($this->returnValue($em->getUnitOfWork()));
foreach ($parameters as $key => $parameter) { foreach ($parameters as $key => $parameter) {
if ('collections' === $key && null === $parameter) { if ('collections' === $key && null === $parameter) {
$parameters[$key] = self::$demands; $parameters[$key] = self::$demands;
@@ -996,27 +1031,23 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
} }
self::$DI['client']->request('POST', '/login/register-classic/', $parameters); self::$DI['client']->request('POST', '/login/register-classic/', $parameters);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
if (null === $user = $user= self::$DI['app']['manipulator.user']->getRepository()->findByEmail($parameters['email'])) { if (null === $user = self::$DI['app']['manipulator.user']->getRepository()->findByEmail($parameters['email'])) {
$this->fail('User not created'); $this->fail('User not created');
} }
$ret = self::$DI['app']['EM']->getRepository('\Alchemy\Phrasea\Model\Entities\UsrAuthProvider')
->findBy(['usr_id' => $user->getId(), 'provider' => 'provider-test']);
$this->assertCount(1, $ret);
self::$DI['app']['model.user-manager']->delete($user); self::$DI['app']['model.user-manager']->delete($user);
$this->assertGreaterThan(0, $emails['Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered']); $this->assertGreaterThan(0, $emails['Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered']);
$this->assertEquals(1, $emails['Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation']); $this->assertEquals(1, $emails['Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation']);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertFlashMessagePopulated(self::$DI['app'], 'info', 1); $this->assertFlashMessagePopulated(self::$DI['app'], 'info', 1);
$this->assertEquals('/login/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertEquals('/login/', self::$DI['client']->getResponse()->headers->get('location'));
} }
/** /**
* @dataProvider provideRegistrationData * @dataProvider provideRegistrationData
* @environment prod
*/ */
public function testPostRegister($parameters, $extraParameters) public function testPostRegister($parameters, $extraParameters)
{ {
@@ -1054,14 +1085,12 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
if (null === $user = $user= self::$DI['app']['manipulator.user']->getRepository()->findByEmail($parameters['email'])) { if (null === $user = $user= self::$DI['app']['manipulator.user']->getRepository()->findByEmail($parameters['email'])) {
$this->fail('User not created'); $this->fail('User not created');
} }
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
self::$DI['app']['model.user-manager']->delete($user);
$this->assertGreaterThan(0, $emails['Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered']); $this->assertGreaterThan(0, $emails['Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered']);
$this->assertEquals(1, $emails['Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation']); $this->assertEquals(1, $emails['Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation']);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertFlashMessagePopulated(self::$DI['app'], 'info', 1); $this->assertFlashMessagePopulated(self::$DI['app'], 'info', 1);
$this->assertEquals('/login/', self::$DI['client']->getResponse()->headers->get('location')); $this->assertEquals('/login/', self::$DI['client']->getResponse()->headers->get('location'));
self::$DI['app']['model.user-manager']->delete($user);
} }
/** /**
@@ -1123,21 +1152,20 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
public function testAuthenticate() public function testAuthenticate()
{ {
$password = \random::generatePassword(); $password = \random::generatePassword();
$login = self::$DI['app']['authentication']->getUser()->getLogin(); $login = self::$DI['app']['authentication']->getUser()->getLogin();
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']['authentication']->getUser(), $password); self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']['authentication']->getUser(), $password);
self::$DI['app']['authentication']->getUser()->setMailLocked(false); self::$DI['app']['authentication']->getUser()->setMailLocked(false);
self::$DI['app']['EM']->persist(self::$DI['app']['authentication']->getUser());
self::$DI['app']['EM']->flush();
$this->logout(self::$DI['app']); $this->logout(self::$DI['app']);
self::$DI['client'] = new Client(self::$DI['app'], []);
$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('POST', '/login/authenticate/', [ self::$DI['client']->request('POST', '/login/authenticate/', [
'login' => $login, 'login' => $login,
'password' => $password, 'password' => $password,
'_token' => 'token', '_token' => 'token',
]); ]);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertRegExp('/^\/prod\/$/', self::$DI['client']->getResponse()->headers->get('Location')); $this->assertRegExp('/^\/prod\/$/', self::$DI['client']->getResponse()->headers->get('Location'));
} }
@@ -1219,18 +1247,13 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
*/ */
public function testGuestAuthenticate() public function testGuestAuthenticate()
{ {
if (null === $user= self::$DI['app']['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST)) { $guest = self::$DI['app']['manipulator.user']->createUser(User::USER_GUEST, User::USER_GUEST);
$this->fail('User not created'); self::$DI['app']['acl']->get($guest)->give_access_to_base([self::$DI['collection']->get_base_id()]);
}
self::$DI['app']['acl']->get($user)->give_access_to_base([self::$DI['collection']->get_base_id()]);
$this->logout(self::$DI['app']); $this->logout(self::$DI['app']);
self::$DI['client'] = new Client(self::$DI['app'], []);
$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('POST', '/login/authenticate/guest/'); self::$DI['client']->request('POST', '/login/authenticate/guest/');
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertRegExp('/^\/prod\/$/', self::$DI['client']->getResponse()->headers->get('Location')); $this->assertRegExp('/^\/prod\/$/', self::$DI['client']->getResponse()->headers->get('Location'));
@@ -1252,11 +1275,8 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertEquals($context, $event->getContext()->getContext()); $this->assertEquals($context, $event->getContext()->getContext());
}); });
if (null === $user= self::$DI['app']['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST)) { $guest = self::$DI['app']['manipulator.user']->createUser(User::USER_GUEST, User::USER_GUEST);
$this->fail('User not created'); self::$DI['app']['acl']->get($guest)->give_access_to_base([self::$DI['collection']->get_base_id()]);
}
self::$DI['app']['acl']->get($user)->give_access_to_base([self::$DI['collection']->get_base_id()]);
$this->logout(self::$DI['app']); $this->logout(self::$DI['app']);
@@ -1272,12 +1292,14 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
*/ */
public function testGuestAuthenticateWithGetMethod() public function testGuestAuthenticateWithGetMethod()
{ {
$guest = self::$DI['app']['manipulator.user']->createUser(User::USER_GUEST, User::USER_GUEST);
self::$DI['app']['acl']->get($guest)->give_access_to_base([self::$DI['collection']->get_base_id()]);
$this->logout(self::$DI['app']); $this->logout(self::$DI['app']);
self::$DI['client'] = new Client(self::$DI['app'], []); self::$DI['client'] = new Client(self::$DI['app'], []);
$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', '/login/authenticate/guest/'); self::$DI['client']->request('GET', '/login/authenticate/guest/');
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect()); $this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertRegExp('/^\/prod\/$/', self::$DI['client']->getResponse()->headers->get('Location')); $this->assertRegExp('/^\/prod\/$/', self::$DI['client']->getResponse()->headers->get('Location'));
@@ -1455,7 +1477,6 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
$entity = $this->getMock('Alchemy\Phrasea\Model\Entities\UsrAuthProvider'); $entity = $this->getMock('Alchemy\Phrasea\Model\Entities\UsrAuthProvider');
$entity->expects($this->any()) $entity->expects($this->any())
->method('getUser') ->method('getUser')
->with(self::$DI['app'])
->will($this->returnValue(self::$DI['user'])); ->will($this->returnValue(self::$DI['user']));
$token = new Token($provider, 42); $token = new Token($provider, 42);

View File

@@ -91,7 +91,7 @@ class SessionTest extends \PhraseanetAuthenticatedWebTestCase
$session = $this->getMock('Alchemy\Phrasea\Model\Entities\Session'); $session = $this->getMock('Alchemy\Phrasea\Model\Entities\Session');
$session->expects($this->once()) $session->expects($this->any())
->method('getUser') ->method('getUser')
->will($this->returnValue(self::$DI['app']['authentication']->getUser())); ->will($this->returnValue(self::$DI['app']['authentication']->getUser()));
@@ -125,9 +125,9 @@ class SessionTest extends \PhraseanetAuthenticatedWebTestCase
$session = $this->getMock('Alchemy\Phrasea\Model\Entities\Session'); $session = $this->getMock('Alchemy\Phrasea\Model\Entities\Session');
$session->expects($this->once()) $session->expects($this->any())
->method('getUsrId') ->method('getUser')
->will($this->returnValue(self::$DI['app']['authentication']->getUser()->getId() + 1)); ->will($this->returnValue(self::$DI['user_alt1']));
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager') $em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
->disableOriginalConstructor() ->disableOriginalConstructor()

View File

@@ -92,22 +92,19 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase
$app['EM'] = $this->getMockBuilder('Doctrine\ORM\EntityManager') $app['EM'] = $this->getMockBuilder('Doctrine\ORM\EntityManager')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$app['recaptcha'] = $this->getMockBuilder('Neutron\ReCaptcha\ReCaptcha') self::$DI['app']['recaptcha'] = $this->getMockBuilder('Neutron\ReCaptcha\ReCaptcha')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$manager = $app['auth.native.failure-manager']; $manager = self::$DI['app']['auth.native.failure-manager'];
$this->assertEquals(42, $manager->getTrials()); $this->assertEquals(42, $manager->getTrials());
} }
public function testFailureAccountCreator() public function testFailureAccountCreator()
{ {
$app = new PhraseaApplication(); self::$DI['app']->register(new ConfigurationServiceProvider());
$app->register(new ConfigurationServiceProvider()); self::$DI['app']['conf']->set(['authentication', 'auto-create'], ['templates' => []]);
self::$DI['app']['authentication.providers.account-creator'];
$app['conf']->set(['authentication', 'auto-create'], ['templates' => []]);
$app['authentication.providers.account-creator'];
} }
public function testAuthNativeWithCaptchaEnabled() public function testAuthNativeWithCaptchaEnabled()
@@ -132,7 +129,7 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase
public function testAuthNativeWithCaptchaDisabled() public function testAuthNativeWithCaptchaDisabled()
{ {
$app = $this->loadApp(); $app = new Application();
$app['root.path'] = __DIR__ . '/../../../../../../'; $app['root.path'] = __DIR__ . '/../../../../../../';
$app->register(new AuthenticationManagerServiceProvider()); $app->register(new AuthenticationManagerServiceProvider());
$app->register(new ConfigurationServiceProvider()); $app->register(new ConfigurationServiceProvider());
@@ -152,17 +149,14 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase
public function testAccountCreator() public function testAccountCreator()
{ {
$app = new PhraseaApplication(); $template1 = $user = self::$DI['app']['manipulator.user']->createTemplate('template1', self::$DI['user']);
$template2 = $user = self::$DI['app']['manipulator.user']->createTemplate('template2', self::$DI['user']);
$random = $app['tokens']; self::$DI['app']['conf']->set(['authentication', 'auto-create'], ['templates' => [$template1->getId(), $template2->getId()]]);
$template1 = $user = self::$DI['app']['manipulator.user']->createUser('template' . $random->generatePassword(), $random->generatePassword());
$template1->setModel(self::$DI['user']);
$template2 = self::$DI['app']['manipulator.user']->createUser('template' . $random->generatePassword(), $random->generatePassword());
$template2->setModel(self::$DI['user']);
$app['conf']->set(['authentication', 'auto-create'], ['templates' => [$template1->get_id(), $template2->get_login()]]); $this->assertEquals([$template1->getLogin(), $template2->getLogin()], array_map(function($u) {
return $u->getLogin();
$this->assertEquals([$template1, $template2], $app['authentication.providers.account-creator']->getTemplates()); }, self::$DI['app']['authentication.providers.account-creator']->getTemplates()));
self::$DI['app']['model.user-manager']->delete($template1); self::$DI['app']['model.user-manager']->delete($template1);
self::$DI['app']['model.user-manager']->delete($template2); self::$DI['app']['model.user-manager']->delete($template2);

View File

@@ -18,7 +18,7 @@ class AggregateLinkGeneratorTest extends \PhraseanetTestCase
$feed = new Feed(); $feed = new Feed();
$feed->setTitle("title"); $feed->setTitle("title");
$another_feed = new Feed($user); $another_feed = new Feed(self::$DI['user']);
$another_feed->setTitle("another_title"); $another_feed->setTitle("another_title");
$feeds = [$feed, $another_feed]; $feeds = [$feed, $another_feed];
@@ -48,7 +48,7 @@ class AggregateLinkGeneratorTest extends \PhraseanetTestCase
$linkGenerator = new AggregateLinkGenerator($generator, self::$DI['app']['EM'], $random); $linkGenerator = new AggregateLinkGenerator($generator, self::$DI['app']['EM'], $random);
$link = $linkGenerator->generate($aggregate, $user, $format, $page, $renew); $link = $linkGenerator->generate($aggregate, self::$DI['user'], $format, $page, $renew);
if ($format == "atom") { if ($format == "atom") {
$this->assertSame("application/atom+xml", $link->getMimetype()); $this->assertSame("application/atom+xml", $link->getMimetype());

View File

@@ -38,7 +38,7 @@ class FeedLinkGeneratorTest extends \PhraseanetTestCase
$linkGenerator = new FeedLinkGenerator($generator, self::$DI['app']['EM'], $random); $linkGenerator = new FeedLinkGenerator($generator, self::$DI['app']['EM'], $random);
$link = $linkGenerator->generate($feed, $user, $format, $page, $renew); $link = $linkGenerator->generate($feed, self::$DI['user'], $format, $page, $renew);
$this->assertSame($expected, $link->getUri()); $this->assertSame($expected, $link->getUri());
if ($format == "atom") { if ($format == "atom") {

View File

@@ -6,7 +6,7 @@ class ACLManipulatorTest extends \PhraseanetTestCase
{ {
public function testResetAdminRights() public function testResetAdminRights()
{ {
$user = self::$DI['app']['manipulator.user']->create(uniqid('toto'), 'toto', null, true); $user = self::$DI['app']['manipulator.user']->createUser(uniqid('toto'), 'toto', null, true);
$acl = self::$DI['app']['acl']->get($user); $acl = self::$DI['app']['acl']->get($user);
$databoxId = null; $databoxId = null;

View File

@@ -14,7 +14,7 @@ class UserProviderTest extends \PhraseanetTestCase
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new \Alchemy\Phrasea\Vocabulary\ControlProvider\UserProvider(self::$DI['app']); $this->object = new UserProvider(self::$DI['app']);
} }
/** /**
@@ -39,6 +39,9 @@ class UserProviderTest extends \PhraseanetTestCase
public function testFind() public function testFind()
{ {
$this->setConnectionEnvironment('prod');
self::$DI['user'];
$results = $this->object->find('BABE', self::$DI['user'], self::$DI['collection']->get_databox()); $results = $this->object->find('BABE', self::$DI['user'], self::$DI['collection']->get_databox());
$this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $results); $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $results);

View File

@@ -12,11 +12,11 @@ class ACLTest extends \PhraseanetAuthenticatedTestCase
public static function tearDownAfterClass() public static function tearDownAfterClass()
{ {
$application = new Application('test'); $application = new Application('test');
if (null !== $template = self::$DI['app']['manipulator.user']->findByLogin('test_phpunit2')) { if (null !== $template = self::$DI['app']['manipulator.user']->getRepository()->findByLogin('test_phpunit2')) {
self::$DI['app']['model.user-manager']->delete($template); self::$DI['app']['model.user-manager']->delete($template);
} }
if (null !== $template = self::$DI['app']['manipulator.user']->findByLogin('test_phpunit3')) { if (null !== $template = self::$DI['app']['manipulator.user']->getRepository()->findByLogin('test_phpunit3')) {
self::$DI['app']['model.user-manager']->delete($template); self::$DI['app']['model.user-manager']->delete($template);
} }
@@ -81,7 +81,7 @@ class ACLTest extends \PhraseanetAuthenticatedTestCase
public function testApply_model() public function testApply_model()
{ {
$template = self::$DI['app']['manipulator.user']->createUser('test_phpunit2', 'blabla2', 'test2@example.com'); $template = self::$DI['app']['manipulator.user']->createUser('test_phpunit2', 'blabla2', 'test2@example.com');
$template->setModel(self::$DI['user']); $template->setModelOf(self::$DI['user']);
$base_ids = []; $base_ids = [];
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {
@@ -112,7 +112,7 @@ class ACLTest extends \PhraseanetAuthenticatedTestCase
public function testApply_model_with_time_limit() public function testApply_model_with_time_limit()
{ {
$template = self::$DI['app']['manipulator.user']->createUser('test_phpunit2', 'blabla2', 'test2@example.com'); $template = self::$DI['app']['manipulator.user']->createUser('test_phpunit2', 'blabla2', 'test2@example.com');
$template->setModel(self::$DI['user']); $template->setModelOf(self::$DI['user']);
$base_ids = []; $base_ids = [];
foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) { foreach (self::$DI['app']['phraseanet.appbox']->get_databoxes() as $databox) {

View File

@@ -40,7 +40,7 @@ class Bridge_Api_Dailymotion_ContainerTest extends \PhraseanetTestCase
$this->assertEquals($this->test['id'], $this->object->get_id()); $this->assertEquals($this->test['id'], $this->object->get_id());
unset($this->test["id"]); unset($this->test["id"]);
$this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla'); $this->object = new Bridge_Api_Dailymotion_Element($this->test, 'blabla');
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->getId()); $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $this->object->get_id());
$this->assertEmpty($this->object->get_id()); $this->assertEmpty($this->object->get_id());
} }

View File

@@ -19,6 +19,7 @@ use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\ValidationData; use Alchemy\Phrasea\Model\Entities\ValidationData;
use Alchemy\Phrasea\Model\Entities\ValidationSession; use Alchemy\Phrasea\Model\Entities\ValidationSession;
use Alchemy\Phrasea\Model\Entities\ValidationParticipant; use Alchemy\Phrasea\Model\Entities\ValidationParticipant;
use Doctrine\ORM\EntityManager;
use Alchemy\Phrasea\Model\Entities\UsrListOwner; use Alchemy\Phrasea\Model\Entities\UsrListOwner;
use Alchemy\Phrasea\Model\Entities\UsrList; use Alchemy\Phrasea\Model\Entities\UsrList;
use Alchemy\Phrasea\Model\Entities\UsrListEntry; use Alchemy\Phrasea\Model\Entities\UsrListEntry;
@@ -58,6 +59,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
protected static $testsTime = []; protected static $testsTime = [];
protected static $records; protected static $records;
public static $recordsInitialized = false; public static $recordsInitialized = false;
public static $collectionsInitialized = false;
/** /**
* Tell if tables were updated with new schemas * Tell if tables were updated with new schemas
@@ -218,14 +220,14 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* Sets self::$DI['app'] with a new API application. * Sets self::$DI['app'] with a new API application.
*/ */
public function createAPIApplication() public function createAPIApplication($env = 'test')
{ {
self::deleteResources(); self::$DI['app'] = self::$DI->share(function () use ($env) {
self::$DI['app'] = self::$DI->share(function () { $environment = $env;
$environment = 'test';
$app = require __DIR__ . '/../../lib/Alchemy/Phrasea/Application/Api.php'; $app = require __DIR__ . '/../../lib/Alchemy/Phrasea/Application/Api.php';
$app['debug'] = true; $app['debug'] = true;
$app['session.test'] = true;
$app['EM'] = $app->share($app->extend('EM', function ($em) { $app['EM'] = $app->share($app->extend('EM', function ($em) {
$this::initializeSqliteDB(); $this::initializeSqliteDB();
@@ -242,12 +244,12 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
} }
/** /**
* Sets self::$DI['app'] with a new Phraseanet application. * Sets $app with a new Phraseanet application.
*/ */
public function createRootApplication() public function createRootApplication($env = 'test')
{ {
self::$DI['app'] = self::$DI->share(function ($DI) { self::$DI['app'] = self::$DI->share(function ($DI) use ($env) {
$environment = 'test'; $environment = $env;
$app = require __DIR__ . '/../../lib/Alchemy/Phrasea/Application/Root.php'; $app = require __DIR__ . '/../../lib/Alchemy/Phrasea/Application/Root.php';
$app['form.csrf_provider'] = $app->share(function () { $app['form.csrf_provider'] = $app->share(function () {
@@ -262,6 +264,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
})); }));
$app['debug'] = true; $app['debug'] = true;
$app['session.test'] = true;
$app['EM'] = $app->share($app->extend('EM', function ($em) { $app['EM'] = $app->share($app->extend('EM', function ($em) {
$this::initializeSqliteDB(); $this::initializeSqliteDB();
@@ -270,7 +273,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
})); }));
$app['browser'] = $app->share($app->extend('browser', function ($browser) { $app['browser'] = $app->share($app->extend('browser', function ($browser) {
$browser->setUserAgent(PhraseanetPHPUnitAbstract::USER_AGENT_FIREFOX8MAC); $browser->setUserAgent(PhraseanetPHPUnitAbstract::USER_AGENT_FIREFOX8MAC);
return $browser; return $browser;
@@ -296,10 +298,10 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* Sets self::$DI['app'] with a new CLI application. * Sets self::$DI['app'] with a new CLI application.
*/ */
public function createCLIApplication() public function createCLIApplication($env = 'test')
{ {
self::$DI['cli'] = self::$DI->share(function ($DI) { self::$DI['cli'] = self::$DI->share(function ($DI) use ($env) {
$app = new CLI('cli test', null, 'test'); $app = new CLI('cli test', null, $env);
$app['form.csrf_provider'] = $app->share(function () { $app['form.csrf_provider'] = $app->share(function () {
return new CsrfTestProvider(); return new CsrfTestProvider();
@@ -313,6 +315,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
})); }));
$app['debug'] = true; $app['debug'] = true;
$app['session.test'] = true;
$app['EM'] = $app->share($app->extend('EM', function ($em) { $app['EM'] = $app->share($app->extend('EM', function ($em) {
$this::initializeSqliteDb(); $this::initializeSqliteDb();
@@ -338,6 +341,10 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
return $app; return $app;
}); });
self::createSetOfUserTests(self::$DI['app']);
self::setCollection(self::$DI['app']);
self::generateRecords(self::$DI['app']);
} }
/** /**
@@ -379,6 +386,30 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
set_time_limit(0); set_time_limit(0);
} }
/**
* Delete all resources created during the test.
*/
public function __destruct()
{
self::deleteResources();
if (self::$time_start) {
self::$time_start = null;
}
}
protected function setConnectionEnvironment($env)
{
self::$DI['app']['EM'] = self::$DI['app']->share(function (Application $app) use ($env) {
return EntityManager::create(
'prod' === $env ? $app['conf']->get(['main', 'database']) : $app['conf']->get(['main', 'database-test']),
$app['EM.config'],
$app['EM.events-manager']
);
});
}
protected function assertForbiddenResponse(Response $response) protected function assertForbiddenResponse(Response $response)
{ {
$this->assertEquals(403, $response->getStatusCode()); $this->assertEquals(403, $response->getStatusCode());
@@ -439,7 +470,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* Inserts one basket. * Inserts one basket.
* *
* @param User_Adapter $user * @param User $user
* *
* @return Basket * @return Basket
*/ */
@@ -459,20 +490,20 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* Inserts one feed. * Inserts one feed.
* *
* @param User_Adapter $user * @param User $user
* @param string|null $title * @param string|null $title
* @param bool $public * @param bool $public
* *
* @return Feed * @return Feed
*/ */
protected function insertOneFeed(\User_Adapter $user = null , $title = null, $public = false) protected function insertOneFeed(User $user = null , $title = null, $public = false)
{ {
$feed = new Feed(); $feed = new Feed();
$publisher = new FeedPublisher(); $publisher = new FeedPublisher();
$user = $user ?: self::$DI['user']; $user = $user ?: self::$DI['user'];
$publisher->setUsrId($user->get_id()); $publisher->setUser($user);
$publisher->setIsOwner(true); $publisher->setIsOwner(true);
$publisher->setFeed($feed); $publisher->setFeed($feed);
@@ -491,12 +522,12 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* Inserts one feed entry. * Inserts one feed entry.
* *
* @param User_Adapter $user * @param User $user
* @param bool $public * @param bool $public
* *
* @return FeedEntry * @return FeedEntry
*/ */
protected function insertOneFeedEntry(\User_Adapter $user = null, $public = false) protected function insertOneFeedEntry(User $user = null, $public = false)
{ {
$feed = $this->insertOneFeed($user, null, $public); $feed = $this->insertOneFeed($user, null, $public);
@@ -527,18 +558,18 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* Inserts one feed token. * Inserts one feed token.
* *
* @param Feed $feed * @param Feed $feed
* @param User_Adapter $user * @param User $user
* *
* @return FeedToken * @return FeedToken
*/ */
protected function insertOneFeedToken(Feed $feed, \User_Adapter $user = null) protected function insertOneFeedToken(Feed $feed, User $user = null)
{ {
$user = $user ?: self::$DI['user']; $user = $user ?: self::$DI['user'];
$token = new FeedToken(); $token = new FeedToken();
$token->setValue(self::$DI['app']['tokens']->generatePassword(12)); $token->setValue(self::$DI['app']['tokens']->generatePassword(12));
$token->setFeed($feed); $token->setFeed($feed);
$token->setUsrId($user->get_id()); $token->setUser($user);
$feed->addToken($token); $feed->addToken($token);
@@ -552,17 +583,17 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* Insert one aggregate token. * Insert one aggregate token.
* *
* @param User_Adapter $user * @param User $user
* *
* @return AggregateToken * @return AggregateToken
*/ */
protected function insertOneAggregateToken(\User_Adapter $user = null) protected function insertOneAggregateToken(User $user = null)
{ {
$user = $user ?: self::$DI['user']; $user = $user ?: self::$DI['user'];
$token = new AggregateToken(); $token = new AggregateToken();
$token->setValue(self::$DI['app']['tokens']->generatePassword(12)); $token->setValue(self::$DI['app']['tokens']->generatePassword(12));
$token->setUsrId($user->get_id()); $token->setUser($user);
self::$DI['app']['EM']->persist($token); self::$DI['app']['EM']->persist($token);
self::$DI['app']['EM']->flush(); self::$DI['app']['EM']->flush();
@@ -573,14 +604,14 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* Inserts one feed item. * Inserts one feed item.
* *
* @return \Alchemy\Phrasea\Model\Entities\FeedItem * @return FeedItem
*/ */
protected function insertOneFeedItem(\User_Adapter $user = null, $public = false, $qty = 1, \record_adapter $record = null) protected function insertOneFeedItem(User $user = null, $public = false, $qty = 1, \record_adapter $record = null)
{ {
$entry = $this->insertOneFeedEntry($user, $public); $entry = $this->insertOneFeedEntry($user, $public);
for ($i = 0; $i < $qty; $i++) { for ($i = 0; $i < $qty; $i++) {
$item = new \Alchemy\Phrasea\Model\Entities\FeedItem(); $item = new FeedItem();
$item->setEntry($entry); $item->setEntry($entry);
if (null === $record) { if (null === $record) {
@@ -606,16 +637,16 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* Inserts one lazaret file. * Inserts one lazaret file.
* *
* @param User_Adapter $user * @param User $user
* *
* @return LazaretFile * @return LazaretFile
*/ */
protected function insertOneLazaretFile(\User_Adapter $user = null) protected function insertOneLazaretFile(User $user = null)
{ {
$user = $user ?: self::$DI['user']; $user = $user ?: self::$DI['user'];
$lazaretSession = new LazaretSession(); $lazaretSession = new LazaretSession();
$lazaretSession->setUsrId($user->get_id()); $lazaretSession->setUser($user);
$lazaretSession->setUpdated(new \DateTime('now')); $lazaretSession->setUpdated(new \DateTime('now'));
$lazaretSession->setCreated(new \DateTime('-1 day')); $lazaretSession->setCreated(new \DateTime('-1 day'));
@@ -640,7 +671,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* Inserts one user list owner. * Inserts one user list owner.
* *
* @param User_Adapter $user * @param User $user
* *
* @return UsrListOwner * @return UsrListOwner
*/ */
@@ -661,11 +692,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* Inserts one user list. * Inserts one user list.
* *
* @param User_Adapter $user * @param User $user
* *
* @return UsrListOwner * @return UsrListOwner
*/ */
protected function insertOneUsrList(\User_Adapter $user = null) protected function insertOneUsrList(User $user = null)
{ {
$owner = $this->insertOneUsrListOwner($user); $owner = $this->insertOneUsrListOwner($user);
$list = new UsrList(); $list = new UsrList();
@@ -679,37 +710,15 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
return $list; return $list;
} }
/**
* Inserts one user list.
*
* @param User_Adapter $user
*
* @return UsrListOwner
*/
protected function insertOneUsrList(\User_Adapter $user = null)
{
$owner = $this->insertOneUsrListOwner($user);
$list = new UsrList();
$list->setName('new list');
$list->addOwner($owner);
$owner->setList($list);
self::$DI['app']['EM']->persist($list);
self::$DI['app']['EM']->flush();
return $list;
}
/** /**
* Insert one user list entry. * Insert one user list entry.
* *
* @param User_adapter $owner * @param User $owner
* @param User_adapter $user * @param User $user
* *
* @return UsrListEntry * @return UsrListEntry
*/ */
protected function insertOneUsrListEntry(\User_adapter $owner, \User_adapter $user) protected function insertOneUsrListEntry(User $owner, User $user)
{ {
$list = $this->insertOneUsrList($owner); $list = $this->insertOneUsrList($owner);
@@ -733,26 +742,26 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
*/ */
protected function insertFiveBasket() protected function insertFiveBasket()
{ {
try { $baskets = [];
$basketFixture = new PhraseaFixture\Basket\LoadFiveBaskets();
$basketFixture->setUser(self::$DI['user']); for ($i = 0; $i < 5; $i ++) {
$basket = new Basket();
$basket->setName('test ' . $i);
$basket->setDescription('description');
$basket->setUser(self::$DI['user']);
$loader = new Loader(); self::$DI['app']['EM']->persist($basket);
$loader->addFixture($basketFixture); $baskets[] = $basket;
$this->insertFixtureInDatabase($loader);
return $basketFixture->baskets;
} catch (\Exception $e) {
$this->fail('Fail load five Basket : ' . $e->getMessage());
} }
self::$DI['app']['EM']->flush();
return $baskets;
} }
/** /**
* Inserts one basket element. * Inserts one basket element.
* *
* @param User_Adapter $user * @param User $user
* @param record_adapter $record * @param record_adapter $record
* *
* @return BasketElement * @return BasketElement
@@ -867,12 +876,12 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/** /**
* Inserts one story. * Inserts one story.
* *
* @param User_Adapter $user * @param User $user
* @param record_adapter $record * @param record_adapter $record
* *
* @return StoryWZ * @return StoryWZ
*/ */
protected function insertOneStory(User_Adapter $user = null, \record_adapter $record = null) protected function insertOneStory(User $user = null, \record_adapter $record = null)
{ {
$story = new StoryWZ(); $story = new StoryWZ();
@@ -889,11 +898,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* Inserts one validation session. * Inserts one validation session.
* *
* @param Basket $basket * @param Basket $basket
* @param User_Adapter $user * @param User $user
* *
* @return ValidationSession * @return ValidationSession
*/ */
protected function insertOneValidationSession(Basket $basket = null, \User_Adapter $user = null) protected function insertOneValidationSession(Basket $basket = null, User $user = null)
{ {
$validationSession = new ValidationSession(); $validationSession = new ValidationSession();
@@ -994,52 +1003,38 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* self::$DI['user_alt1'] * self::$DI['user_alt1']
* self::$DI['user_alt2'] * self::$DI['user_alt2']
*/ */
private static function createSetOfUserTests(Application $application) public static function createSetOfUserTests(Application $application)
{ {
self::$DI['user'] = self::$DI->share(function ($DI) use ($application) { self::$DI['user'] = self::$DI->share(function ($DI) use ($application) {
$usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit'); if (null === $user = self::$DI['app']['manipulator.user']->getRepository()->findByLogin('test_phpunit')) {
$user = self::$DI['app']['manipulator.user']->createUser('test_phpunit', 'test_phpunit', 'noone@example.com', true);
if (!$usr_id) {
$user = User_Adapter::create($application, 'test_phpunit', random::generatePassword(), 'noone@example.com', false);
$usr_id = $user->get_id();
} }
$user = User_Adapter::getInstance($usr_id, $application);
return $user; return $user;
}); });
self::$DI['user_notAdmin'] = self::$DI->share(function () use ($application) { self::$DI['user_notAdmin'] = self::$DI->share(function () use ($application) {
$usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit_not_admin'); if (null === $user = self::$DI['app']['manipulator.user']->getRepository()->findByLogin('test_phpunit_not_admin')) {
$user = self::$DI['app']['manipulator.user']->createUser('test_phpunit_not_admin', 'test_phpunit_not_admin', 'noone_not_admin@example.com');
if (!$usr_id) {
$user = User_Adapter::create($application, 'test_phpunit_not_admin', random::generatePassword(), 'noone_not_admin@example.com', false);
$usr_id = $user->get_id();
} }
return User_Adapter::getInstance($usr_id, $application); return $user;
}); });
self::$DI['user_alt1'] = self::$DI->share(function () use ($application) { self::$DI['user_alt1'] = self::$DI->share(function () use ($application) {
$usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit_alt1'); if (null === $user = self::$DI['app']['manipulator.user']->getRepository()->findByLogin('test_phpunit_alt1')) {
$user = self::$DI['app']['manipulator.user']->createUser('test_phpunit_alt1', 'test_phpunit_alt1', 'noonealt1@example.com');
if (!$usr_id) {
$user = User_Adapter::create($application, 'test_phpunit_alt1', random::generatePassword(), 'noonealt1@example.com', false);
$usr_id = $user->get_id();
} }
return User_Adapter::getInstance($usr_id, $application); return $user;
}); });
self::$DI['user_alt2'] = self::$DI->share(function () use ($application) { self::$DI['user_alt2'] = self::$DI->share(function () use ($application) {
$usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit_alt2'); if (null === $user = self::$DI['app']['manipulator.user']->getRepository()->findByLogin('test_phpunit_alt2')) {
$user = self::$DI['app']['manipulator.user']->createUser('test_phpunit_alt2', 'test_phpunit_alt2', 'noonealt2@example.com');
if (!$usr_id) {
$user = User_Adapter::create($application, 'test_phpunit_alt2', random::generatePassword(), 'noonealt2@example.com', false);
$usr_id = $user->get_id();
} }
return User_Adapter::getInstance($usr_id, $application); return $user;
}); });
} }
@@ -1048,7 +1043,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* *
* @param \User_Adapter $user * @param \User_Adapter $user
*/ */
public static function giveRightsToUser(Application $app, \User_Adapter $user) public static function giveRightsToUser(Application $app, $user)
{ {
$app['acl']->get($user)->give_access_to_sbas(array_keys($app['phraseanet.appbox']->get_databoxes())); $app['acl']->get($user)->give_access_to_sbas(array_keys($app['phraseanet.appbox']->get_databoxes()));
@@ -1101,6 +1096,10 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
*/ */
private static function setCollection(Application $application) private static function setCollection(Application $application)
{ {
if (self::$collectionsInitialized) {
return;
}
$coll = $collection_no_acces = $collection_no_acces_by_status = $db = null; $coll = $collection_no_acces = $collection_no_acces_by_status = $db = null;
foreach ($application['phraseanet.appbox']->get_databoxes() as $databox) { foreach ($application['phraseanet.appbox']->get_databoxes() as $databox) {
@@ -1134,15 +1133,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$collection_no_acces = collection::create($application, $databox, $application['phraseanet.appbox'], 'BIBOO', $DI['user']); $collection_no_acces = collection::create($application, $databox, $application['phraseanet.appbox'], 'BIBOO', $DI['user']);
} }
$DI['user'] = $DI->share( $application['acl']->get($DI['user'])->revoke_access_from_bases([$collection_no_acces->get_base_id()]);
$DI->extend('user', function ($user, $DI) use ($collection_no_acces) {
$DI['app']['acl']->get($user)->revoke_access_from_bases([$collection_no_acces->get_base_id()]);
return $user;
})
);
$DI['user'];
return $collection_no_acces; return $collection_no_acces;
}); });
@@ -1174,59 +1165,61 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
*/ */
protected static function generateRecords(Application $app) protected static function generateRecords(Application $app)
{ {
if (self::$recordsInitialized === false) { if (self::$recordsInitialized) {
$logger = new \Monolog\Logger('tests'); return;
$logger->pushHandler(new \Monolog\Handler\NullHandler()); }
self::$recordsInitialized = [];
$resolvePathfile = function ($i) { $logger = new \Monolog\Logger('tests');
$finder = new Symfony\Component\Finder\Finder(); $logger->pushHandler(new \Monolog\Handler\NullHandler());
self::$recordsInitialized = [];
$name = $i < 10 ? 'test00' . $i . '.*' : 'test0' . $i . '.*'; $resolvePathfile = function ($i) {
$finder = new Symfony\Component\Finder\Finder();
$finder->name($name)->in(__DIR__ . '/../files/'); $name = $i < 10 ? 'test00' . $i . '.*' : 'test0' . $i . '.*';
foreach ($finder as $file) { $finder->name($name)->in(__DIR__ . '/../files/');
return $file;
}
throw new Exception(sprintf('File %d not found', $i)); foreach ($finder as $file) {
}; return $file;
foreach (range(1, 24) as $i) {
self::$DI['record_' . $i] = self::$DI->share(function ($DI) use ($logger, $resolvePathfile, $i) {
PhraseanetPHPUnitAbstract::$recordsInitialized[] = $i;
$file = new File($DI['app'], $DI['app']['mediavorus']->guess($resolvePathfile($i)->getPathname()), $DI['collection']);
$record = record_adapter::createFromFile($file, $DI['app']);
$record->generate_subdefs($record->get_databox(), $DI['app']);
return $record;
});
} }
foreach (range(1, 2) as $i) { throw new Exception(sprintf('File %d not found', $i));
self::$DI['record_story_' . $i] = self::$DI->share(function ($DI) use ($i) { };
PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'story_' . $i;
return record_adapter::createStory($DI['app'], $DI['collection']); foreach (range(1, 24) as $i) {
}); self::$DI['record_' . $i] = self::$DI->share(function ($DI) use ($logger, $resolvePathfile, $i) {
} PhraseanetPHPUnitAbstract::$recordsInitialized[] = $i;
$file = new File($DI['app'], $DI['app']['mediavorus']->guess($resolvePathfile($i)->getPathname()), $DI['collection']);
$record = record_adapter::createFromFile($file, $DI['app']);
$record->generate_subdefs($record->get_databox(), $DI['app']);
self::$DI['record_no_access'] = self::$DI->share(function ($DI) { return $record;
PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access';
$file = new File($DI['app'], $DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), $DI['collection_no_access']);
return \record_adapter::createFromFile($file, $DI['app']);
});
self::$DI['record_no_access_by_status'] = self::$DI->share(function ($DI) {
PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access_by_status';
$file = new File($DI['app'], $DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), $DI['collection_no_access']);
return \record_adapter::createFromFile($file, $DI['app']);
}); });
} }
foreach (range(1, 2) as $i) {
self::$DI['record_story_' . $i] = self::$DI->share(function ($DI) use ($i) {
PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'story_' . $i;
return record_adapter::createStory($DI['app'], $DI['collection']);
});
}
self::$DI['record_no_access'] = self::$DI->share(function ($DI) {
PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access';
$file = new File($DI['app'], $DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), $DI['collection_no_access']);
return \record_adapter::createFromFile($file, $DI['app']);
});
self::$DI['record_no_access_by_status'] = self::$DI->share(function ($DI) {
PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access_by_status';
$file = new File($DI['app'], $DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), $DI['collection_no_access']);
return \record_adapter::createFromFile($file, $DI['app']);
});
return; return;
} }

View File

@@ -18,14 +18,12 @@ class collectionTest extends \PhraseanetAuthenticatedTestCase
{ {
$application = self::$DI['app']; $application = self::$DI['app'];
self::$DI['user'];
if (!self::$object) { if (!self::$object) {
if (0 === count(self::$DI['app']['phraseanet.appbox']->get_databoxes())) { if (0 === count($databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes())) {
$this->fail('No databox found for collection test'); $this->fail('No databox found for collection test');
} }
$databox = array_shift(self::$DI['app']['phraseanet.appbox']->get_databoxes()); $databox = array_shift($databoxes);
self::$object = collection::create( self::$object = collection::create(
self::$DI['app'], self::$DI['app'],

View File

@@ -1,38 +1,29 @@
<?php <?php
use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\UsrAuthProvider;
class userTest extends \PhraseanetTestCase class userTest extends \PhraseanetTestCase
{ {
public function testMail() public function testMail()
{ {
$this->assertNull(self::$DI['app']['manipulator.user']->getRepository()->findByEmail(null));
try {
self::$DI['user']->setEmail(null);
$this->assertNull(self::$DI['app']['manipulator.user']->getRepository()->findByEmail(null));
self::$DI['user']->setEmail(''); self::$DI['user']->setEmail('');
$this->assertNull(self::$DI['app']['manipulator.user']->getRepository()->findByEmail(null)); $this->assertNull(self::$DI['app']['manipulator.user']->getRepository()->findByEmail(self::$DI['user']->getEmail()));
self::$DI['user']->setEmail('noone@example.com'); self::$DI['user']->setEmail('noone@example.com');
$this->assertEquals(self::$DI['user'], self::$DI['app']['manipulator.user']->getRepository()->findByEmail('noone@example.com')); $this->assertEquals(self::$DI['user'], self::$DI['app']['manipulator.user']->getRepository()->findByEmail('noone@example.com'));
} catch (Exception $e) {
$this->fail($e->getMessage());
}
try { try {
self::$DI['user']->setEmail('noonealt1@example.com'); self::$DI['user']->setEmail('noonealt1@example.com');
$this->fail('A user already got this address'); $this->fail('A user already got this address');
} catch (Exception $e) { } catch (Exception $e) {
} }
$this->assertNull(self::$DI['app']['manipulator.user']->getRepository()->findByEmail(null));
} }
public function testDeleteSetMailToNullAndRemovesProviders() public function testDeleteSetMailToNullAndRemovesProviders()
{ {
if (null === $user = self::$DI['app']['manipulator.user']->getRepository()->findByLogin('test_phpunit_providers')) { $user = self::$DI['app']['manipulator.user']->createUser('test_phpunit_providers', 'any');
$user = self::$DI['app']['manipulator.user']->createUser('test_phpunit_providers', 'any');
}
$provider = new Alchemy\Phrasea\Model\Entities\UsrAuthProvider(); $provider = new UsrAuthProvider();
$provider->setDistantId(12345); $provider->setDistantId(12345);
$provider->setProvider('custom-one'); $provider->setProvider('custom-one');
$provider->setUser($user); $provider->setUser($user);
@@ -42,8 +33,7 @@ class userTest extends \PhraseanetTestCase
self::$DI['app']['model.user-manager']->delete($user); self::$DI['app']['model.user-manager']->delete($user);
$repo = self::$DI['app']['EM']->getRepository('Phraseanet:UsrAuthProvider'); $this->assertNull(self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\UsrAuthProvider')->findWithProviderAndId('custom-one', 12345));
$this->assertNull($repo->findWithProviderAndId('custom-one', 12345));
} }
public function testDeleteSetMailToNullAndRemovesSessions() public function testDeleteSetMailToNullAndRemovesSessions()
@@ -71,7 +61,7 @@ class userTest extends \PhraseanetTestCase
public function testGetPref() public function testGetPref()
{ {
$user = $this->get_user(); $user = self::$DI['app']['manipulator.user']->createUser('notif_ref_test', 'pass');
$this->assertNull($user->getSettingValue('lalala')); $this->assertNull($user->getSettingValue('lalala'));
$this->assertSame('popo', $user->getSettingValue('lalala', 'popo')); $this->assertSame('popo', $user->getSettingValue('lalala', 'popo'));
@@ -80,6 +70,8 @@ class userTest extends \PhraseanetTestCase
public function testGetPrefWithACustomizedConf() public function testGetPrefWithACustomizedConf()
{ {
$user = self::$DI['app']['manipulator.user']->createUser('notif_ref_test', 'pass');
$data = self::$DI['app']['conf']->get(['user-settings']); $data = self::$DI['app']['conf']->get(['user-settings']);
self::$DI['app']['conf']->set('user-settings', [ self::$DI['app']['conf']->set('user-settings', [
@@ -105,7 +97,7 @@ class userTest extends \PhraseanetTestCase
public function testSetPref() public function testSetPref()
{ {
$user = $this->get_user(); $user = self::$DI['app']['manipulator.user']->createUser('notif_ref_test', 'pass');
$user->setSettingValue('prout', 'pooop'); $user->setSettingValue('prout', 'pooop');
$this->assertSame('pooop', $user->getSettingValue('prout')); $this->assertSame('pooop', $user->getSettingValue('prout'));
@@ -113,28 +105,19 @@ class userTest extends \PhraseanetTestCase
public function testGetNotificationPref() public function testGetNotificationPref()
{ {
$user = $this->get_user(); $user = self::$DI['app']['manipulator.user']->createUser('notif_ref_test', 'pass');
$this->assertSame('1', $user->getNotificationSettingValue('eventsmanager_notify_push')); $this->assertTrue($user->getNotificationSettingValue('eventsmanager_notify_push'));
} }
public function testNotificationPref() public function testNotificationPref()
{ {
$user = $this->get_user(); $user = self::$DI['app']['manipulator.user']->createUser('notif_ref_test', 'pass');
$this->assertSame('1', $user->getNotificationSettingValue('eventsmanager_notify_push')); $this->assertTrue($user->getNotificationSettingValue('eventsmanager_notify_push'));
$user->setNotificationSettingValue('eventsmanager_notify_push', false); $user->setNotificationSettingValue('eventsmanager_notify_push', false);
$this->assertSame('0', $user->getNotificationSettingValue('eventsmanager_notify_push')); $this->assertFalse($user->getNotificationSettingValue('eventsmanager_notify_push'));
$user->setNotificationSettingValue('eventsmanager_notify_push', true); $user->setNotificationSettingValue('eventsmanager_notify_push', true);
$this->assertSame('1', $user->getNotificationSettingValue('eventsmanager_notify_push')); $this->assertTrue($user->getNotificationSettingValue('eventsmanager_notify_push'));
}
private function get_user()
{
if (null !== $user = self::$DI['app']['manipulator.user']->getRepository()->findByLogin('notif_ref_test')) {
self::$DI['app']['model.user-manager']->delete($user);
}
return self::$DI['app']['manipulator.user']->create('notif_ref_test', mt_rand(), null, false);
} }
} }

View File

@@ -64,10 +64,10 @@ class AggregateToken extends \Alchemy\Phrasea\Model\Entities\AggregateToken impl
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usrId', 'value'); return array('__isInitialized__', 'id', 'user', 'value');
} }
return array('__isInitialized__', 'id', 'usrId', 'value'); return array('__isInitialized__', 'id', 'user', 'value');
} }
/** /**
@@ -191,23 +191,23 @@ class AggregateToken extends \Alchemy\Phrasea\Model\Entities\AggregateToken impl
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUsrId($usrId) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
return parent::setUsrId($usrId); return parent::setUser($user);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getUsrId() public function getUser()
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array()); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUsrId(); return parent::getUser();
} }
/** /**

View File

@@ -64,10 +64,10 @@ class Basket extends \Alchemy\Phrasea\Model\Entities\Basket implements \Doctrine
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'name', 'description', 'usr_id', 'is_read', 'pusher_id', 'archived', 'created', 'updated', 'validation', 'elements', 'order'); return array('__isInitialized__', 'id', 'name', 'description', 'user', 'is_read', 'pusher_id', 'archived', 'created', 'updated', 'validation', 'elements', 'order', 'pusher');
} }
return array('__isInitialized__', 'id', 'name', 'description', 'usr_id', 'is_read', 'pusher_id', 'archived', 'created', 'updated', 'validation', 'elements', 'order'); return array('__isInitialized__', 'id', 'name', 'description', 'user', 'is_read', 'pusher_id', 'archived', 'created', 'updated', 'validation', 'elements', 'order', 'pusher');
} }
/** /**
@@ -235,45 +235,23 @@ class Basket extends \Alchemy\Phrasea\Model\Entities\Basket implements \Doctrine
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUsrId($usrId) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
return parent::setUsrId($usrId); return parent::setUser($user);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getUsrId() public function getUser()
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array()); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUsrId(); return parent::getUser();
}
/**
* {@inheritDoc}
*/
public function setOwner(\User_Adapter $user)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setOwner', array($user));
return parent::setOwner($user);
}
/**
* {@inheritDoc}
*/
public function getOwner(\Alchemy\Phrasea\Application $app)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getOwner', array($app));
return parent::getOwner($app);
} }
/** /**
@@ -323,7 +301,7 @@ class Basket extends \Alchemy\Phrasea\Model\Entities\Basket implements \Doctrine
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setPusher(\User_Adapter $user) public function setPusher(\Alchemy\Phrasea\Model\Entities\User $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setPusher', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setPusher', array($user));

View File

@@ -389,7 +389,7 @@ class BasketElement extends \Alchemy\Phrasea\Model\Entities\BasketElement implem
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getUserValidationDatas(\User_Adapter $user, \Alchemy\Phrasea\Application $app) public function getUserValidationDatas(\Alchemy\Phrasea\Model\Entities\User $user, \Alchemy\Phrasea\Application $app)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUserValidationDatas', array($user, $app)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUserValidationDatas', array($user, $app));

View File

@@ -356,7 +356,7 @@ class Feed extends \Alchemy\Phrasea\Model\Entities\Feed implements \Doctrine\ORM
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function isOwner(\User_Adapter $user) public function isOwner(\Alchemy\Phrasea\Model\Entities\User $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'isOwner', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'isOwner', array($user));
@@ -433,7 +433,7 @@ class Feed extends \Alchemy\Phrasea\Model\Entities\Feed implements \Doctrine\ORM
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function isPublisher(\User_Adapter $user) public function isPublisher(\Alchemy\Phrasea\Model\Entities\User $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'isPublisher', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'isPublisher', array($user));
@@ -444,7 +444,7 @@ class Feed extends \Alchemy\Phrasea\Model\Entities\Feed implements \Doctrine\ORM
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getPublisher(\User_Adapter $user) public function getPublisher(\Alchemy\Phrasea\Model\Entities\User $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getPublisher', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPublisher', array($user));
@@ -499,7 +499,7 @@ class Feed extends \Alchemy\Phrasea\Model\Entities\Feed implements \Doctrine\ORM
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function hasAccess(\User_Adapter $user, \Alchemy\Phrasea\Application $app) public function hasAccess(\Alchemy\Phrasea\Model\Entities\User $user, \Alchemy\Phrasea\Application $app)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'hasAccess', array($user, $app)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'hasAccess', array($user, $app));
@@ -576,7 +576,7 @@ class Feed extends \Alchemy\Phrasea\Model\Entities\Feed implements \Doctrine\ORM
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function isAccessible(\User_Adapter $user, \Alchemy\Phrasea\Application $app) public function isAccessible(\Alchemy\Phrasea\Model\Entities\User $user, \Alchemy\Phrasea\Application $app)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'isAccessible', array($user, $app)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'isAccessible', array($user, $app));

View File

@@ -400,7 +400,7 @@ class FeedEntry extends \Alchemy\Phrasea\Model\Entities\FeedEntry implements \Do
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function isPublisher(\User_Adapter $user) public function isPublisher(\Alchemy\Phrasea\Model\Entities\User $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'isPublisher', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'isPublisher', array($user));

View File

@@ -64,10 +64,10 @@ class FeedPublisher extends \Alchemy\Phrasea\Model\Entities\FeedPublisher implem
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usrId', 'owner', 'createdOn', 'feed'); return array('__isInitialized__', 'id', 'user', 'owner', 'createdOn', 'feed');
} }
return array('__isInitialized__', 'id', 'usrId', 'owner', 'createdOn', 'feed'); return array('__isInitialized__', 'id', 'user', 'owner', 'createdOn', 'feed');
} }
/** /**
@@ -191,23 +191,23 @@ class FeedPublisher extends \Alchemy\Phrasea\Model\Entities\FeedPublisher implem
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUsrId($usrId) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
return parent::setUsrId($usrId); return parent::setUser($user);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getUsrId() public function getUser()
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array()); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUsrId(); return parent::getUser();
} }
/** /**
@@ -254,17 +254,6 @@ class FeedPublisher extends \Alchemy\Phrasea\Model\Entities\FeedPublisher implem
return parent::getFeed(); return parent::getFeed();
} }
/**
* {@inheritDoc}
*/
public function getUser(\Alchemy\Phrasea\Application $app)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app));
return parent::getUser($app);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@@ -64,10 +64,10 @@ class FeedToken extends \Alchemy\Phrasea\Model\Entities\FeedToken implements \Do
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usrId', 'value', 'feed'); return array('__isInitialized__', 'id', 'user', 'value', 'feed');
} }
return array('__isInitialized__', 'id', 'usrId', 'value', 'feed'); return array('__isInitialized__', 'id', 'user', 'value', 'feed');
} }
/** /**
@@ -191,23 +191,23 @@ class FeedToken extends \Alchemy\Phrasea\Model\Entities\FeedToken implements \Do
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUsrId($usrId) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
return parent::setUsrId($usrId); return parent::setUser($user);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getUsrId() public function getUser()
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array()); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUsrId(); return parent::getUser();
} }
/** /**

View File

@@ -64,10 +64,10 @@ class FtpCredential extends \Alchemy\Phrasea\Model\Entities\FtpCredential implem
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usrId', 'user', 'active', 'address', 'login', 'password', 'receptionFolder', 'repositoryPrefixName', 'passive', 'ssl', 'maxRetry', 'updated'); return array('__isInitialized__', 'id', 'user', 'active', 'address', 'login', 'password', 'receptionFolder', 'repositoryPrefixName', 'passive', 'ssl', 'maxRetry', 'updated');
} }
return array('__isInitialized__', 'id', 'usrId', 'user', 'active', 'address', 'login', 'password', 'receptionFolder', 'repositoryPrefixName', 'passive', 'ssl', 'maxRetry', 'updated'); return array('__isInitialized__', 'id', 'user', 'active', 'address', 'login', 'password', 'receptionFolder', 'repositoryPrefixName', 'passive', 'ssl', 'maxRetry', 'updated');
} }
/** /**
@@ -188,28 +188,6 @@ class FtpCredential extends \Alchemy\Phrasea\Model\Entities\FtpCredential implem
return parent::getId(); return parent::getId();
} }
/**
* {@inheritDoc}
*/
public function getUsrId()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array());
return parent::getUsrId();
}
/**
* {@inheritDoc}
*/
public function setUsrId($usrId)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId));
return parent::setUsrId($usrId);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -224,7 +202,7 @@ class FtpCredential extends \Alchemy\Phrasea\Model\Entities\FtpCredential implem
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUser(\Alchemy\Phrasea\Model\Entities\User $user) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));

View File

@@ -64,10 +64,10 @@ class FtpExport extends \Alchemy\Phrasea\Model\Entities\FtpExport implements \Do
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'crash', 'nbretry', 'mail', 'addr', 'ssl', 'login', 'pwd', 'passif', 'destfolder', 'sendermail', 'textMailSender', 'textMailReceiver', 'usrId', 'foldertocreate', 'logfile', 'elements', 'created', 'updated'); return array('__isInitialized__', 'id', 'crash', 'nbretry', 'mail', 'addr', 'ssl', 'login', 'pwd', 'passif', 'destfolder', 'sendermail', 'textMailSender', 'textMailReceiver', 'user', 'foldertocreate', 'logfile', 'elements', 'created', 'updated');
} }
return array('__isInitialized__', 'id', 'crash', 'nbretry', 'mail', 'addr', 'ssl', 'login', 'pwd', 'passif', 'destfolder', 'sendermail', 'textMailSender', 'textMailReceiver', 'usrId', 'foldertocreate', 'logfile', 'elements', 'created', 'updated'); return array('__isInitialized__', 'id', 'crash', 'nbretry', 'mail', 'addr', 'ssl', 'login', 'pwd', 'passif', 'destfolder', 'sendermail', 'textMailSender', 'textMailReceiver', 'user', 'foldertocreate', 'logfile', 'elements', 'created', 'updated');
} }
/** /**
@@ -188,6 +188,28 @@ class FtpExport extends \Alchemy\Phrasea\Model\Entities\FtpExport implements \Do
return parent::getId(); return parent::getId();
} }
/**
* {@inheritDoc}
*/
public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
return parent::setUser($user);
}
/**
* {@inheritDoc}
*/
public function getUser()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUser();
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -463,50 +485,6 @@ class FtpExport extends \Alchemy\Phrasea\Model\Entities\FtpExport implements \Do
return parent::getTextMailReceiver(); return parent::getTextMailReceiver();
} }
/**
* {@inheritDoc}
*/
public function setUsrId($usrId)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId));
return parent::setUsrId($usrId);
}
/**
* {@inheritDoc}
*/
public function getUsrId()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array());
return parent::getUsrId();
}
/**
* {@inheritDoc}
*/
public function getUser(\Alchemy\Phrasea\Application $app)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app));
return parent::getUser($app);
}
/**
* {@inheritDoc}
*/
public function setUser(\User_Adapter $user)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
return parent::setUser($user);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@@ -64,10 +64,10 @@ class LazaretSession extends \Alchemy\Phrasea\Model\Entities\LazaretSession impl
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usr_id', 'created', 'updated', 'files'); return array('__isInitialized__', 'id', 'user', 'created', 'updated', 'files');
} }
return array('__isInitialized__', 'id', 'usr_id', 'created', 'updated', 'files'); return array('__isInitialized__', 'id', 'user', 'created', 'updated', 'files');
} }
/** /**
@@ -191,34 +191,23 @@ class LazaretSession extends \Alchemy\Phrasea\Model\Entities\LazaretSession impl
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUsrId($usrId) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
return parent::setUsrId($usrId); return parent::setUser($user);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getUsrId() public function getUser()
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array()); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUsrId(); return parent::getUser();
}
/**
* {@inheritDoc}
*/
public function getUser(\Alchemy\Phrasea\Application $app)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app));
return parent::getUser($app);
} }
/** /**

View File

@@ -64,10 +64,10 @@ class Order extends \Alchemy\Phrasea\Model\Entities\Order implements \Doctrine\O
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usrId', 'orderUsage', 'todo', 'deadline', 'createdOn', 'elements', 'basket'); return array('__isInitialized__', 'id', 'user', 'orderUsage', 'todo', 'deadline', 'createdOn', 'elements', 'basket');
} }
return array('__isInitialized__', 'id', 'usrId', 'orderUsage', 'todo', 'deadline', 'createdOn', 'elements', 'basket'); return array('__isInitialized__', 'id', 'user', 'orderUsage', 'todo', 'deadline', 'createdOn', 'elements', 'basket');
} }
/** /**
@@ -191,23 +191,23 @@ class Order extends \Alchemy\Phrasea\Model\Entities\Order implements \Doctrine\O
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUsrId($usrId) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
return parent::setUsrId($usrId); return parent::setUser($user);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getUsrId() public function getUser()
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array()); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUsrId(); return parent::getUser();
} }
/** /**
@@ -287,17 +287,6 @@ class Order extends \Alchemy\Phrasea\Model\Entities\Order implements \Doctrine\O
return parent::getElements(); return parent::getElements();
} }
/**
* {@inheritDoc}
*/
public function getUser(\Alchemy\Phrasea\Application $app)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app));
return parent::getUser($app);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@@ -64,10 +64,10 @@ class Session extends \Alchemy\Phrasea\Model\Entities\Session implements \Doctri
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usr_id', 'user_agent', 'ip_address', 'platform', 'browser_name', 'browser_version', 'screen_width', 'screen_height', 'token', 'nonce', 'created', 'updated', 'modules'); return array('__isInitialized__', 'id', 'user', 'user_agent', 'ip_address', 'platform', 'browser_name', 'browser_version', 'screen_width', 'screen_height', 'token', 'nonce', 'created', 'updated', 'modules');
} }
return array('__isInitialized__', 'id', 'usr_id', 'user_agent', 'ip_address', 'platform', 'browser_name', 'browser_version', 'screen_width', 'screen_height', 'token', 'nonce', 'created', 'updated', 'modules'); return array('__isInitialized__', 'id', 'user', 'user_agent', 'ip_address', 'platform', 'browser_name', 'browser_version', 'screen_width', 'screen_height', 'token', 'nonce', 'created', 'updated', 'modules');
} }
/** /**
@@ -191,7 +191,7 @@ class Session extends \Alchemy\Phrasea\Model\Entities\Session implements \Doctri
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUser(\User_Adapter $user) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
@@ -202,34 +202,12 @@ class Session extends \Alchemy\Phrasea\Model\Entities\Session implements \Doctri
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUsrId($usrId) public function getUser()
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::setUsrId($usrId); return parent::getUser();
}
/**
* {@inheritDoc}
*/
public function getUser(\Alchemy\Phrasea\Application $app)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app));
return parent::getUser($app);
}
/**
* {@inheritDoc}
*/
public function getUsrId()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array());
return parent::getUsrId();
} }
/** /**

View File

@@ -64,10 +64,10 @@ class StoryWZ extends \Alchemy\Phrasea\Model\Entities\StoryWZ implements \Doctri
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'sbas_id', 'record_id', 'usr_id', 'created'); return array('__isInitialized__', 'id', 'sbas_id', 'record_id', 'user', 'created');
} }
return array('__isInitialized__', 'id', 'sbas_id', 'record_id', 'usr_id', 'created'); return array('__isInitialized__', 'id', 'sbas_id', 'record_id', 'user', 'created');
} }
/** /**
@@ -257,29 +257,7 @@ class StoryWZ extends \Alchemy\Phrasea\Model\Entities\StoryWZ implements \Doctri
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUsrId($usrId) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId));
return parent::setUsrId($usrId);
}
/**
* {@inheritDoc}
*/
public function getUsrId()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array());
return parent::getUsrId();
}
/**
* {@inheritDoc}
*/
public function setUser(\User_Adapter $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
@@ -290,12 +268,12 @@ class StoryWZ extends \Alchemy\Phrasea\Model\Entities\StoryWZ implements \Doctri
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getUser(\Alchemy\Phrasea\Application $app) public function getUser()
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUser($app); return parent::getUser();
} }
/** /**

View File

@@ -1013,17 +1013,6 @@ class User extends \Alchemy\Phrasea\Model\Entities\User implements \Doctrine\ORM
return parent::getSettings(); return parent::getSettings();
} }
/**
* {@inheritDoc}
*/
public function getSettingValue($name, $default = NULL)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getSettingValue', array($name, $default));
return parent::getSettingValue($name, $default);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -1035,6 +1024,17 @@ class User extends \Alchemy\Phrasea\Model\Entities\User implements \Doctrine\ORM
return parent::addSetting($setting); return parent::addSetting($setting);
} }
/**
* {@inheritDoc}
*/
public function setSettingValue($name, $value)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setSettingValue', array($name, $value));
return parent::setSettingValue($name, $value);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@@ -1057,6 +1057,28 @@ class User extends \Alchemy\Phrasea\Model\Entities\User implements \Doctrine\ORM
return parent::addNotificationSettings($notificationSetting); return parent::addNotificationSettings($notificationSetting);
} }
/**
* {@inheritDoc}
*/
public function setNotificationSettingValue($name, $value)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setNotificationSettingValue', array($name, $value));
return parent::setNotificationSettingValue($name, $value);
}
/**
* {@inheritDoc}
*/
public function getNotificationSettingValue($name)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getNotificationSettingValue', array($name));
return parent::getNotificationSettingValue($name);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@@ -64,10 +64,10 @@ class UserNotificationSetting extends \Alchemy\Phrasea\Model\Entities\UserNotifi
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usrId', 'user', 'name', 'value', 'created', 'updated'); return array('__isInitialized__', 'id', 'user', 'name', 'value', 'created', 'updated');
} }
return array('__isInitialized__', 'id', 'usrId', 'user', 'name', 'value', 'created', 'updated'); return array('__isInitialized__', 'id', 'user', 'name', 'value', 'created', 'updated');
} }
/** /**
@@ -210,28 +210,6 @@ class UserNotificationSetting extends \Alchemy\Phrasea\Model\Entities\UserNotifi
return parent::setUser($user); return parent::setUser($user);
} }
/**
* {@inheritDoc}
*/
public function getUsrId()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array());
return parent::getUsrId();
}
/**
* {@inheritDoc}
*/
public function setUsrId($usrId)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId));
return parent::setUsrId($usrId);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@@ -64,10 +64,10 @@ class UserQuery extends \Alchemy\Phrasea\Model\Entities\UserQuery implements \Do
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usrId', 'user', 'query', 'created'); return array('__isInitialized__', 'id', 'user', 'query', 'created');
} }
return array('__isInitialized__', 'id', 'usrId', 'user', 'query', 'created'); return array('__isInitialized__', 'id', 'user', 'query', 'created');
} }
/** /**
@@ -188,28 +188,6 @@ class UserQuery extends \Alchemy\Phrasea\Model\Entities\UserQuery implements \Do
return parent::getId(); return parent::getId();
} }
/**
* {@inheritDoc}
*/
public function getUsrId()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array());
return parent::getUsrId();
}
/**
* {@inheritDoc}
*/
public function setUsrId($usrId)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId));
return parent::setUsrId($usrId);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@@ -64,10 +64,10 @@ class UserSetting extends \Alchemy\Phrasea\Model\Entities\UserSetting implements
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usrId', 'user', 'name', 'value', 'created', 'updated'); return array('__isInitialized__', 'id', 'user', 'name', 'value', 'created', 'updated');
} }
return array('__isInitialized__', 'id', 'usrId', 'user', 'name', 'value', 'created', 'updated'); return array('__isInitialized__', 'id', 'user', 'name', 'value', 'created', 'updated');
} }
/** /**
@@ -210,28 +210,6 @@ class UserSetting extends \Alchemy\Phrasea\Model\Entities\UserSetting implements
return parent::setUser($user); return parent::setUser($user);
} }
/**
* {@inheritDoc}
*/
public function getUsrId()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array());
return parent::getUsrId();
}
/**
* {@inheritDoc}
*/
public function setUsrId($usrId)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId));
return parent::setUsrId($usrId);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@@ -64,10 +64,10 @@ class UsrAuthProvider extends \Alchemy\Phrasea\Model\Entities\UsrAuthProvider im
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usr_id', 'provider', 'distant_id', 'created', 'updated'); return array('__isInitialized__', 'id', 'user', 'provider', 'distant_id', 'created', 'updated');
} }
return array('__isInitialized__', 'id', 'usr_id', 'provider', 'distant_id', 'created', 'updated'); return array('__isInitialized__', 'id', 'user', 'provider', 'distant_id', 'created', 'updated');
} }
/** /**
@@ -191,34 +191,23 @@ class UsrAuthProvider extends \Alchemy\Phrasea\Model\Entities\UsrAuthProvider im
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUsrId($usrId) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
return parent::setUsrId($usrId); return parent::setUser($user);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getUsrId() public function getUser()
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array()); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUsrId(); return parent::getUser();
}
/**
* {@inheritDoc}
*/
public function getUser(\Alchemy\Phrasea\Application $app)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app));
return parent::getUser($app);
} }
/** /**

View File

@@ -323,29 +323,29 @@ class UsrList extends \Alchemy\Phrasea\Model\Entities\UsrList implements \Doctri
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function hasAccess(\User_Adapter $user, \Alchemy\Phrasea\Application $app) public function hasAccess(\Alchemy\Phrasea\Model\Entities\User $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'hasAccess', array($user, $app)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'hasAccess', array($user));
return parent::hasAccess($user, $app); return parent::hasAccess($user);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getOwner(\User_Adapter $user, \Alchemy\Phrasea\Application $app) public function getOwner(\Alchemy\Phrasea\Model\Entities\User $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getOwner', array($user, $app)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getOwner', array($user));
return parent::getOwner($user, $app); return parent::getOwner($user);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function has(\User_Adapter $user, \Alchemy\Phrasea\Application $app) public function has(\Alchemy\Phrasea\Model\Entities\User $user, \Alchemy\Phrasea\Application $app)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'has', array($user, $app)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'has', array($user, $app));

View File

@@ -64,10 +64,10 @@ class UsrListEntry extends \Alchemy\Phrasea\Model\Entities\UsrListEntry implemen
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usr_id', 'created', 'updated', 'list'); return array('__isInitialized__', 'id', 'user', 'created', 'updated', 'list');
} }
return array('__isInitialized__', 'id', 'usr_id', 'created', 'updated', 'list'); return array('__isInitialized__', 'id', 'user', 'created', 'updated', 'list');
} }
/** /**
@@ -191,40 +191,7 @@ class UsrListEntry extends \Alchemy\Phrasea\Model\Entities\UsrListEntry implemen
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUsrId($usrId) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId));
return parent::setUsrId($usrId);
}
/**
* {@inheritDoc}
*/
public function getUsrId()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array());
return parent::getUsrId();
}
/**
* {@inheritDoc}
*/
public function getUser(\Alchemy\Phrasea\Application $app)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app));
return parent::getUser($app);
}
/**
* {@inheritDoc}
*/
public function setUser(\User_Adapter $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
@@ -232,6 +199,17 @@ class UsrListEntry extends \Alchemy\Phrasea\Model\Entities\UsrListEntry implemen
return parent::setUser($user); return parent::setUser($user);
} }
/**
* {@inheritDoc}
*/
public function getUser()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUser();
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@@ -64,10 +64,10 @@ class UsrListOwner extends \Alchemy\Phrasea\Model\Entities\UsrListOwner implemen
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usr_id', 'role', 'created', 'updated', 'list'); return array('__isInitialized__', 'id', 'user', 'role', 'created', 'updated', 'list');
} }
return array('__isInitialized__', 'id', 'usr_id', 'role', 'created', 'updated', 'list'); return array('__isInitialized__', 'id', 'user', 'role', 'created', 'updated', 'list');
} }
/** /**
@@ -191,29 +191,7 @@ class UsrListOwner extends \Alchemy\Phrasea\Model\Entities\UsrListOwner implemen
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUsrId($usrId) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId));
return parent::setUsrId($usrId);
}
/**
* {@inheritDoc}
*/
public function getUsrId()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array());
return parent::getUsrId();
}
/**
* {@inheritDoc}
*/
public function setUser(\User_Adapter $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
@@ -224,12 +202,12 @@ class UsrListOwner extends \Alchemy\Phrasea\Model\Entities\UsrListOwner implemen
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getUser(\Alchemy\Phrasea\Application $app) public function getUser()
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUser($app); return parent::getUser();
} }
/** /**

View File

@@ -64,10 +64,10 @@ class ValidationParticipant extends \Alchemy\Phrasea\Model\Entities\ValidationPa
public function __sleep() public function __sleep()
{ {
if ($this->__isInitialized__) { if ($this->__isInitialized__) {
return array('__isInitialized__', 'id', 'usr_id', 'is_aware', 'is_confirmed', 'can_agree', 'can_see_others', 'reminded', 'datas', 'session'); return array('__isInitialized__', 'id', 'is_aware', 'is_confirmed', 'can_agree', 'can_see_others', 'reminded', 'datas', 'session', 'user');
} }
return array('__isInitialized__', 'id', 'usr_id', 'is_aware', 'is_confirmed', 'can_agree', 'can_see_others', 'reminded', 'datas', 'session'); return array('__isInitialized__', 'id', 'is_aware', 'is_confirmed', 'can_agree', 'can_see_others', 'reminded', 'datas', 'session', 'user');
} }
/** /**
@@ -191,29 +191,7 @@ class ValidationParticipant extends \Alchemy\Phrasea\Model\Entities\ValidationPa
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setUsrId($usrId) public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsrId', array($usrId));
return parent::setUsrId($usrId);
}
/**
* {@inheritDoc}
*/
public function getUsrId()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsrId', array());
return parent::getUsrId();
}
/**
* {@inheritDoc}
*/
public function setUser(\User_Adapter $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
@@ -224,12 +202,12 @@ class ValidationParticipant extends \Alchemy\Phrasea\Model\Entities\ValidationPa
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getUser(\Alchemy\Phrasea\Application $app) public function getUser()
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUser($app); return parent::getUser();
} }
/** /**

View File

@@ -213,7 +213,7 @@ class ValidationSession extends \Alchemy\Phrasea\Model\Entities\ValidationSessio
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function isInitiator(\User_Adapter $user) public function isInitiator(\Alchemy\Phrasea\Model\Entities\User $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'isInitiator', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'isInitiator', array($user));
@@ -224,7 +224,7 @@ class ValidationSession extends \Alchemy\Phrasea\Model\Entities\ValidationSessio
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setInitiator(\User_Adapter $user) public function setInitiator(\Alchemy\Phrasea\Model\Entities\User $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setInitiator', array($user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'setInitiator', array($user));
@@ -378,7 +378,7 @@ class ValidationSession extends \Alchemy\Phrasea\Model\Entities\ValidationSessio
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getValidationString(\Alchemy\Phrasea\Application $app, \User_Adapter $user) public function getValidationString(\Alchemy\Phrasea\Application $app, \Alchemy\Phrasea\Model\Entities\User $user)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getValidationString', array($app, $user)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getValidationString', array($app, $user));
@@ -389,7 +389,7 @@ class ValidationSession extends \Alchemy\Phrasea\Model\Entities\ValidationSessio
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getParticipant(\User_Adapter $user, \Alchemy\Phrasea\Application $app) public function getParticipant(\Alchemy\Phrasea\Model\Entities\User $user, \Alchemy\Phrasea\Application $app)
{ {
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getParticipant', array($user, $app)); $this->__initializer__ && $this->__initializer__->__invoke($this, 'getParticipant', array($user, $app));