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
if ($this->oldEncoder->isPasswordValid($user->getPassword(), $password, $user->getNonce())) {
$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->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;
}

View File

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

View File

@@ -49,7 +49,7 @@ class Feed implements ControllerProviderInterface
$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', ''))) {
$app->abort(400, "Bad request");

View File

@@ -278,8 +278,6 @@ class Push implements ControllerProviderInterface
try {
$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_description = $request->request->get('validation_description');
@@ -337,15 +335,15 @@ class Push implements ControllerProviderInterface
}
$found = false;
foreach ($participants as $key => $participant) {
if ($participant['usr_id'] == $app['authentication']->getUser()->getId()) {
foreach ($participants as $participant) {
if ($participant['usr_id'] === $app['authentication']->getUser()->getId()) {
$found = true;
break;
}
}
if (!$found) {
$participants[$app['authentication']->getUser()->getId()] = [
$participants[] = [
'see_others' => 1,
'usr_id' => $app['authentication']->getUser()->getId(),
'agree' => 0,
@@ -429,7 +427,7 @@ class Push implements ControllerProviderInterface
$params = [
'from' => $app['authentication']->getUser()->getId(),
'from_email' => $app['authentication']->getUser()->getEmail(),
'to' => $participant_user->get_id(),
'to' => $participant_user->getId(),
'to_email' => $participant_user->getEmail(),
'to_name' => $participant_user->getDisplayName(),
'url' => $url,

View File

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

View File

@@ -340,7 +340,6 @@ class Login implements ControllerProviderInterface
$inscOK = [];
foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) {
if (null !== $selected && !in_array($collection->get_base_id(), $selected)) {
continue;
@@ -387,6 +386,9 @@ class Login implements ControllerProviderInterface
}
}
$app['EM']->persist($user);
$app['EM']->flush();
if (null !== $provider) {
$this->attachProviderToUser($app['EM'], $provider, $user);
$app['EM']->flush();
@@ -395,14 +397,14 @@ class Login implements ControllerProviderInterface
$demandOK = [];
if ($app['conf']->get(['registry', 'registration', 'auto-register-enabled'])) {
$template_user = $app['manipulator.user']->getRepository()->findbyLogin('autoregister');
$template_user = $app['manipulator.user']->getRepository()->findByLogin(User::USER_AUTOREGISTER);
$base_ids = [];
foreach (array_keys($inscOK) as $base_id) {
$base_ids[] = $base_id;
}
$app['acl']->get($user)->apply_model($template_user, $base_ids);
}
@@ -808,7 +810,8 @@ class Login implements ControllerProviderInterface
$context = new Context(Context::CONTEXT_GUEST);
$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());
$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');
}
if (null === $session->getUser()) {
$app->abort(403, 'Unauthorized');
}
if ($session->getUser()->getId() !== $app['authentication']->getUser()->getId()) {
$app->abort(403, 'Unauthorized');
}

View File

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

View File

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

View File

@@ -80,7 +80,7 @@ class Aggregate implements FeedInterface
public static function createFromUser(Application $app, User $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);
}

View File

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

View File

@@ -140,13 +140,13 @@ class FeedLinkGenerator implements LinkGeneratorInterface
{
$token = $this->em
->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) {
$token = new FeedToken();
$token->setFeed($feed);
$token->setUsrId($user->getId());
$token->setUser($user);
$feed->addToken($token);
$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');
$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)
WHERE (u.id = " . implode(' OR u.id = ', $this->users) . ")
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');
$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)
WHERE (u.id = " . implode(' OR u.id = ', $this->users) . ")
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');
$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
INNER JOIN bas b ON b.base_id = bu.base_id)
@@ -588,7 +588,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
, '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'])) {
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'));
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');
}
@@ -736,7 +736,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
if ($user->isTemplate()) {
$template = $user;
if ($template->getLastModel()->getId() !== $this->app['authentication']->getUser()->getId()) {
if (null === $template->getModelOf() || $template->getModelOf()->getId() !== $this->app['authentication']->getUser()->getId()) {
continue;
}
}
@@ -758,7 +758,13 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
private function unserializedRequestData(Request $request, array $indexes, $requestIndex)
{
$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) {
foreach ($indexes as $index) {

View File

@@ -112,11 +112,11 @@ class Manage extends Helper
->execute();
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)) {
$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) {
@@ -198,7 +198,7 @@ class Manage extends Helper
}
$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();
return $created_user;

View File

@@ -234,7 +234,7 @@ class Basket
public function getPusher(Application $app)
{
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;
/**
* @ORM\OneToOne(targetEntity="User")
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="model_of", referencedColumnName="id")
*
* @var User

View File

@@ -239,7 +239,7 @@ class UsrList
/**
* Return true if one of the entry is related to the given user
*
* @param \User_Adapter $user
* @param User $user
* @return boolean
*/
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.
*
@@ -180,6 +195,7 @@ class UserManager
$this->cleanFtpCredentials($user);
$this->cleanOrders($user);
$this->cleanFtpExports($user);
$this->cleanAuthProvider($user);
}
/**

View File

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

View File

@@ -33,7 +33,7 @@ class BasketElementRepository extends EntityRepository
LEFT JOIN e.validation_datas vd
LEFT JOIN b.validation s
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';
$params = [
@@ -108,7 +108,7 @@ class BasketElementRepository extends EntityRepository
JOIN e.basket b
LEFT JOIN b.validation s
LEFT JOIN s.participants p
WHERE b.usr_id = :usr_id
WHERE b.user = :usr_id
AND b.pusher_id IS NOT NULL
AND e.record_id = :record_id
AND e.sbas_id = :sbas_id';
@@ -132,7 +132,7 @@ class BasketElementRepository extends EntityRepository
JOIN e.basket b
JOIN b.validation v
JOIN v.participants p
WHERE p.usr_id = :usr_id
WHERE p.user = :usr_id
AND e.record_id = :record_id
AND e.sbas_id = :sbas_id';

View File

@@ -36,7 +36,7 @@ class BasketRepository extends EntityRepository
$dql = 'SELECT b
FROM Phraseanet:Basket b
LEFT JOIN b.elements e
WHERE b.usr_id = :usr_id
WHERE b.user = :usr_id
AND b.archived = false';
if ($sort == 'date') {
@@ -66,9 +66,9 @@ class BasketRepository extends EntityRepository
LEFT JOIN s.participants p
WHERE b.archived = false
AND (
(b.usr_id = :usr_id_owner AND b.is_read = false)
OR (b.usr_id != :usr_id_ownertwo
AND p.usr_id = :usr_id_participant
(b.user = :usr_id_owner AND b.is_read = false)
OR (b.user != :usr_id_ownertwo
AND p.user = :usr_id_participant
AND p.is_aware = false)
)
AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP())';
@@ -100,7 +100,7 @@ class BasketRepository extends EntityRepository
JOIN e.validation_datas v
JOIN b.validation s
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()) ';
if ($sort == 'date') {
@@ -167,7 +167,7 @@ class BasketRepository extends EntityRepository
FROM Phraseanet:Basket b
JOIN b.elements e
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 = [
'record_id' => $record->get_record_id(),
@@ -189,7 +189,7 @@ class BasketRepository extends EntityRepository
$dql = 'SELECT b
FROM Phraseanet:Basket b
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 = [
'usr_id' => $user->getId()
];
@@ -200,7 +200,7 @@ class BasketRepository extends EntityRepository
JOIN b.elements e
JOIN b.validation s
JOIN s.participants p
WHERE b.usr_id != ?1 AND p.usr_id = ?2';
WHERE b.user != ?1 AND p.user = ?2';
$params = [
1 => $user->getId()
, 2 => $user->getId()
@@ -211,7 +211,7 @@ class BasketRepository extends EntityRepository
FROM Phraseanet:Basket b
JOIN b.elements e
JOIN b.validation v
WHERE b.usr_id = :usr_id';
WHERE b.user = :usr_id';
$params = [
'usr_id' => $user->getId()
];
@@ -222,7 +222,7 @@ class BasketRepository extends EntityRepository
LEFT JOIN b.elements e
LEFT JOIN b.validation s
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 = [
'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.validation s
LEFT JOIN s.participants p
WHERE (b.usr_id = :usr_id)';
WHERE (b.user = :usr_id)';
$params = [
'usr_id' => $user->getId()
];
@@ -281,8 +281,8 @@ class BasketRepository extends EntityRepository
LEFT JOIN b.elements e
LEFT JOIN b.validation s
LEFT JOIN s.participants p
WHERE (b.usr_id = :usr_id AND b.archived = false)
OR (b.usr_id != :usr_id AND p.usr_id = :usr_id
WHERE (b.user = :usr_id AND b.archived = false)
OR (b.user != :usr_id AND p.user = :usr_id
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)
{
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 Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NoResultException;
/**
* OrderRepository
@@ -31,7 +32,7 @@ class OrderRepository extends EntityRepository
*/
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');
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)
{
$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') {
$dql .= ' ORDER BY s.created DESC';
@@ -98,7 +98,7 @@ class StoryWZRepository extends EntityRepository
{
$story = $this->findOneBy(
[
'usr_id' => $user->getId(),
'user' => $user->getId(),
'sbas_id' => $Story->get_sbas_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)))
->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.deleted', $qb->expr()->literal(false)));

View File

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

View File

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

View File

@@ -60,7 +60,7 @@ class UsrListOwnerRepository extends EntityRepository
{
$dql = 'SELECT o FROM Phraseanet:UsrListOwner o
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 = [
'usr_id' => $usr_id,

View File

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

View File

@@ -107,6 +107,12 @@ class Installer
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)
{
$structure = simplexml_load_file(__DIR__ . "/../../../conf.d/bases_structure.xml");
@@ -148,8 +154,6 @@ class Installer
private function createAB()
{
$this->app['phraseanet.appbox']->insert_datas();
$metadatas = $this->app['EM']->getMetadataFactory()->getAllMetadata();
if (!empty($metadatas)) {
@@ -159,6 +163,8 @@ class Installer
$tool->dropSchema($metadatas);
$tool->createSchema($metadatas);
}
$this->app['phraseanet.appbox']->insert_datas($this->app);
}
private function createConfigFile($abConn, $serverName, $binaryData)

View File

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

View File

@@ -234,11 +234,11 @@ class User_Query implements User_QueryInterface
}
$sql .= ' AND model_of = ' . $this->app['authentication']->getUser()->getId();
} elseif ($this->include_templates === false) {
$sql .= ' AND model_of=0';
$sql .= ' AND model_of IS NULL';
} 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 {
$sql .= ' AND model_of=0';
$sql .= ' AND model_of IS NULL';
}
if ($this->activities) {
@@ -512,7 +512,7 @@ class User_Query implements User_QueryInterface
$users = new ArrayCollection();
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;

View File

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

View File

@@ -33,7 +33,7 @@ function giveMeBases(Application $app, $usr = null)
WHERE bas.active > 0
AND bas.sbas_id = sbas.sbas_id
AND u.id = :usr_id
AND u.model_of = 0
AND u.model_of IS NULL
';
$stmt = $conn->prepare($sqlU);

View File

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

View File

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

View File

@@ -54,25 +54,22 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
$mailColl = [];
$rsm = new ResultSetMappingBuilder($this->app['EM']);
$rsm->addRootEntityFromClassMetadata('Alchemy\Phrasea\Model\Entities\User', 'u');
$rsm->addScalarResult('base_id', 'base_id');
$selectClause = $rsm->generateSelectClause([
'u' => 't1'
]);
$selectClause = $rsm->generateSelectClause();
$query = $this->app['EM']->createNativeQuery('
SELECT b.base_id, '.$selectClause.' FROM Users u, basusr b
WHERE u.id = b.usr_id
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.canadmin="1"
AND u.deleted="0"'
);
AND u.deleted="0"',
$rsm);
try {
$rs = $query->getResult();
foreach ($rs as $row) {
foreach ($query->getResult() as $row) {
$user = $row[0];
if (!isset($mailColl[$user->getId()])) {
@@ -82,7 +79,6 @@ class eventsmanager_notify_register extends eventsmanager_notifyAbstract
$mailColl[$user->getId()][] = $row['base_id'];
}
} catch (Exception $e) {
}
$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="'
. $this->app->url('lightbox_validation', ['ssel_id' => (string) $sx->ssel_id])
. $this->app->url('lightbox_validation', ['basket' => (string) $sx->ssel_id])
. '" target="_blank">'
. $basket_name . '</a>';

View File

@@ -62,13 +62,11 @@ class module_console_systemUpgrade extends Command
try {
$upgrader = new Setup_Upgrade($this->container, $input->getOption('force'));
$queries = $this->getService('phraseanet.appbox')->forceUpgrade($upgrader, $this->container);
} catch (\Exception_Setup_FixBadEmailAddresses $e) {
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 (0 < count($queries)) {

View File

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

View File

@@ -189,8 +189,8 @@ class queries
$history = '<ul>';
$queries = $app['EM']
->getRepository('Phraseanet:UserQuery')
->findBy(['usrId' => $usrId], ['created' => 'ASC'], 25, 0);
->getRepository('Alchemy\Phrasea\Model\Entities\UserQuery')
->findBy(['user' => $usrId], ['created' => 'ASC'], 25, 0);
foreach ($queries as $query) {
$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']),
':usr_id' => $this->app['authentication']->getUser()->getId(),
':record_id' => $this->get_record_id(),
);
];
} else {
$sql = 'SELECT record_id
FROM regroup g
@@ -1728,11 +1728,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface
ON (g.rid_parent = r.record_id)
WHERE rid_child = :record_id';
$params = [
$params = array(
':GV_site' => $this->app['conf']->get(['main', 'key'])
, ':usr_id' => $this->app['authentication']->getUser()->get_id()
, ':record_id' => $this->get_record_id()
);
];
$stmt = $this->get_databox()->get_connection()->prepare($sql);
$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());
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 (
FtpCredential INNER JOIN Users ON (
FtpCredential.active = 1 AND FtpCredential.user_id = Users.id
@@ -244,7 +244,7 @@ class set_export extends set_abstract
GROUP BY Users.id ";
$params = [];
} 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 (
FtpCredential INNER JOIN Users ON (
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>
{% endif %}
{% if table['user'] | length > 0 %}
{% if table['users'] | length > 0 %}
<form id="accept-demand" action="{{ path('users_submit_demands') }}" method="post">
<div class="btn-group btn-all-action">
<button data-event="deny" class="btn deny-checker" type="button">

View File

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

View File

@@ -326,7 +326,7 @@
<div class="control-group">
<label class="control-label" for="usr_mail"> {{ 'admin::compte-utilisateur email' | trans }}</label>
<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>

View File

@@ -33,7 +33,7 @@
<input type="hidden" name="usr_id" value="{{ owner.getUser().getId() }}" />
</td>
<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') %}
{{ 'You are Admin' | trans }}
{% endif %}
@@ -53,7 +53,7 @@
{% endif %}
</td>
<td style="width:15px">
{% if app['authentication'].getUser().getgetId() owner.getUser().getId() %}
{% if app['authentication'].getUser().getId() == owner.getUser().getId() %}
<a href="#" class="deleter">
<img src="/skins/prod/Push/close_badge.png" title="{{ 'Remove' | trans }}"/>
</a>

View File

@@ -63,18 +63,14 @@ class AccountCreatorTest extends \PhraseanetTestCase
public function testCreateWithTemplates()
{
$random = self::$DI['app']['tokens'];
$template1 = 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']);
$template3 = self::$DI['app']['manipulator.user']->createUser('template' . $random->generatePassword(), $random->generatePassword());
$template3->setModel(self::$DI['user']);
$template1 = self::$DI['app']['manipulator.user']->createTemplate('template1', self::$DI['user']);
$template2 = self::$DI['app']['manipulator.user']->createTemplate('template2', self::$DI['user']);
$template3 = self::$DI['app']['manipulator.user']->createTemplate('template3', self::$DI['user']);
$templates = [$template1, $template2];
$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);
$this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $user);

View File

@@ -15,11 +15,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
{
$app = $this->loadApp();
$app['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $session = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock();
$authenticator = new Authenticator($app, $browser, $session, $em);
$authenticator = new Authenticator(self::$DI['app'], $browser, $session, $em);
$this->assertNull($authenticator->getUser());
}
/**
@@ -31,19 +27,19 @@ class AuthenticatorTest extends \PhraseanetTestCase
$user = self::$DI['user'];
$app['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $session = $this->getSessionMock();
self::$DI['app']['browser'] = $browser = $this->getBrowserMock();
self::$DI['app']['session'] = $session = $this->getSessionMock();
$sessionEntity = new Session();
$sessionEntity->setUser($user);
$sessionEntity->setUserAgent('');
$app['EM']->persist($sessionEntity);
$app['EM']->flush();
self::$DI['app']['EM']->persist($sessionEntity);
self::$DI['app']['EM']->flush();
$session->set('usr_id', $user->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());
}
@@ -54,15 +50,11 @@ class AuthenticatorTest extends \PhraseanetTestCase
{
$app = $this->loadApp();
$app['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $session = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock();
$user = $this->getMockBuilder('')
$user = $this->getMockBuilder('Alchemy\Phrasea\Model\Entities\User')
->disableOriginalConstructor()
->getMock();
$authenticator = new Authenticator($app, $browser, $session, $em);
$authenticator = new Authenticator(self::$DI['app'], $browser, $session, $em);
$authenticator->setUser($user);
$this->assertEquals($user, $authenticator->getUser());
$authenticator->setUser(null);
@@ -77,9 +69,9 @@ class AuthenticatorTest extends \PhraseanetTestCase
$app = $this->loadApp();
$capturedSession = null;
$app['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $session = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock();
self::$DI['app']['browser'] = $browser = $this->getBrowserMock();
self::$DI['app']['session'] = $session = $this->getSessionMock();
self::$DI['app']['EM'] = $em = $this->getEntityManagerMock();
$user = $this->getMockBuilder('Alchemy\Phrasea\Model\Entities\User')
->disableOriginalConstructor()
@@ -102,7 +94,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
->method('get')
->will($this->returnValue($acl));
$app['acl'] = $aclProvider;
self::$DI['app']['acl'] = $aclProvider;
$em->expects($this->at(0))
->method('persist')
@@ -113,7 +105,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
$em->expects($this->at(1))
->method('flush');
$authenticator = new Authenticator($app, $browser, $session, $em);
$authenticator = new Authenticator(self::$DI['app'], $browser, $session, $em);
$phsession = $authenticator->openAccount($user);
$this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\Session', $phsession);
@@ -129,9 +121,9 @@ class AuthenticatorTest extends \PhraseanetTestCase
$user = self::$DI['user'];
$app['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $SFsession = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock();
self::$DI['app']['browser'] = $browser = $this->getBrowserMock();
self::$DI['app']['session'] = $SFsession = $this->getSessionMock();
self::$DI['app']['EM'] = $em = $this->getEntityManagerMock();
$sessionId = 4224242;
@@ -157,7 +149,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
->with($this->equalTo('Phraseanet:Session'))
->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));
}
@@ -170,9 +162,9 @@ class AuthenticatorTest extends \PhraseanetTestCase
$user = self::$DI['user'];
$app['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $SFsession = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock();
self::$DI['app']['browser'] = $browser = $this->getBrowserMock();
self::$DI['app']['session'] = $SFsession = $this->getSessionMock();
self::$DI['app']['EM'] = $em = $this->getEntityManagerMock();
$sessionId = 4224242;
@@ -198,7 +190,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
->with($this->equalTo('Phraseanet:Session'))
->will($this->returnValue($repo));
$authenticator = new Authenticator($app, $browser, $SFsession, $em);
$authenticator = new Authenticator(self::$DI['app'], $browser, $SFsession, $em);
try {
$authenticator->refreshAccount($session);
$this->fail('Should have raised an exception');
@@ -240,19 +232,19 @@ class AuthenticatorTest extends \PhraseanetTestCase
$user = self::$DI['user'];
$app['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $session = $this->getSessionMock();
self::$DI['app']['browser'] = $browser = $this->getBrowserMock();
self::$DI['app']['session'] = $session = $this->getSessionMock();
$sessionEntity = new Session();
$sessionEntity->setUser($user);
$sessionEntity->setUserAgent('');
$app['EM']->persist($sessionEntity);
$app['EM']->flush();
self::$DI['app']['EM']->persist($sessionEntity);
self::$DI['app']['EM']->flush();
$session->set('usr_id', $user->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());
}
@@ -263,11 +255,7 @@ class AuthenticatorTest extends \PhraseanetTestCase
{
$app = $this->loadApp();
$app['browser'] = $browser = $this->getBrowserMock();
$app['session'] = $session = $this->getSessionMock();
$app['EM'] = $em = $this->getEntityManagerMock();
$authenticator = new Authenticator($app, $browser, $session, $em);
$authenticator = new Authenticator(self::$DI['app'], $browser, $session, $em);
$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\Exception\AccountLockedException;
use Alchemy\Phrasea\Model\Entities\User;
class NativeAuthenticationTest extends \PhraseanetTestCase
{
/**
* @dataProvider provideReservedUsernames
*/
public function testReservedAreValid($username)
public function testAuthenticationSpecialUser()
{
$password = 'popo42';
$encoder = $this->getEncoderMock();
$oldEncoder = $this->getOldEncoderMock();
$conn = $this->getMock('connection_interface');
$request = $this->getRequestMock();
$auth = new NativeAuthentication($encoder, $oldEncoder, $conn);
$this->assertNull($auth->getUsrId($username, $password, $request));
}
$specialUser = $this->getMock('Alchemy\Phrasea\Model\Entities\User');
$specialUser->expects($this->any())->method('isSpecial')->will($this->returnValue(true));
public function provideReservedUsernames()
{
return [
['autoregister'],
['invite'],
];
$manipulator = $this->getUserManipulatorMock($specialUser);
$auth = new NativeAuthentication($encoder, $oldEncoder, $manipulator);
$this->assertNull($auth->getUsrId('a_login', 'a_password', $request));
}
public function testNotFoundIsNotValid()
{
$username = 'romainneutron';
$password = 'popo42';
$encoder = $this->getEncoderMock();
$oldEncoder = $this->getOldEncoderMock();
$conn = $this->getConnectionMock($username, null);
$request = $this->getRequestMock();
$manipulator = $this->getUserManipulatorMock(null);
$auth = new NativeAuthentication($encoder, $oldEncoder, $conn);
$this->assertNull($auth->getUsrId($username, $password, $request));
$auth = new NativeAuthentication($encoder, $oldEncoder, $manipulator);
$this->assertNull($auth->getUsrId('a_login', 'a_password', $request));
}
public function testLockAccountThrowsAnException()
{
$username = 'romainneutron';
$password = 'popo42';
$encoder = $this->getEncoderMock();
$oldEncoder = $this->getOldEncoderMock();
$conn = $this->getConnectionMock($username, [
'nonce' => 'dfqsdgqsd',
'salted_password' => '1',
'mail_locked' => '1',
'usr_id' => '1',
'usr_password' => 'qsdfsqdfqsd',
]);
$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 {
$auth->getUsrId($username, $password, $request);
$auth->getUsrId('a_login', 'a_password', $request);
$this->fail('Should have raised an exception');
} catch (AccountLockedException $e) {
@@ -73,23 +57,26 @@ class NativeAuthenticationTest extends \PhraseanetTestCase
public function testGetUsrIdWithCorrectCredentials()
{
$username = 'romainneutron';
$password = 'popo42';
$encoded = 'qsdfsqdfqsd';
$nonce = 'dfqsdgqsd';
$usr_id = '42';
$userId = 42;
$encoder = $this->getEncoderMock();
$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();
$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())
->method('isPasswordValid');
@@ -98,30 +85,33 @@ class NativeAuthenticationTest extends \PhraseanetTestCase
->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce))
->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()
{
$username = 'romainneutron';
$password = 'popo42';
$encoded = 'qsdfsqdfqsd';
$nonce = 'dfqsdgqsd';
$usr_id = '42';
$userId = 42;
$encoder = $this->getEncoderMock();
$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();
$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())
->method('isPasswordValid');
@@ -130,30 +120,33 @@ class NativeAuthenticationTest extends \PhraseanetTestCase
->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce))
->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()
{
$username = 'romainneutron';
$password = 'popo42';
$encoded = 'qsdfsqdfqsd';
$nonce = 'dfqsdgqsd';
$usr_id = '42';
$userId = 42;
$encoder = $this->getEncoderMock();
$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();
$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())
->method('isPasswordValid')
->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))
->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()
{
$username = 'romainneutron';
$password = 'popo42';
$encoded = 'qsdfsqdfqsd';
$nonce = 'dfqsdgqsd';
$usr_id = '42';
$userId = 42;
$encoder = $this->getEncoderMock();
$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();
$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())
->method('isPasswordValid')
->with($this->equalTo($encoded), $this->equalTo($password), $this->equalTo($nonce))
@@ -237,37 +204,8 @@ class NativeAuthenticationTest extends \PhraseanetTestCase
return true;
}));
$auth = new NativeAuthentication($encoder, $oldEncoder, $conn);
$this->assertEquals($usr_id, $auth->getUsrId($username, $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;
$auth = new NativeAuthentication($encoder, $oldEncoder, $manipulator);
$this->assertEquals($userId, $auth->getUsrId('a_login', $password, $request));
}
private function getEncoderMock()
@@ -297,4 +235,15 @@ class NativeAuthenticationTest extends \PhraseanetTestCase
->disableOriginalConstructor()
->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::dropDatabase();
parent::setUp();
self::dropDatabase();
}
public static function tearDownAfterClass()
public function tearDown()
{
if (!self::$createdCollections) {
return;
}
foreach (self::$createdCollections as $collection) {
try {
$collection->unmount_collection(self::$DI['app']);
@@ -35,15 +40,6 @@ class DataboxTest extends \PhraseanetAuthenticatedWebTestCase
}
self::$createdCollections = null;
self::dropDatabase();
parent::tearDownAfterClass();
}
public function tearDown()
{
self::dropDatabase();
parent::tearDown();
}
public function getJson($response)

View File

@@ -37,8 +37,8 @@ class SearchEngineTest extends \PhraseanetAuthenticatedWebTestCase
$app = $this->loadApp();
return [
[new PhraseaEngine($app)],
[new SphinxSearchEngine($app, 'localhost', 9306, 'localhost', 9308)],
[new PhraseaEngine(new Application('test'))],
[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
{
protected $client;
protected $usersParameters;
public function setUp()
@@ -29,10 +28,10 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
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()]);
$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()
@@ -40,25 +39,25 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['client']->request('POST', '/admin/users/delete/', ['users' => self::$DI['user']->getId()]);
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isRedirect());
$this->assertNotNull(self::$DI['app']['manipulator.user']->getRepository()->findByLogin(self::$DI['user']->getLogin()));
}
public function testRouteRightsApply()
{
$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();
$_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . $base_id . '=1&canpush_' . $base_id . '=1';
$_GET['user_infos'] = "user_infos[email]=" . $user->getEmail();
self::$DI['client']->request('POST', '/admin/users/rights/apply/', [
'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(),
]);
self::$DI['client']->request('POST', '/admin/users/rights/apply/', ['users' => $user->getId()]);
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type"));
@@ -66,28 +65,29 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertTrue(is_object($datas));
$datas = json_decode($response->getContent());
$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($base_id, "canreport"));
$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(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);
}
public function testRouteRightsApplyException()
{
$this->markTestIncomplete();
$_GET = [];
$user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), "test");
$base_id = self::$DI['collection']->get_base_id();
$_GET['values'] = 'canreport_' . $base_id . '=1&manage_' . self::$DI['collection']->get_base_id() . '=1&canpush_' . self::$DI['collection']->get_base_id() . '=1';
$_GET['user_infos'] = "user_infos[email]=" . $user->getEmail();
self::$DI['client']->request('POST', '/admin/users/rights/apply/', ['users' => $user->getId()]);
self::$DI['client']->request('POST', '/admin/users/rights/apply/', [
'users' => 'unknow_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',
'user_infos' => "user_infos[email]=toto@toto.fr"
]);
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOK());
$this->assertEquals("application/json", $response->headers->get("content-type"));
$datas = json_decode($response->getContent());
$this->assertTrue(is_object($datas));
$this->assertTrue($datas->error);
self::$DI['app']['model.user-manager']->delete($user);
$data = json_decode($response->getContent());
$this->assertTrue(is_object($data));
$this->assertTrue($data->error);
}
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());
$base_id = array_pop($keys);
$params = ['base_id' => $base_id, 'users' => self::$DI['user']->getId()];
self::$DI['client']->request('POST', '/admin/users/rights/quotas/', $params);
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOK());
@@ -136,9 +135,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
public function testRouteRightTimeSbas()
{
$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/', $params);
self::$DI['client']->request('POST', '/admin/users/rights/time/sbas/', ['sbas_id' => $sbas_id, 'users' => self::$DI['user']->getId()]);
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOK());
}
@@ -237,14 +234,13 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
public function testRouteApplyTp()
{
$this->authenticate(self::$DI['app']);
$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");
self::$DI['client']->request('POST', '/admin/users/apply_template/', [
'template' => $template->getId()
, 'users' => $user->getId()]
'template' => $template->getId(),
'users' => $user->getId()]
);
$response = self::$DI['client']->getResponse();
@@ -293,7 +289,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertTrue(is_object($datas));
$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);
}
@@ -316,7 +312,7 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertTrue(is_object($datas));
$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);
}
@@ -374,10 +370,13 @@ class UsersTest extends \PhraseanetAuthenticatedWebTestCase
self::$DI['app']['model.user-manager']->delete($user);
}
/**
* environment prod
*/
public function testRenderDemands()
{
$this->setConnectionEnvironment('prod');
self::$DI['client']->request('GET', '/admin/users/demands/');
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
}

