Remove DoctrineFixtures mechanism

This commit is contained in:
Nicolas Le Goff
2013-11-21 14:57:10 +01:00
parent 4890832822
commit b751d0ef3e
19 changed files with 367 additions and 1202 deletions

View File

@@ -46,7 +46,6 @@
"doctrine/migrations" : "1.0.x-dev@dev"
},
"require-dev": {
"doctrine/data-fixtures" : "1.0.x@dev",
"phpunit/phpunit" : "~3.7",
"behat/behat" : "2.5.x-dev@dev",
"behat/gherkin" : "2.3.x-dev@dev",
@@ -69,8 +68,7 @@
"autoload": {
"psr-0": {
"" : "lib/classes",
"Alchemy" : "lib",
"PhraseaFixture" : "lib/conf.d"
"Alchemy" : "lib"
}
},
"include-path": ["vendor/zend/gdata/library"],

View File

@@ -1,40 +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;
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

@@ -1,47 +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\Basket;
use Alchemy\Phrasea\Model\Entities\Basket;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
class LoadFiveBaskets extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
*
* @var array
*/
public $baskets;
public function load(ObjectManager $manager)
{
for ($i = 0; $i < 5; $i ++) {
$basket = new Basket();
$basket->setName('test ' . $i);
$basket->setDescription('description');
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new basket');
}
$basket->setOwner($this->user);
$manager->persist($basket);
$this->baskets[] = $basket;
}
$this->addReference('five-basket', $basket);
$manager->flush();
}
}

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\Basket;
use Alchemy\Phrasea\Model\Entities\Basket;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
class LoadOneBasket extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
* @var Basket
*/
public $basket;
public function load(ObjectManager $manager)
{
$basket = new Basket();
$basket->setName('test');
$basket->setDescription('description');
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new basket');
}
$basket->setOwner($this->user);
$manager->persist($basket);
$manager->flush();
$this->basket = $basket;
$this->addReference('one-basket', $basket);
}
}

View File

@@ -1,120 +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\Basket;
use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Entities\BasketElement;
use Alchemy\Phrasea\Model\Entities\ValidationSession;
use Alchemy\Phrasea\Model\Entities\ValidationParticipant;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
class LoadOneBasketEnv extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
* @var Basket
*/
public $basket;
/**
* @var Array
*/
protected $participants = [];
/**
* @var Array
*/
protected $basketElements = [];
public function addParticipant(\User_Adapter $user)
{
$this->participants[] = $user;
}
public function addElement(\record_adapter $record)
{
$this->basketElements[] = $record;
}
public function load(ObjectManager $manager)
{
$basket = new Basket();
$basket->setName('test');
$basket->setDescription('description');
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new basket');
}
$basket->setOwner($this->user);
$this->addElementToBasket($manager, $basket);
$validationSession = new ValidationSession();
$validationSession->setBasket($basket);
$expires = new \DateTime();
$expires->modify('+1 week');
$validationSession->setExpires($expires);
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new validation Session');
}
$validationSession->setInitiator($this->user);
$this->addParticipantsToSession($manager, $validationSession);
$this->basket = $basket;
}
private function addParticipantsToSession(EntityManager $manager, ValidationSession $validationSession)
{
if (0 === count($this->participants)) {
throw new \LogicException('Add new participants to validation session');
}
foreach ($this->participants as $participant) {
$validationParticipant = new ValidationParticipant();
$validationParticipant->setUser($participant);
$validationParticipant->setSession($validationSession);
$manager->persist($validationParticipant);
}
$manager->flush();
}
private function addElementToBasket(EntityManager $manager, Basket $basket)
{
if (0 === count($this->basketElements)) {
throw new \LogicException('Add new elements to basket');
}
foreach ($this->basketElements as $record) {
$basketElement = new BasketElement();
$basketElement->setRecord($record);
$basketElement->setBasket($basket);
$manager->persist($basketElement);
}
$manager->flush();
}
}

View File

@@ -1,93 +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\Feed;
use Alchemy\Phrasea\Model\Entities\Feed;
use Alchemy\Phrasea\Model\Entities\FeedPublisher;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\AbstractFixture;
class LoadOneFeed extends AbstractFixture implements FixtureInterface
{
/**
*
* @var Feed
*/
public $feed;
public $user;
public $title;
public $public;
public function load(ObjectManager $manager)
{
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new feed');
}
$feed = new Feed();
$publisher = new FeedPublisher();
$publisher->setUsrId($this->user->get_id());
$publisher->setIsOwner(true);
$publisher->setFeed($feed);
$feed->addPublisher($publisher);
if (isset($this->title) && $this->title !== null) {
$feed->setTitle($this->title);
} else {
$feed->setTitle("test");
}
$feed->setIsPublic((Boolean) $this->public);
$feed->setSubtitle("description");
$manager->persist($feed);
$manager->persist($publisher);
$manager->flush();
$this->feed = $feed;
$this->addReference('one-feed', $feed);
}
public function setUser(\User_Adapter $user)
{
$this->user = $user;
}
public function getUser()
{
return $this->user;
}
public function setTitle($title)
{
$this->title = $title;
}
public function getTitle()
{
return $this->title;
}
public function setPublic($public)
{
$this->public = $public;
}
public function getPublic()
{
return $this->public;
}
}

View File

@@ -1,61 +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\Lazaret;
use Alchemy\Phrasea\Model\Entities\LazaretFile;
use Alchemy\Phrasea\Model\Entities\LazaretSession;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
class LoadOneFile extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
* @var LazaretFile
*/
public $file;
public $collectionId;
public function load(ObjectManager $manager)
{
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new basket');
}
$lazaretSession = new LazaretSession();
$lazaretSession->setUsrId($this->user->get_id());
$lazaretSession->setUpdated(new \DateTime('now'));
$lazaretSession->setCreated(new \DateTime('-1 day'));
$lazaretFile = new LazaretFile();
$lazaretFile->setOriginalName('test');
$lazaretFile->setFilename('test.jpg');
$lazaretFile->setThumbFilename('thumb_test.jpg');
$lazaretFile->setBaseId($this->collectionId);
$lazaretFile->setSession($lazaretSession);
$lazaretFile->setSha256('3191af52748620e0d0da50a7b8020e118bd8b8a0845120b0bb');
$lazaretFile->setUuid('7b8ef0e3-dc8f-4b66-9e2f-bd049d175124');
$lazaretFile->setCreated(new \DateTime('now'));
$lazaretFile->setUpdated(new \DateTime('-1 day'));
$manager->persist($lazaretFile);
$manager->flush();
$this->file = $lazaretFile;
$this->addReference('one-lazaret-file', $lazaretFile);
}
public function setCollectionId($collectionId)
{
$this->collectionId = (int) $collectionId;
}
}

View File

@@ -1,48 +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\Story;
use Alchemy\Phrasea\Model\Entities\StoryWZ;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
class LoadOneStory extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
*
* @var StoryWZ
*/
public $story;
public function load(ObjectManager $manager)
{
$story = new StoryWZ();
if (null === $this->record) {
throw new \LogicException('Fill a record to store a new story');
}
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new story');
}
$story->setRecord($this->record);
$story->setUser($this->user);
$manager->persist($story);
$manager->flush();
$this->story = $story;
$this->addReference('one-story', $story);
}
}

View File

@@ -1,48 +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\User;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\Persistence\ObjectManager;
use Alchemy\Phrasea\Model\Entities\User;
class LoadOneUser extends AbstractFixture implements FixtureInterface
{
/**
*
* @var User
*/
public $user;
public function load(ObjectManager $manager)
{
if (null === $this->user) {
throw new \Exception('Please set a user to persist');
}
$manager->persist($this->user);
$manager->flush();
$this->addReference('one-user', $this->user);
}
public function getUser()
{
return $this->user;
}
public function setUser(User $user)
{
$this->user = $user;
}
}

View File

@@ -1,41 +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\UsrLists;
use Alchemy\Phrasea\Model\Entities\UsrList;
use Doctrine\Common\DataFixtures\AbstractFixture;
abstract class ListAbstract extends AbstractFixture
{
protected $user;
protected $list;
public function getUser()
{
return $this->user;
}
public function setUser(\User_Adapter $user)
{
$this->user = $user;
}
public function getList()
{
return $this->list;
}
public function setList(UsrList $list)
{
$this->list = $list;
}
}

View File

@@ -1,47 +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\UsrLists;
use Alchemy\Phrasea\Model\Entities\UsrList as UsrListEntity;
use Alchemy\Phrasea\Model\Entities\UsrListOwner as UsrListOwnerEntity;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
class UsrList extends ListAbstract implements FixtureInterface
{
/**
*
* @var UsrList
*/
public $list;
public function load(ObjectManager $manager)
{
$list = new UsrListEntity();
$owner = $this->getReference('one-listowner');
$list->setName('new list');
$list->addOwner($owner);
/* @var $owner UsrListOwnerEntity */
$owner->setList($list);
$manager->persist($list);
$manager->merge($owner);
$manager->flush();
$this->list = $list;
$this->addReference('one-list', $list);
}
}

View File

@@ -1,49 +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\UsrLists;
use Alchemy\Phrasea\Model\Entities\UsrList as UsrListEntity;
use Alchemy\Phrasea\Model\Entities\UsrListEntry as UsrListEntryEntity;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
class UsrListEntry extends ListAbstract implements FixtureInterface
{
/**
* @var UsrListEntry
*/
public $entry;
public function load(ObjectManager $manager)
{
$entry = new UsrListEntryEntity();
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new basket');
}
$list = $this->getReference('one-list');
$entry->setUser($this->user);
$entry->setList($list);
/* @var $list UsrListEntity */
$list->addEntrie($entry);
$manager->persist($entry);
$manager->flush();
$this->entry = $entry;
$this->addReference('one-entry', $entry);
}
}

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\UsrLists;
use Alchemy\Phrasea\Model\Entities\UsrListOwner as UsrListOwnerEntity;
use Alchemy\Phrasea\Model\Entities\StoryWZ;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
class UsrListOwner extends ListAbstract implements FixtureInterface
{
/**
* @var StoryWZ
*/
public $owner;
public function load(ObjectManager $manager)
{
$owner = new UsrListOwnerEntity();
$owner->setRole(UsrListOwnerEntity::ROLE_ADMIN);
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new basket');
}
$owner->setUser($this->user);
$manager->persist($owner);
$manager->flush();
$this->owner = $owner;
$this->addReference('one-listowner', $owner);
}
}