View File

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

View File

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

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()]);
$response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk());
unset($response);
}
/**

View File

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

View File

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

View File

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

View File

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

View File

@@ -755,7 +755,7 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
"email" => $this->generateEmail(),
"collections" => null,
"login" => 'login-'.\random::generatePassword(),
"gender" => '1',
"gender" => User::GENDER_MR,
"firstname" => 'romain',
"lastname" => 'neutron',
"address" => '30 place saint georges',
@@ -830,7 +830,6 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
$entity = $this->getMock('Alchemy\Phrasea\Model\Entities\UsrAuthProvider');
$entity->expects($this->any())
->method('getUser')
->with(self::$DI['app'])
->will($this->returnValue(self::$DI['user']));
$token = new Token($provider, 42);
@@ -846,7 +845,6 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
'confirm' => 'password'
],
"email" => $this->generateEmail(),
"accept-tou" => '1',
"collections" => null,
"provider-id" => 'provider-test',
]);
@@ -864,7 +862,6 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
}
self::$DI['client']->request('POST', '/login/register-classic/', $parameters);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertEquals('/prod/', self::$DI['client']->getResponse()->headers->get('location'));
}
@@ -946,7 +943,11 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertEquals('/login/register/', self::$DI['client']->getResponse()->headers->get('location'));
}
public function testPostRegisterWithProviderId()
/**
*
* @environment prod
*/
public function testPostRegisterWithProviderIdAndAccountNotCreatedYet()
{
self::$DI['app']['registration.fields'] = [];
$this->logout(self::$DI['app']);
@@ -965,7 +966,6 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
'confirm' => 'password'
],
"email" => $this->generateEmail(),
"accept-tou" => '1',
"collections" => null,
"provider-id" => 'provider-test',
]);
@@ -979,6 +979,41 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
->method('getToken')
->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) {
if ('collections' === $key && null === $parameter) {
$parameters[$key] = self::$demands;
@@ -996,27 +1031,23 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
}
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');
}
$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);
$this->assertGreaterThan(0, $emails['Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered']);
$this->assertEquals(1, $emails['Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation']);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertFlashMessagePopulated(self::$DI['app'], 'info', 1);
$this->assertEquals('/login/', self::$DI['client']->getResponse()->headers->get('location'));
}
/**
* @dataProvider provideRegistrationData
* @environment prod
*/
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'])) {
$this->fail('User not created');
}
self::$DI['app']['model.user-manager']->delete($user);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertGreaterThan(0, $emails['Alchemy\Phrasea\Notification\Mail\MailInfoUserRegistered']);
$this->assertEquals(1, $emails['Alchemy\Phrasea\Notification\Mail\MailRequestEmailConfirmation']);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertFlashMessagePopulated(self::$DI['app'], 'info', 1);
$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()
{
$password = \random::generatePassword();
$login = self::$DI['app']['authentication']->getUser()->getLogin();
self::$DI['app']['manipulator.user']->setPassword(self::$DI['app']['authentication']->getUser(), $password);
self::$DI['app']['authentication']->getUser()->setMailLocked(false);
self::$DI['app']['EM']->persist(self::$DI['app']['authentication']->getUser());
self::$DI['app']['EM']->flush();
$this->logout(self::$DI['app']);
self::$DI['client'] = new Client(self::$DI['app'], []);
$this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']);
self::$DI['client']->request('POST', '/login/authenticate/', [
'login' => $login,
'password' => $password,
'_token' => 'token',
]);
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertRegExp('/^\/prod\/$/', self::$DI['client']->getResponse()->headers->get('Location'));
}
@@ -1219,18 +1247,13 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
*/
public function testGuestAuthenticate()
{
if (null === $user= self::$DI['app']['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST)) {
$this->fail('User not created');
}
self::$DI['app']['acl']->get($user)->give_access_to_base([self::$DI['collection']->get_base_id()]);
$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']);
self::$DI['client'] = new Client(self::$DI['app'], []);
$this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']);
self::$DI['client']->request('POST', '/login/authenticate/guest/');
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$this->assertRegExp('/^\/prod\/$/', self::$DI['client']->getResponse()->headers->get('Location'));
@@ -1252,11 +1275,8 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
$this->assertEquals($context, $event->getContext()->getContext());
});
if (null === $user= self::$DI['app']['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST)) {
$this->fail('User not created');
}
self::$DI['app']['acl']->get($user)->give_access_to_base([self::$DI['collection']->get_base_id()]);
$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']);
@@ -1272,12 +1292,14 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
*/
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']);
self::$DI['client'] = new Client(self::$DI['app'], []);
$this->set_user_agent(self::USER_AGENT_FIREFOX8MAC, self::$DI['app']);
self::$DI['client']->request('GET', '/login/authenticate/guest/');
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
$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->expects($this->any())
->method('getUser')
->with(self::$DI['app'])
->will($this->returnValue(self::$DI['user']));
$token = new Token($provider, 42);

View File

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

View File

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

View File

@@ -18,7 +18,7 @@ class AggregateLinkGeneratorTest extends \PhraseanetTestCase
$feed = new Feed();
$feed->setTitle("title");
$another_feed = new Feed($user);
$another_feed = new Feed(self::$DI['user']);
$another_feed->setTitle("another_title");
$feeds = [$feed, $another_feed];
@@ -48,7 +48,7 @@ class AggregateLinkGeneratorTest extends \PhraseanetTestCase
$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") {
$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);
$link = $linkGenerator->generate($feed, $user, $format, $page, $renew);
$link = $linkGenerator->generate($feed, self::$DI['user'], $format, $page, $renew);
$this->assertSame($expected, $link->getUri());
if ($format == "atom") {

View File

@@ -6,7 +6,7 @@ class ACLManipulatorTest extends \PhraseanetTestCase
{
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);
$databoxId = null;

View File

@@ -14,7 +14,7 @@ class UserProviderTest extends \PhraseanetTestCase
public function 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()
{
$this->setConnectionEnvironment('prod');
self::$DI['user'];
$results = $this->object->find('BABE', self::$DI['user'], self::$DI['collection']->get_databox());
$this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $results);

View File

@@ -12,11 +12,11 @@ class ACLTest extends \PhraseanetAuthenticatedTestCase
public static function tearDownAfterClass()
{
$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);
}
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);
}
@@ -81,7 +81,7 @@ class ACLTest extends \PhraseanetAuthenticatedTestCase
public function testApply_model()
{
$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 = [];
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()
{
$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 = [];
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());
unset($this->test["id"]);
$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());
}