View File

@@ -1,46 +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\ValidationParticipant;
use Alchemy\Phrasea\Model\Entities\ValidationParticipant;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
class LoadOneParticipant extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
*
* @var ValidationParticipant
*/
public $validationParticipant;
public function load(ObjectManager $manager)
{
$validationParticipant = new ValidationParticipant();
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new validation Session');
}
$validationParticipant->setParticipant($this->user);
$validationParticipant->setSession(
$this->getReference('one-validation-session')
);
$manager->persist($validationParticipant);
$manager->flush();
$this->validationParticipant = $validationParticipant;
$this->addReference('one-validation-participant', $validationParticipant);
}
}

View File

@@ -1,56 +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\ValidationParticipant;
use Alchemy\Phrasea\Model\Entities\ValidationParticipant;
use Alchemy\Phrasea\Model\Entities\ValidationSession;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
class LoadParticipantWithSession extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
* @var Participant
*/
public $validationParticipant;
/**
*
* @var ValidationSession
*/
private $session;
public function load(ObjectManager $manager)
{
$validationParticipant = new ValidationParticipant();
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new validation Session');
}
$validationParticipant->setUser($this->user);
if (null === $this->session) {
throw new \LogicException('Attach a session to the current participant');
}
$validationParticipant->setSession($this->session);
$manager->persist($validationParticipant);
$manager->flush();
$this->validationParticipant = $validationParticipant;
}
public function setSession(ValidationSession $session)
{
$this->session = $session;
}
}

View File

@@ -1,50 +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\ValidationSession;
use Alchemy\Phrasea\Model\Entities\ValidationSession as ValidationSessionEntity;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
class LoadOneValidationSession extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
*
* @var ValidationSessionEntity
*/
public $validationSession;
public function load(ObjectManager $manager)
{
$validationSession = new ValidationSessionEntity();
$validationSession->setBasket(
$this->getReference('one-basket') // load the one-basket stored reference
);
$expires = new \DateTime();
$expires->modify('+1 week');
$validationSession->setExpires($expires);
if (null === $this->user) {
throw new \LogicException('Fill a user to store a new validation Session');
}
$validationSession->setInitiator($this->user);
$manager->persist($validationSession);
$manager->flush();
$this->validationSession = $validationSession;
$this->addReference('one-validation-session', $validationSession);
}
}

View File

@@ -98,10 +98,7 @@ class UserTest extends \PhraseanetPHPUnitAbstract
public function testIsTemplate()
{
$this->assertFalse($this->user->isTemplate());
$template = new User();
$template->setLogin('login2');
$template->setPassword('toto');
$this->insertOneUser($template);
$template = $this->insertOneUser('login2');
$this->user->setModelOf($template);
$this->assertTrue($this->user->isTemplate());
}
@@ -120,15 +117,10 @@ class UserTest extends \PhraseanetPHPUnitAbstract
public function testSetModelOf()
{
$this->user->setLogin('login');
$this->user->setPassword('toto');
$user = new User();
$user->setLogin('login2');
$user->setPassword('toto');
$this->insertOneUser($this->user);
$this->insertOneUser($user);
$this->user->setModelOf($user);
$this->assertEquals('login2', $this->user->getModelOf()->getLogin());
$user1 = $this->insertOneUser('login');
$user2 = $this->insertOneUser('login2');
$user1->setModelOf($user2);
$this->assertEquals('login3', $user1->getModelOf()->getLogin());
}
public function genderProvider()

View File