View File

@@ -19,6 +19,7 @@ use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\ValidationData;
use Alchemy\Phrasea\Model\Entities\ValidationSession;
use Alchemy\Phrasea\Model\Entities\ValidationParticipant;
use Doctrine\ORM\EntityManager;
use Alchemy\Phrasea\Model\Entities\UsrListOwner;
use Alchemy\Phrasea\Model\Entities\UsrList;
use Alchemy\Phrasea\Model\Entities\UsrListEntry;
@@ -58,6 +59,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
protected static $testsTime = [];
protected static $records;
public static $recordsInitialized = false;
public static $collectionsInitialized = false;
/**
* 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.
*/
public function createAPIApplication()
public function createAPIApplication($env = 'test')
{
self::deleteResources();
self::$DI['app'] = self::$DI->share(function () {
$environment = 'test';
self::$DI['app'] = self::$DI->share(function () use ($env) {
$environment = $env;
$app = require __DIR__ . '/../../lib/Alchemy/Phrasea/Application/Api.php';
$app['debug'] = true;
$app['session.test'] = true;
$app['EM'] = $app->share($app->extend('EM', function ($em) {
$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) {
$environment = 'test';
self::$DI['app'] = self::$DI->share(function ($DI) use ($env) {
$environment = $env;
$app = require __DIR__ . '/../../lib/Alchemy/Phrasea/Application/Root.php';
$app['form.csrf_provider'] = $app->share(function () {
@@ -262,6 +264,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}));
$app['debug'] = true;
$app['session.test'] = true;
$app['EM'] = $app->share($app->extend('EM', function ($em) {
$this::initializeSqliteDB();
@@ -270,7 +273,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}));
$app['browser'] = $app->share($app->extend('browser', function ($browser) {
$browser->setUserAgent(PhraseanetPHPUnitAbstract::USER_AGENT_FIREFOX8MAC);
return $browser;
@@ -296,10 +298,10 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* 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) {
$app = new CLI('cli test', null, 'test');
self::$DI['cli'] = self::$DI->share(function ($DI) use ($env) {
$app = new CLI('cli test', null, $env);
$app['form.csrf_provider'] = $app->share(function () {
return new CsrfTestProvider();
@@ -313,6 +315,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}));
$app['debug'] = true;
$app['session.test'] = true;
$app['EM'] = $app->share($app->extend('EM', function ($em) {
$this::initializeSqliteDb();
@@ -338,6 +341,10 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
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);
}
/**
* 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)
{
$this->assertEquals(403, $response->getStatusCode());
@@ -439,7 +470,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Inserts one basket.
*
* @param User_Adapter $user
* @param User $user
*
* @return Basket
*/
@@ -459,20 +490,20 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Inserts one feed.
*
* @param User_Adapter $user
* @param User $user
* @param string|null $title
* @param bool $public
*
* @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();
$publisher = new FeedPublisher();
$user = $user ?: self::$DI['user'];
$publisher->setUsrId($user->get_id());
$publisher->setUser($user);
$publisher->setIsOwner(true);
$publisher->setFeed($feed);
@@ -491,12 +522,12 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Inserts one feed entry.
*
* @param User_Adapter $user
* @param User $user
* @param bool $public
*
* @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);
@@ -527,18 +558,18 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* Inserts one feed token.
*
* @param Feed $feed
* @param User_Adapter $user
* @param User $user
*
* @return FeedToken
*/
protected function insertOneFeedToken(Feed $feed, \User_Adapter $user = null)
protected function insertOneFeedToken(Feed $feed, User $user = null)
{
$user = $user ?: self::$DI['user'];
$token = new FeedToken();
$token->setValue(self::$DI['app']['tokens']->generatePassword(12));
$token->setFeed($feed);
$token->setUsrId($user->get_id());
$token->setUser($user);
$feed->addToken($token);
@@ -552,17 +583,17 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Insert one aggregate token.
*
* @param User_Adapter $user
* @param User $user
*
* @return AggregateToken
*/
protected function insertOneAggregateToken(\User_Adapter $user = null)
protected function insertOneAggregateToken(User $user = null)
{
$user = $user ?: self::$DI['user'];
$token = new AggregateToken();
$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']->flush();
@@ -573,14 +604,14 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* 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);
for ($i = 0; $i < $qty; $i++) {
$item = new \Alchemy\Phrasea\Model\Entities\FeedItem();
$item = new FeedItem();
$item->setEntry($entry);
if (null === $record) {
@@ -606,16 +637,16 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Inserts one lazaret file.
*
* @param User_Adapter $user
* @param User $user
*
* @return LazaretFile
*/
protected function insertOneLazaretFile(\User_Adapter $user = null)
protected function insertOneLazaretFile(User $user = null)
{
$user = $user ?: self::$DI['user'];
$lazaretSession = new LazaretSession();
$lazaretSession->setUsrId($user->get_id());
$lazaretSession->setUser($user);
$lazaretSession->setUpdated(new \DateTime('now'));
$lazaretSession->setCreated(new \DateTime('-1 day'));
@@ -640,7 +671,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Inserts one user list owner.
*
* @param User_Adapter $user
* @param User $user
*
* @return UsrListOwner
*/
@@ -661,11 +692,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Inserts one user list.
*
* @param User_Adapter $user
* @param User $user
*
* @return UsrListOwner
*/
protected function insertOneUsrList(\User_Adapter $user = null)
protected function insertOneUsrList(User $user = null)
{
$owner = $this->insertOneUsrListOwner($user);
$list = new UsrList();
@@ -679,37 +710,15 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
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.
*
* @param User_adapter $owner
* @param User_adapter $user
* @param User $owner
* @param User $user
*
* @return UsrListEntry
*/
protected function insertOneUsrListEntry(\User_adapter $owner, \User_adapter $user)
protected function insertOneUsrListEntry(User $owner, User $user)
{
$list = $this->insertOneUsrList($owner);
@@ -733,26 +742,26 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
*/
protected function insertFiveBasket()
{
try {
$basketFixture = new PhraseaFixture\Basket\LoadFiveBaskets();
$baskets = [];
$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();
$loader->addFixture($basketFixture);
$this->insertFixtureInDatabase($loader);
return $basketFixture->baskets;
} catch (\Exception $e) {
$this->fail('Fail load five Basket : ' . $e->getMessage());
self::$DI['app']['EM']->persist($basket);
$baskets[] = $basket;
}
self::$DI['app']['EM']->flush();
return $baskets;
}
/**
* Inserts one basket element.
*
* @param User_Adapter $user
* @param User $user
* @param record_adapter $record
*
* @return BasketElement
@@ -867,12 +876,12 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
/**
* Inserts one story.
*
* @param User_Adapter $user
* @param User $user
* @param record_adapter $record
*
* @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();
@@ -889,11 +898,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* Inserts one validation session.
*
* @param Basket $basket
* @param User_Adapter $user
* @param User $user
*
* @return ValidationSession
*/
protected function insertOneValidationSession(Basket $basket = null, \User_Adapter $user = null)
protected function insertOneValidationSession(Basket $basket = null, User $user = null)
{
$validationSession = new ValidationSession();
@@ -994,52 +1003,38 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* self::$DI['user_alt1']
* 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) {
$usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit');
if (!$usr_id) {
$user = User_Adapter::create($application, 'test_phpunit', random::generatePassword(), 'noone@example.com', false);
$usr_id = $user->get_id();
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);
}
$user = User_Adapter::getInstance($usr_id, $application);
return $user;
});
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 (!$usr_id) {
$user = User_Adapter::create($application, 'test_phpunit_not_admin', random::generatePassword(), 'noone_not_admin@example.com', false);
$usr_id = $user->get_id();
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');
}
return User_Adapter::getInstance($usr_id, $application);
return $user;
});
self::$DI['user_alt1'] = self::$DI->share(function () use ($application) {
$usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit_alt1');
if (!$usr_id) {
$user = User_Adapter::create($application, 'test_phpunit_alt1', random::generatePassword(), 'noonealt1@example.com', false);
$usr_id = $user->get_id();
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');
}
return User_Adapter::getInstance($usr_id, $application);
return $user;
});
self::$DI['user_alt2'] = self::$DI->share(function () use ($application) {
$usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit_alt2');
if (!$usr_id) {
$user = User_Adapter::create($application, 'test_phpunit_alt2', random::generatePassword(), 'noonealt2@example.com', false);
$usr_id = $user->get_id();
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');
}
return User_Adapter::getInstance($usr_id, $application);
return $user;
});
}
@@ -1048,7 +1043,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
*
* @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()));
@@ -1101,6 +1096,10 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
*/
private static function setCollection(Application $application)
{
if (self::$collectionsInitialized) {
return;
}
$coll = $collection_no_acces = $collection_no_acces_by_status = $db = null;
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']);
}
$DI['user'] = $DI->share(
$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'];
$application['acl']->get($DI['user'])->revoke_access_from_bases([$collection_no_acces->get_base_id()]);
return $collection_no_acces;
});
@@ -1174,7 +1165,10 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
*/
protected static function generateRecords(Application $app)
{
if (self::$recordsInitialized === false) {
if (self::$recordsInitialized) {
return;
}
$logger = new \Monolog\Logger('tests');
$logger->pushHandler(new \Monolog\Handler\NullHandler());
self::$recordsInitialized = [];
@@ -1225,7 +1219,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
return \record_adapter::createFromFile($file, $DI['app']);
});
}
return;
}

View File

@@ -18,14 +18,12 @@ class collectionTest extends \PhraseanetAuthenticatedTestCase
{
$application = self::$DI['app'];
self::$DI['user'];
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');
}
$databox = array_shift(self::$DI['app']['phraseanet.appbox']->get_databoxes());
$databox = array_shift($databoxes);
self::$object = collection::create(
self::$DI['app'],

View File

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

View File

@@ -64,10 +64,10 @@ class AggregateToken extends \Alchemy\Phrasea\Model\Entities\AggregateToken impl
public function __sleep()
{
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}
*/
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}
*/
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()
{
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}
*/
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}
*/
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();
}
/**
* {@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);
return parent::getUser();
}
/**
@@ -323,7 +301,7 @@ class Basket extends \Alchemy\Phrasea\Model\Entities\Basket implements \Doctrine
/**
* {@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));

View File

@@ -389,7 +389,7 @@ class BasketElement extends \Alchemy\Phrasea\Model\Entities\BasketElement implem
/**
* {@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));

View File

@@ -356,7 +356,7 @@ class Feed extends \Alchemy\Phrasea\Model\Entities\Feed implements \Doctrine\ORM
/**
* {@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));
@@ -433,7 +433,7 @@ class Feed extends \Alchemy\Phrasea\Model\Entities\Feed implements \Doctrine\ORM
/**
* {@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));
@@ -444,7 +444,7 @@ class Feed extends \Alchemy\Phrasea\Model\Entities\Feed implements \Doctrine\ORM
/**
* {@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));
@@ -499,7 +499,7 @@ class Feed extends \Alchemy\Phrasea\Model\Entities\Feed implements \Doctrine\ORM
/**
* {@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));
@@ -576,7 +576,7 @@ class Feed extends \Alchemy\Phrasea\Model\Entities\Feed implements \Doctrine\ORM
/**
* {@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));

View File

@@ -400,7 +400,7 @@ class FeedEntry extends \Alchemy\Phrasea\Model\Entities\FeedEntry implements \Do
/**
* {@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));

View File

@@ -64,10 +64,10 @@ class FeedPublisher extends \Alchemy\Phrasea\Model\Entities\FeedPublisher implem
public function __sleep()
{
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}
*/
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}
*/
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();
}
/**
* {@inheritDoc}
*/
public function getUser(\Alchemy\Phrasea\Application $app)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app));
return parent::getUser($app);
}
/**
* {@inheritDoc}
*/

View File

@@ -64,10 +64,10 @@ class FeedToken extends \Alchemy\Phrasea\Model\Entities\FeedToken implements \Do
public function __sleep()
{
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}
*/
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}
*/
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()
{
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();
}
/**
* {@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}
*/
@@ -224,7 +202,7 @@ class FtpCredential extends \Alchemy\Phrasea\Model\Entities\FtpCredential implem
/**
* {@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));

View File

@@ -64,10 +64,10 @@ class FtpExport extends \Alchemy\Phrasea\Model\Entities\FtpExport implements \Do
public function __sleep()
{
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();
}
/**
* {@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}
*/
@@ -463,50 +485,6 @@ class FtpExport extends \Alchemy\Phrasea\Model\Entities\FtpExport implements \Do
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}
*/

View File

@@ -64,10 +64,10 @@ class LazaretSession extends \Alchemy\Phrasea\Model\Entities\LazaretSession impl
public function __sleep()
{
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}
*/
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}
*/
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();
}
/**
* {@inheritDoc}
*/
public function getUser(\Alchemy\Phrasea\Application $app)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app));
return parent::getUser($app);
return parent::getUser();
}
/**

View File

@@ -64,10 +64,10 @@ class Order extends \Alchemy\Phrasea\Model\Entities\Order implements \Doctrine\O
public function __sleep()
{
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}
*/
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}
*/
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();
}
/**
* {@inheritDoc}
*/
public function getUser(\Alchemy\Phrasea\Application $app)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app));
return parent::getUser($app);
}
/**
* {@inheritDoc}
*/

View File

@@ -64,10 +64,10 @@ class Session extends \Alchemy\Phrasea\Model\Entities\Session implements \Doctri
public function __sleep()
{
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}
*/
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));
@@ -202,34 +202,12 @@ class Session extends \Alchemy\Phrasea\Model\Entities\Session implements \Doctri
/**
* {@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);
}
/**
* {@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();
return parent::getUser();
}
/**

View File

@@ -64,10 +64,10 @@ class StoryWZ extends \Alchemy\Phrasea\Model\Entities\StoryWZ implements \Doctri
public function __sleep()
{
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}
*/
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 setUser(\User_Adapter $user)
public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
@@ -290,12 +268,12 @@ class StoryWZ extends \Alchemy\Phrasea\Model\Entities\StoryWZ implements \Doctri
/**
* {@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();
}
/**
* {@inheritDoc}
*/
public function getSettingValue($name, $default = NULL)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getSettingValue', array($name, $default));
return parent::getSettingValue($name, $default);
}
/**
* {@inheritDoc}
*/
@@ -1035,6 +1024,17 @@ class User extends \Alchemy\Phrasea\Model\Entities\User implements \Doctrine\ORM
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}
*/
@@ -1057,6 +1057,28 @@ class User extends \Alchemy\Phrasea\Model\Entities\User implements \Doctrine\ORM
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}
*/