@@ -8,37 +8,27 @@ class UserRepositoryTest extends \PhraseanetPHPUnitAbstract
{
public function testFindAdminsWithNoAdmins()
{
$user = new User();
$user->setLogin('login');
$user->setPassword('toto');
$this->insertOneUser($user);
$this->insertOneUser('login');
$users = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findAdmins();
$this->assertEquals(0, count($users));
}
public function testFindAdminsWithOneAdmin()
{
$user = new User();
$user->setLogin('login');
$user->setPassword('toto');
$user->setAdmin(true);
$this->insertOneUser($user);
$this->insertOneUser('login', null, true);
$users = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findAdmins();
$this->assertEquals(1, count($users));
}
public function testFindAdminsWithOneAdminButTemplate()
{
$user = new User();
$user->setLogin('login');
$user->setPassword('toto');
$user->setAdmin(true);
$user = $this->insertOneUser('login');
$template = $this->insertOneUser('login', null, true);
$template = new User();
$template->setLogin('logint');
$template->setPassword('totot');
$template->setModelOf($user);
$user->setModelOf($template);
self::$DI['app']['EM']->persist($template);
self::$DI['app']['EM']->flush();
$users = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findAdmins();
$this->assertEquals(0, count($users));
@@ -46,22 +36,19 @@ class UserRepositoryTest extends \PhraseanetPHPUnitAbstract
public function testFindAdminsWithOneAdminButDeleted()
{
$user = new User();
$user->setLogin('login');
$user->setPassword('toto');
$user->setAdmin(true);
$user = $this->insertOneUser('login', null, true);
$user->setDeleted(true);
self::$DI['app']['EM']->persist($user);
self::$DI['app']['EM']->flush();
$users = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findAdmins();
$this->assertEquals(0, count($users));
}
public function testFindByLogin()
{
$user = new User();
$user->setLogin('login');
$user->setPassword('toto');
$this->insertOneUser($user);
$this->insertOneUser('login');
$user = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByLogin('login');
$this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $user);
$this->assertNull(self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByLogin('wrong-login'));
@@ -69,36 +56,30 @@ class UserRepositoryTest extends \PhraseanetPHPUnitAbstract
public function testFindUserByEmail()
{
$user = new User();
$user->setLogin('login');
$user->setPassword('toto');
$user->setEmail('toto@toto.to');
$this->insertOneUser($user);
$this->insertOneUser('login', 'toto@toto.to');
$user = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByEmail('toto@toto.to');
$this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $user);
}
public function testFindUserByEmailButDeleted()
{
$user = new User();
$user->setLogin('login');
$user->setPassword('toto');
$user->setEmail('toto@toto.to');
$user = $this->insertOneUser('login', 'toto@toto.to');
$user->setDeleted(true);
$this->insertOneUser($user);
$user = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByEmail('toto@toto.to');
$this->assertNull($user);
self::$DI['app']['EM']->persist($user);
self::$DI['app']['EM']->flush();
$this->assertNull(self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByEmail('toto@toto.to'));
}
public function testFindUserByEmailButNullEmail()
{
$user = new User();
$user->setLogin('login');
$user->setPassword('toto');
$user->setEmail(null);
$user = $this->insertOneUser('login');
$user->setDeleted(true);
$this->insertOneUser($user);
$user = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByEmail('toto@toto.to');
$this->assertNull($user);
self::$DI['app']['EM']->persist($user);
self::$DI['app']['EM']->flush();
$this->assertNull(self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByEmail('toto@toto.to'));
}
}

View File