View File

@@ -64,10 +64,10 @@ class UserNotificationSetting extends \Alchemy\Phrasea\Model\Entities\UserNotifi
public function __sleep()
{
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);
}
/**
* {@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}
*/

View File

@@ -64,10 +64,10 @@ class UserQuery extends \Alchemy\Phrasea\Model\Entities\UserQuery implements \Do
public function __sleep()
{
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();
}
/**
* {@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}
*/

View File

@@ -64,10 +64,10 @@ class UserSetting extends \Alchemy\Phrasea\Model\Entities\UserSetting implements
public function __sleep()
{
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);
}
/**
* {@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}
*/

View File

@@ -64,10 +64,10 @@ class UsrAuthProvider extends \Alchemy\Phrasea\Model\Entities\UsrAuthProvider im
public function __sleep()
{
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}
*/
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}
*/
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();
}
/**
* {@inheritDoc}
*/
public function getUser(\Alchemy\Phrasea\Application $app)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array($app));
return parent::getUser($app);
return parent::getUser();
}
/**

View File

@@ -323,29 +323,29 @@ class UsrList extends \Alchemy\Phrasea\Model\Entities\UsrList implements \Doctri
/**
* {@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}
*/
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}
*/
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));

View File

@@ -64,10 +64,10 @@ class UsrListEntry extends \Alchemy\Phrasea\Model\Entities\UsrListEntry implemen
public function __sleep()
{
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}
*/
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)
public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{
$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);
}
/**
* {@inheritDoc}
*/
public function getUser()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUser', array());
return parent::getUser();
}
/**
* {@inheritDoc}
*/

View File

@@ -64,10 +64,10 @@ class UsrListOwner extends \Alchemy\Phrasea\Model\Entities\UsrListOwner implemen
public function __sleep()
{
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}
*/
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 setUser(\User_Adapter $user)
public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
@@ -224,12 +202,12 @@ class UsrListOwner extends \Alchemy\Phrasea\Model\Entities\UsrListOwner implemen
/**
* {@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()
{
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}
*/
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 setUser(\User_Adapter $user)
public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user));
@@ -224,12 +202,12 @@ class ValidationParticipant extends \Alchemy\Phrasea\Model\Entities\ValidationPa
/**
* {@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}
*/
public function isInitiator(\User_Adapter $user)
public function isInitiator(\Alchemy\Phrasea\Model\Entities\User $user)
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'isInitiator', array($user));
@@ -224,7 +224,7 @@ class ValidationSession extends \Alchemy\Phrasea\Model\Entities\ValidationSessio
/**
* {@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));
@@ -378,7 +378,7 @@ class ValidationSession extends \Alchemy\Phrasea\Model\Entities\ValidationSessio
/**
* {@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));
@@ -389,7 +389,7 @@ class ValidationSession extends \Alchemy\Phrasea\Model\Entities\ValidationSessio
/**
* {@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));