@@ -3,19 +3,25 @@
use Alchemy\Phrasea\CLI;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Border\File;
use Doctrine\Common\DataFixtures\Loader;
use Alchemy\Phrasea\Model\Entities\AggregateToken;
use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Entities\BasketElement;
use Alchemy\Phrasea\Model\Entities\Feed;
use Alchemy\Phrasea\Model\Entities\FeedEntry;
use Alchemy\Phrasea\Model\Entities\FeedItem;
use Alchemy\Phrasea\Model\Entities\FeedPublisher;
use Alchemy\Phrasea\Model\Entities\FeedToken;
use Alchemy\Phrasea\Model\Entities\LazaretFile;
use Alchemy\Phrasea\Model\Entities\LazaretSession;
use Alchemy\Phrasea\Model\Entities\Session;
use Alchemy\Phrasea\Model\Entities\Task;
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 Alchemy\Phrasea\Model\Entities\UsrListOwner;
use Alchemy\Phrasea\Model\Entities\UsrList;
use Alchemy\Phrasea\Model\Entities\UsrListEntry;
use Silex\WebTestCase;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Client;
@@ -113,7 +119,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
*/
public function __destruct()
{
self::deleteRessources();
self::deleteResources();
if (self::$time_start) {
self::$time_start = null;
@@ -270,6 +276,26 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$this->assertTrue(false !== stripos($response->getContent(), 'Sorry, the page you are looking for could not be found'));
}
protected function assertDateAtom($date)
{
return $this->assertRegExp('/\d{4}[-]\d{2}[-]\d{2}[T]\d{2}[:]\d{2}[:]\d{2}[+]\d{2}[:]\d{2}/', $date);
}
protected function set_user_agent($user_agent, Application $app)
{
$app['browser']->setUserAgent($user_agent);
$app->register(new \Silex\Provider\TwigServiceProvider());
$app->setupTwig();
self::$DI['client'] = self::$DI->share(function ($DI) use ($app) {
return new Client($app, []);
});
}
/**
* Inserts two tasks.
*
* @return Task[]
*/
public function insertTwoTasks()
{
$task1 = new Task();
@@ -285,61 +311,23 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
self::$DI['app']['EM']->persist($task1);
self::$DI['app']['EM']->persist($task2);
self::$DI['app']['EM']->flush();
return [$task1, $task2];
}
/**
* Insert fixture contained in the specified fixtureLoader
* into sqlLite test temporary database
* Inserts one basket.
*
* @param Doctrine\Common\DataFixtures\Loader $fixtureLoader
*/
public function insertFixtureInDatabase(Doctrine\Common\DataFixtures\Loader $fixtureLoader, $append = true)
{
$purger = new Doctrine\Common\DataFixtures\Purger\ORMPurger();
$executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor(self::$DI['app']['EM'], $purger);
$executor->execute($fixtureLoader->getFixtures(), $append);
self::$DI['client'] = self::$DI->share(function ($DI) {
return new Client($DI['app'], []);
});
}
/**
* Purge sqlLite test temporary database by truncate all existing tables
*/
protected static function purgeDatabase()
{
$purger = new Doctrine\Common\DataFixtures\Purger\ORMPurger();
$executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor(self::$DI['app']['EM'], $purger);
$executor->execute([]);
self::$DI['app']["phraseanet.cache-service"]->flushAll();
}
protected function assertDateAtom($date)
{
return $this->assertRegExp('/\d{4}[-]\d{2}[-]\d{2}[T]\d{2}[:]\d{2}[:]\d{2}[+]\d{2}[:]\d{2}/', $date);
}
protected function set_user_agent($user_agent, Alchemy\Phrasea\Application $app)
{
$app['browser']->setUserAgent($user_agent);
$app->register(new \Silex\Provider\TwigServiceProvider());
$app->setupTwig();
self::$DI['client'] = self::$DI->share(function ($DI) use ($app) {
return new Client($app, []);
});
}
/**
* Insert one basket entry ans set current authenticated user as owner
* @param User_Adapter $user
*
* @return \Alchemy\Phrasea\Model\Entities\Basket
* @return Basket
*/
protected function insertOneBasket(\User_Adapter $user = null)
{
$basket = new Basket();
$basket->setOwner($user ?: self::$DI['user']);
$basket->setName('test');
$basket->setName('description test');
$basket->setDescription('description test');
self::$DI['app']['EM']->persist($basket);
self::$DI['app']['EM']->flush();
@@ -348,54 +336,57 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}
/**
* Insert one feed
* Inserts one feed.
*
* @return \Alchemy\Phrasea\Model\Entities\Feed
* @param User_Adapter $user
* @param string|null $title
* @param bool $public
*
* @return Feed
*/
protected function insertOneFeed(\User_Adapter $user, $title = null, $public = null)
protected function insertOneFeed(\User_Adapter $user = null , $title = null, $public = false)
{
try {
$feedFixture = new PhraseaFixture\Feed\LoadOneFeed();
$feedFixture->setUser($user);
$feed = new Feed();
$publisher = new FeedPublisher();
if ($title !== null) {
$feedFixture->setTitle($title);
}
$user = $user ?: self::$DI['user'];
if ($public !== null) {
$feedFixture->setPublic($public);
}
$publisher->setUsrId($user->get_id());
$publisher->setIsOwner(true);
$publisher->setFeed($feed);
$loader = new Loader();
$loader->addFixture($feedFixture);
$feed->addPublisher($publisher);
$feed->setTitle($title ?: "test");
$feed->setIsPublic($public);
$feed->setSubtitle("description");
$this->insertFixtureInDatabase($loader);
self::$DI['app']['EM']->persist($feed);
self::$DI['app']['EM']->persist($publisher);
self::$DI['app']['EM']->flush();
return $feedFixture->feed;
} catch (\Exception $e) {
$this->fail('Fail to load one Feed : ' . $e->getMessage());
}
return $feed;
}
/**
* Inserts one feed entry.
*
* @return \Alchemy\Phrasea\Model\Entities\FeedEntry
* @param User_Adapter $user
* @param bool $public
*
* @return FeedEntry
*/
protected function insertOneFeedEntry(\User_Adapter $user, $public = false)
protected function insertOneFeedEntry(\User_Adapter $user = null, $public = false)
{
try {
$feed = $this->insertOneFeed($user, '', $public);
$feed = $this->insertOneFeed($user, null, $public);
$em = self::$DI['app']['EM'];
$entry = new \Alchemy\Phrasea\Model\Entities\FeedEntry();
$entry = new FeedEntry();
$entry->setFeed($feed);
$entry->setTitle("test");
$entry->setSubtitle("description");
$entry->setAuthorName('user');
$entry->setAuthorEmail('user@email.com');
$publisher = $feed->getPublisher($user);
$publisher = $feed->getPublisher($user ?: self::$DI['user']);
if ($publisher !== null) {
$entry->setPublisher($publisher);
@@ -403,20 +394,25 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$feed->addEntry($entry);
$em->persist($entry);
$em->persist($feed);
$em->flush();
self::$DI['app']['EM']->persist($entry);
self::$DI['app']['EM']->persist($feed);
self::$DI['app']['EM']->flush();
return $entry;
} catch (\Exception $e) {
$this->fail('Fail to load one FeedEntry : ' . $e->getMessage());
}
}
protected function insertOneFeedToken(Feed $feed, \User_Adapter $user)
/**
* Inserts one feed token.
*
* @param Feed $feed
* @param User_Adapter $user
*
* @return FeedToken
*/
protected function insertOneFeedToken(Feed $feed, \User_Adapter $user = null)
{
try {
$user = $user ?: self::$DI['user'];
$token = new FeedToken();
$token->setValue(self::$DI['app']['tokens']->generatePassword(12));
$token->setFeed($feed);
@@ -427,41 +423,47 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
self::$DI['app']['EM']->persist($token);
self::$DI['app']['EM']->persist($feed);
self::$DI['app']['EM']->flush();
} catch (\Exception $e) {
$this->fail('Fail to load one FeedToken : ' . $e->getMessage());
}
return $token;
}
protected function insertOneAggregateToken(\User_Adapter $user)
/**
* Insert one aggregate token.
*
* @param User_Adapter $user
*
* @return AggregateToken
*/
protected function insertOneAggregateToken(\User_Adapter $user = null)
{
try {
$user = $user ?: self::$DI['user'];
$token = new AggregateToken();
$token->setValue(self::$DI['app']['tokens']->generatePassword(12));
$token->setUsrId($user->get_id());
self::$DI['app']['EM']->persist($token);
self::$DI['app']['EM']->flush();
} catch (\Exception $e) {
$this->fail('Fail to load one AggregateToken : ' . $e->getMessage());
}
return $token;
}
/**
* Inserts one feed item.
*
* @return \Alchemy\Phrasea\Model\Entities\FeedItem
* @param User_Adapter $user
* @param boolean $public
* @param integer $qty
* @param record_adapter $record
*
* @return FeedItem
*/
protected function insertOneFeedItem(\User_Adapter $user, $public = false, $qty = 1, \record_adapter $record = null)
protected function insertOneFeedItem(\User_Adapter $user = null, $public = false, $qty = 1, \record_adapter $record = null)
{
try {
$em = self::$DI['app']['EM'];
$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) {
@@ -473,125 +475,135 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$item->setRecordId($actual->get_record_id());
$item->setSbasId($actual->get_sbas_id());
$item->setEntry($entry);
$entry->addItem($item);
$em->persist($item);
self::$DI['app']['EM']->persist($item);
}
$em->persist($entry);
$em->flush();
} catch (\Exception $e) {
$this->fail('Fail to load one FeedEntry : ' . $e->getMessage());
}
self::$DI['app']['EM']->persist($entry);
self::$DI['app']['EM']->flush();
return $item;
}
/**
* Insert one basket entry ans set current authenticated user as owner
* Inserts one lazaret file.
*
* @return \Alchemy\Phrasea\Model\Entities\Basket
* @param User_Adapter $user
*
* @return LazaretFile
*/
protected function insertOneLazaretFile()
protected function insertOneLazaretFile(\User_Adapter $user = null)
{
try {
$lazaretFixture = new PhraseaFixture\Lazaret\LoadOneFile();
$user = $user ?: self::$DI['user'];
$lazaretFixture->setUser(self::$DI['user']);
$lazaretFixture->setCollectionId(self::$DI['collection']->get_base_id());
$lazaretSession = new LazaretSession();
$lazaretSession->setUsrId($user->get_id());
$lazaretSession->setUpdated(new \DateTime('now'));
$lazaretSession->setCreated(new \DateTime('-1 day'));
$loader = new Loader();
$loader->addFixture($lazaretFixture);
$lazaretFile = new LazaretFile();
$lazaretFile->setOriginalName('test');
$lazaretFile->setFilename('test.jpg');
$lazaretFile->setThumbFilename('thumb_test.jpg');
$lazaretFile->setBaseId(self::$DI['collection']->get_base_id());
$lazaretFile->setSession($lazaretSession);
$lazaretFile->setSha256('3191af52748620e0d0da50a7b8020e118bd8b8a0845120b0bb');
$lazaretFile->setUuid('7b8ef0e3-dc8f-4b66-9e2f-bd049d175124');
$lazaretFile->setCreated(new \DateTime('now'));
$lazaretFile->setUpdated(new \DateTime('-1 day'));
$this->insertFixtureInDatabase($loader);
self::$DI['app']['EM']->persist($lazaretFile);
self::$DI['app']['EM']->flush();
return $lazaretFixture->file;
} catch (\Exception $e) {
$this->fail('Fail load one Basket : ' . $e->getMessage());
}
}
return $lazaretFile;
protected function insertOneUsrList(\User_Adapter $user)
{
try {
$loader = new Loader();
$UsrOwner = new PhraseaFixture\UsrLists\UsrListOwner();
$UsrOwner->setUser($user);
$loader->addFixture($UsrOwner);
$UsrList = new PhraseaFixture\UsrLists\UsrList();
$loader->addFixture($UsrList);
$this->insertFixtureInDatabase($loader);
return $UsrList->list;
} catch (\Exception $e) {
$this->fail('Fail load one UsrList : ' . $e->getMessage());
}
}
/**
* Inserts one user list.
*
* @param \Alchemy\Phrasea\Model\Entities\UsrList $UsrList
* @return \Alchemy\Phrasea\Model\Entities\UsrListEntry
* @param User_Adapter $user
*
* @return UsrListOwner
*/
protected function insertOneUsrList(\User_Adapter $user = null)
{
$user = $user ?: self::$DI['user'];
$owner = new UsrListOwner();
$owner->setRole(UsrListOwner::ROLE_ADMIN);
$owner->setUser($user);
self::$DI['app']['EM']->persist($owner);
self::$DI['app']['EM']->flush();
return $owner;
}
/**
* Insert one user list entry.
*
* @param User_adapter $owner
* @param User_adapter $user
*
* @return UsrListEntry
*/
protected function insertOneUsrListEntry(\User_adapter $owner, \User_adapter $user)
{
try {
$loader = new Loader();
$listOwner = new UsrListOwner();
$listOwner->setRole(UsrListOwner::ROLE_ADMIN);
$listOwner->setUser($owner);
$UsrOwner = new PhraseaFixture\UsrLists\UsrListOwner();
$UsrOwner->setUser($owner);
$list = new UsrList();
$list->addOwner($listOwner);
$loader->addFixture($UsrOwner);
$listOwner->setList($list);
$UsrList = new PhraseaFixture\UsrLists\UsrList();
$entry = new UsrListEntry();
$entry->setUser($user);
$entry->setList($list);
$loader->addFixture($UsrList);
$list->addEntrie($entry);
$UsrEntry = new PhraseaFixture\UsrLists\UsrListEntry();
self::$DI['app']['EM']->persist($entry);
self::$DI['app']['EM']->persist($list);
self::$DI['app']['EM']->persist($listOwner);
self::$DI['app']['EM']->flush();
$UsrEntry->setUser($user);
$loader->addFixture($UsrEntry);
$this->insertFixtureInDatabase($loader);
return $UsrEntry->entry;
} catch (\Exception $e) {
$this->fail('Fail load one UsrListEntry : ' . $e->getMessage());
}
return $entry;
}
/**
* Insert five baskets and set current authenticated user as owner
* Inserts five baskets.
*
* @return \Alchemy\Phrasea\Model\Entities\Basket
* @return Basket[]
*/
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->setOwner(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;
}
/**
* @return \Alchemy\Phrasea\Model\Entities\BasketElement
* Inserts one basket element.
*
* @param User_Adapter $user
* @param record_adapter $record
*
* @return BasketElement
*/
protected function insertOneBasketElement(\User_Adapter $user = null, \record_adapter $record = null)
{
@@ -602,67 +614,66 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$basket->addElement($element);
$element->setBasket($basket);
self::$DI['app']['EM']->persist($element);
self::$DI['app']['EM']->persist($basket);
self::$DI['app']['EM']->flush();
return $element;
}
/**
* Inserts one validation basket.
*
* @return \Alchemy\Phrasea\Model\Entities\Basket
* @param array $parameters
*
* @return Basket
*/
protected function insertOneValidationBasket(array $parameters = [])
{
$em = self::$DI['app']['EM'];
$basketElement = $this->insertOneBasketElement();
$basket = $basketElement->getBasket();
$Validation = new Alchemy\Phrasea\Model\Entities\ValidationSession();
$Validation->setBasket($basket);
$Validation->setInitiator(self::$DI['user']);
$validation = new ValidationSession();
$validation->setBasket($basket);
$validation->setInitiator(self::$DI['user']);
if (isset($parameters['expires']) && $parameters['expires'] instanceof \DateTime) {
$Validation->setExpires($parameters['expires']);
$validation->setExpires($parameters['expires']);
}
$basket->setValidation($Validation);
$em->persist($Validation);
$em->merge($basket);
$basket->setValidation($validation);
$Participant = new Alchemy\Phrasea\Model\Entities\ValidationParticipant();
$Participant->setUser(self::$DI['user']);
$Participant->setCanAgree(true);
$Participant->setCanSeeOthers(true);
$participant = new ValidationParticipant();
$participant->setUser(self::$DI['user']);
$participant->setCanAgree(true);
$participant->setCanSeeOthers(true);
$Validation->addParticipant($Participant);
$Participant->setSession($Validation);
$validation->addParticipant($participant);
$participant->setSession($validation);
$em->persist($Participant);
$em->merge($Validation);
$data = new ValidationData();
$data->setBasketElement($basketElement);
$data->setParticipant($participant);
$basketElement->addValidationData($data);
$Data = new Alchemy\Phrasea\Model\Entities\ValidationData();
$Data->setBasketElement($basketElement);
$Data->setParticipant($Participant);
$basketElement->addValidationData($Data);
self::$DI['app']['EM']->persist($basket);
self::$DI['app']['EM']->persist($validation);
self::$DI['app']['EM']->persist($participant);
self::$DI['app']['EM']->persist($data);
self::$DI['app']['EM']->persist($basketElement);
$em->persist($Data);
$em->merge($basketElement);
$em->flush();
self::$DI['app']['EM']->flush();
return $basket;
}
/**
* Create a new basket with current auhtenticated user as owner
* Create a new sessionValidation with the newly created basket
* Set current authenticated user as sessionValidation initiator
* Add 2 records as elments of the newly created basket
* Add 2 participants to the newly created sessionValidation
* - Creates a new basket with current authenticated user as owner.
* - Creates a new sessionValidation with the newly created basket.
* - Sets current authenticated user as sessionValidation initiator.
* - Adds 2 records as elements of the newly created basket.
* - Adds 2 participants to the newly created sessionValidation.
*
* @return \Alchemy\Phrasea\Model\Entities\Basket
* @return Basket
*/
protected function insertOneBasketEnv()
{
@@ -670,6 +681,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$basket->setName('test');
$basket->setDescription('description');
$basket->setOwner(self::$DI['user']);
self::$DI['app']['EM']->persist($basket);
foreach ([self::$DI['record_1'], self::$DI['record_2']] as $record) {
@@ -702,58 +714,72 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}
/**
* Load One WZ with
* One basket
* One story
* One ValidationSession & one participant
* @return
* Inserts one story.
*
* @param User_Adapter $user
* @param record_adapter $record
*
* @return StoryWZ
*/
protected function insertOneStory(User_Adapter $user = null, \record_adapter $record = null)
{
$story = new StoryWZ();
$story->setRecord($record ?: self::$DI['record_1']);
$story->setUser($user ?: self::$DI['user']);
self::$DI['app']['EM']->persist($story);
self::$DI['app']['EM']->flush();
return $story;
}
/**
* Inserts one validation session.
*
* @param Basket $basket
* @param User_Adapter $user
*
* @return ValidationSession
*/
protected function insertOneValidationSession(Basket $basket = null, \User_Adapter $user = null)
{
$validationSession = new ValidationSession();
$validationSession->setBasket($basket ?: $this->insertOneBasket());
$expires = new \DateTime();
$expires->modify('+1 week');
$validationSession->setExpires($expires);
$validationSession->setInitiator($user ?: self::$DI['user']);
self::$DI['app']['EM']->persist($validationSession);
self::$DI['app']['EM']->flush();
return $validationSession;
}
/**
* Loads One WZ with one basket, one story and one ValidationSession with one participant.
*/
protected function insertOneWZ()
{
try {
$currentUser = self::$DI['user'];
$altUser = self::$DI['user_alt1'];
// add one basket
$basket = new PhraseaFixture\Basket\LoadOneBasket();
$basket->setUser($currentUser);
//add one story
$story = new PhraseaFixture\Story\LoadOneStory();
$story->setUser($currentUser);
$story->setRecord(self::$DI['record_1']);
//add a validation session initiated by alt user
$validationSession = new PhraseaFixture\ValidationSession\LoadOneValidationSession();
$validationSession->setUser($altUser);
$loader = new Loader();
$loader->addFixture($basket);
$loader->addFixture($story);
$loader->addFixture($validationSession);
$this->insertFixtureInDatabase($loader);
} catch (\Exception $e) {
$this->fail('Fail load one WorkingZone : ' . $e->getMessage());
$this->insertOneStory();
$this->insertOneValidationSession($this->insertOneBasket(), self::$DI['user_alt1']);
}
return;
}
protected function insertOneUser(User $user)
/**
* Inserts one user.
*
* @param string $login
* @param null $email
* @param bool $admin
*
* @return User
*/
protected function insertOneUser($login, $email = null, $admin = false)
{
try {
$userFixture = new PhraseaFixture\User\LoadOneUser();
$userFixture->setUser($user);
$loader = new Loader();
$loader->addFixture($userFixture);
$this->insertFixtureInDatabase($loader);
} catch (\Exception $e) {
$this->fail('Fail load one User : ' . $e->getMessage());
}
return self::$DI['app']['manipulator.user']->create($login, uniqid('pass'), $email, $admin);
}
/**
@@ -762,7 +788,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
* @param string $method The request method
* @param string $uri The URI to fetch
* @param array $parameters The Request parameters
* @param array $httpAccept Contents of the Accept header
* @param string $httpAccept Contents of the Accept header
*
* @return Crawler
*/
@@ -775,13 +801,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}
/**
* Update the sql tables with the current schema
* @return void
* Updates the sql tables with the current schema.
*/
private static function updateTablesSchema(Application $application)
{
if (!self::$updated) {
if (file_exists(Setup_Upgrade::get_lock_file())) {
unlink(Setup_Upgrade::get_lock_file());
}
@@ -813,12 +837,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}
/**
* Create a set of users for the test suite
* Creates a set of users for the test suite.
*
* self::$DI['user']
* self::$DI['user_alt1']
* self::$DI['user_alt2']
*
* @return void;
*/
private static function createSetOfUserTests(Application $application)
{
@@ -870,7 +893,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}
/**
* Give Bases Rights to User
* Gives Bases Rights to User.
*
* @param \User_Adapter $user
*/
@@ -923,8 +946,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}
/**
* Set self::$DI['collection']
* @return void
* Sets self::$DI['collection'].
*/
private static function setCollection(Application $application)
{
@@ -998,7 +1020,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}
/**
* Generate a set of records for the current tests suites
* Generates a set of records for the current tests suites.
*/
private static function generateRecords(Application $app)
{
@@ -1087,11 +1109,9 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}
/**
* Delete previously created Ressources
*
* @return void
* Deletes previously created Resources.
*/
private static function deleteRessources()
private static function deleteResources()
{
$skipped = \PhraseanetPHPUnitListener::getSkipped();
@@ -1116,6 +1136,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
return;
}
/**
* Authenticates self::['user'] against application.
*
* @param Application $app
*/
protected function authenticate(Application $app)
{
$app['session']->clear();
@@ -1131,6 +1156,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
self::$DI['app']['authentication']->reinitUser();
}
/**
* Logout authenticated user from application.
*
* @param Application $app
*/
protected function logout(Application $app)
{
$app['session']->clear();