mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 04:53:26 +00:00
Remove DoctrineFixtures mechanism
This commit is contained in:
@@ -46,7 +46,6 @@
|
|||||||
"doctrine/migrations" : "1.0.x-dev@dev"
|
"doctrine/migrations" : "1.0.x-dev@dev"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"doctrine/data-fixtures" : "1.0.x@dev",
|
|
||||||
"phpunit/phpunit" : "~3.7",
|
"phpunit/phpunit" : "~3.7",
|
||||||
"behat/behat" : "2.5.x-dev@dev",
|
"behat/behat" : "2.5.x-dev@dev",
|
||||||
"behat/gherkin" : "2.3.x-dev@dev",
|
"behat/gherkin" : "2.3.x-dev@dev",
|
||||||
@@ -69,8 +68,7 @@
|
|||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-0": {
|
||||||
"" : "lib/classes",
|
"" : "lib/classes",
|
||||||
"Alchemy" : "lib",
|
"Alchemy" : "lib"
|
||||||
"PhraseaFixture" : "lib/conf.d"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include-path": ["vendor/zend/gdata/library"],
|
"include-path": ["vendor/zend/gdata/library"],
|
||||||
|
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -98,10 +98,7 @@ class UserTest extends \PhraseanetPHPUnitAbstract
|
|||||||
public function testIsTemplate()
|
public function testIsTemplate()
|
||||||
{
|
{
|
||||||
$this->assertFalse($this->user->isTemplate());
|
$this->assertFalse($this->user->isTemplate());
|
||||||
$template = new User();
|
$template = $this->insertOneUser('login2');
|
||||||
$template->setLogin('login2');
|
|
||||||
$template->setPassword('toto');
|
|
||||||
$this->insertOneUser($template);
|
|
||||||
$this->user->setModelOf($template);
|
$this->user->setModelOf($template);
|
||||||
$this->assertTrue($this->user->isTemplate());
|
$this->assertTrue($this->user->isTemplate());
|
||||||
}
|
}
|
||||||
@@ -120,15 +117,10 @@ class UserTest extends \PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
public function testSetModelOf()
|
public function testSetModelOf()
|
||||||
{
|
{
|
||||||
$this->user->setLogin('login');
|
$user1 = $this->insertOneUser('login');
|
||||||
$this->user->setPassword('toto');
|
$user2 = $this->insertOneUser('login2');
|
||||||
$user = new User();
|
$user1->setModelOf($user2);
|
||||||
$user->setLogin('login2');
|
$this->assertEquals('login3', $user1->getModelOf()->getLogin());
|
||||||
$user->setPassword('toto');
|
|
||||||
$this->insertOneUser($this->user);
|
|
||||||
$this->insertOneUser($user);
|
|
||||||
$this->user->setModelOf($user);
|
|
||||||
$this->assertEquals('login2', $this->user->getModelOf()->getLogin());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function genderProvider()
|
public function genderProvider()
|
||||||
|
@@ -8,37 +8,27 @@ class UserRepositoryTest extends \PhraseanetPHPUnitAbstract
|
|||||||
{
|
{
|
||||||
public function testFindAdminsWithNoAdmins()
|
public function testFindAdminsWithNoAdmins()
|
||||||
{
|
{
|
||||||
$user = new User();
|
$this->insertOneUser('login');
|
||||||
$user->setLogin('login');
|
|
||||||
$user->setPassword('toto');
|
|
||||||
$this->insertOneUser($user);
|
|
||||||
$users = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findAdmins();
|
$users = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findAdmins();
|
||||||
$this->assertEquals(0, count($users));
|
$this->assertEquals(0, count($users));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFindAdminsWithOneAdmin()
|
public function testFindAdminsWithOneAdmin()
|
||||||
{
|
{
|
||||||
$user = new User();
|
$this->insertOneUser('login', null, true);
|
||||||
$user->setLogin('login');
|
|
||||||
$user->setPassword('toto');
|
|
||||||
$user->setAdmin(true);
|
|
||||||
$this->insertOneUser($user);
|
|
||||||
$users = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findAdmins();
|
$users = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findAdmins();
|
||||||
$this->assertEquals(1, count($users));
|
$this->assertEquals(1, count($users));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFindAdminsWithOneAdminButTemplate()
|
public function testFindAdminsWithOneAdminButTemplate()
|
||||||
{
|
{
|
||||||
$user = new User();
|
$user = $this->insertOneUser('login');
|
||||||
$user->setLogin('login');
|
$template = $this->insertOneUser('login', null, true);
|
||||||
$user->setPassword('toto');
|
|
||||||
$user->setAdmin(true);
|
|
||||||
|
|
||||||
$template = new User();
|
$template->setModelOf($user);
|
||||||
$template->setLogin('logint');
|
|
||||||
$template->setPassword('totot');
|
|
||||||
|
|
||||||
$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();
|
$users = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findAdmins();
|
||||||
$this->assertEquals(0, count($users));
|
$this->assertEquals(0, count($users));
|
||||||
@@ -46,22 +36,19 @@ class UserRepositoryTest extends \PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
public function testFindAdminsWithOneAdminButDeleted()
|
public function testFindAdminsWithOneAdminButDeleted()
|
||||||
{
|
{
|
||||||
$user = new User();
|
$user = $this->insertOneUser('login', null, true);
|
||||||
$user->setLogin('login');
|
|
||||||
$user->setPassword('toto');
|
|
||||||
$user->setAdmin(true);
|
|
||||||
$user->setDeleted(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();
|
$users = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findAdmins();
|
||||||
$this->assertEquals(0, count($users));
|
$this->assertEquals(0, count($users));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFindByLogin()
|
public function testFindByLogin()
|
||||||
{
|
{
|
||||||
$user = new User();
|
$this->insertOneUser('login');
|
||||||
$user->setLogin('login');
|
|
||||||
$user->setPassword('toto');
|
|
||||||
$this->insertOneUser($user);
|
|
||||||
$user = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByLogin('login');
|
$user = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByLogin('login');
|
||||||
$this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $user);
|
$this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $user);
|
||||||
$this->assertNull(self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByLogin('wrong-login'));
|
$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()
|
public function testFindUserByEmail()
|
||||||
{
|
{
|
||||||
$user = new User();
|
$this->insertOneUser('login', 'toto@toto.to');
|
||||||
$user->setLogin('login');
|
|
||||||
$user->setPassword('toto');
|
|
||||||
$user->setEmail('toto@toto.to');
|
|
||||||
$this->insertOneUser($user);
|
|
||||||
$user = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByEmail('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);
|
$this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFindUserByEmailButDeleted()
|
public function testFindUserByEmailButDeleted()
|
||||||
{
|
{
|
||||||
$user = new User();
|
$user = $this->insertOneUser('login', 'toto@toto.to');
|
||||||
$user->setLogin('login');
|
|
||||||
$user->setPassword('toto');
|
|
||||||
$user->setEmail('toto@toto.to');
|
|
||||||
$user->setDeleted(true);
|
$user->setDeleted(true);
|
||||||
$this->insertOneUser($user);
|
|
||||||
$user = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByEmail('toto@toto.to');
|
self::$DI['app']['EM']->persist($user);
|
||||||
$this->assertNull($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()
|
public function testFindUserByEmailButNullEmail()
|
||||||
{
|
{
|
||||||
$user = new User();
|
$user = $this->insertOneUser('login');
|
||||||
$user->setLogin('login');
|
|
||||||
$user->setPassword('toto');
|
|
||||||
$user->setEmail(null);
|
|
||||||
$user->setDeleted(true);
|
$user->setDeleted(true);
|
||||||
$this->insertOneUser($user);
|
|
||||||
$user = self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByEmail('toto@toto.to');
|
self::$DI['app']['EM']->persist($user);
|
||||||
$this->assertNull($user);
|
self::$DI['app']['EM']->flush();
|
||||||
|
|
||||||
|
$this->assertNull(self::$DI['app']['EM']->getRepository('Alchemy\Phrasea\Model\Entities\User')->findByEmail('toto@toto.to'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,19 +3,25 @@
|
|||||||
use Alchemy\Phrasea\CLI;
|
use Alchemy\Phrasea\CLI;
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Border\File;
|
use Alchemy\Phrasea\Border\File;
|
||||||
use Doctrine\Common\DataFixtures\Loader;
|
|
||||||
use Alchemy\Phrasea\Model\Entities\AggregateToken;
|
use Alchemy\Phrasea\Model\Entities\AggregateToken;
|
||||||
use Alchemy\Phrasea\Model\Entities\Basket;
|
use Alchemy\Phrasea\Model\Entities\Basket;
|
||||||
use Alchemy\Phrasea\Model\Entities\BasketElement;
|
use Alchemy\Phrasea\Model\Entities\BasketElement;
|
||||||
use Alchemy\Phrasea\Model\Entities\Feed;
|
use Alchemy\Phrasea\Model\Entities\Feed;
|
||||||
use Alchemy\Phrasea\Model\Entities\FeedEntry;
|
use Alchemy\Phrasea\Model\Entities\FeedEntry;
|
||||||
use Alchemy\Phrasea\Model\Entities\FeedItem;
|
use Alchemy\Phrasea\Model\Entities\FeedItem;
|
||||||
|
use Alchemy\Phrasea\Model\Entities\FeedPublisher;
|
||||||
use Alchemy\Phrasea\Model\Entities\FeedToken;
|
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\Session;
|
||||||
use Alchemy\Phrasea\Model\Entities\Task;
|
use Alchemy\Phrasea\Model\Entities\Task;
|
||||||
use Alchemy\Phrasea\Model\Entities\User;
|
use Alchemy\Phrasea\Model\Entities\User;
|
||||||
|
use Alchemy\Phrasea\Model\Entities\ValidationData;
|
||||||
use Alchemy\Phrasea\Model\Entities\ValidationSession;
|
use Alchemy\Phrasea\Model\Entities\ValidationSession;
|
||||||
use Alchemy\Phrasea\Model\Entities\ValidationParticipant;
|
use Alchemy\Phrasea\Model\Entities\ValidationParticipant;
|
||||||
|
use Alchemy\Phrasea\Model\Entities\UsrListOwner;
|
||||||
|
use Alchemy\Phrasea\Model\Entities\UsrList;
|
||||||
|
use Alchemy\Phrasea\Model\Entities\UsrListEntry;
|
||||||
use Silex\WebTestCase;
|
use Silex\WebTestCase;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Client;
|
use Symfony\Component\HttpKernel\Client;
|
||||||
@@ -113,7 +119,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
self::deleteRessources();
|
self::deleteResources();
|
||||||
|
|
||||||
if (self::$time_start) {
|
if (self::$time_start) {
|
||||||
self::$time_start = null;
|
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'));
|
$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()
|
public function insertTwoTasks()
|
||||||
{
|
{
|
||||||
$task1 = new Task();
|
$task1 = new Task();
|
||||||
@@ -285,61 +311,23 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
self::$DI['app']['EM']->persist($task1);
|
self::$DI['app']['EM']->persist($task1);
|
||||||
self::$DI['app']['EM']->persist($task2);
|
self::$DI['app']['EM']->persist($task2);
|
||||||
self::$DI['app']['EM']->flush();
|
self::$DI['app']['EM']->flush();
|
||||||
|
|
||||||
|
return [$task1, $task2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert fixture contained in the specified fixtureLoader
|
* Inserts one basket.
|
||||||
* into sqlLite test temporary database
|
|
||||||
*
|
*
|
||||||
* @param Doctrine\Common\DataFixtures\Loader $fixtureLoader
|
* @param User_Adapter $user
|
||||||
*/
|
|
||||||
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
|
|
||||||
*
|
*
|
||||||
* @return \Alchemy\Phrasea\Model\Entities\Basket
|
* @return Basket
|
||||||
*/
|
*/
|
||||||
protected function insertOneBasket(\User_Adapter $user = null)
|
protected function insertOneBasket(\User_Adapter $user = null)
|
||||||
{
|
{
|
||||||
$basket = new Basket();
|
$basket = new Basket();
|
||||||
$basket->setOwner($user ?: self::$DI['user']);
|
$basket->setOwner($user ?: self::$DI['user']);
|
||||||
$basket->setName('test');
|
$basket->setName('test');
|
||||||
$basket->setName('description test');
|
$basket->setDescription('description test');
|
||||||
|
|
||||||
self::$DI['app']['EM']->persist($basket);
|
self::$DI['app']['EM']->persist($basket);
|
||||||
self::$DI['app']['EM']->flush();
|
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 {
|
$feed = new Feed();
|
||||||
$feedFixture = new PhraseaFixture\Feed\LoadOneFeed();
|
$publisher = new FeedPublisher();
|
||||||
$feedFixture->setUser($user);
|
|
||||||
|
|
||||||
if ($title !== null) {
|
$user = $user ?: self::$DI['user'];
|
||||||
$feedFixture->setTitle($title);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($public !== null) {
|
$publisher->setUsrId($user->get_id());
|
||||||
$feedFixture->setPublic($public);
|
$publisher->setIsOwner(true);
|
||||||
}
|
$publisher->setFeed($feed);
|
||||||
|
|
||||||
$loader = new Loader();
|
$feed->addPublisher($publisher);
|
||||||
$loader->addFixture($feedFixture);
|
$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;
|
return $feed;
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->fail('Fail to load one Feed : ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 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, null, $public);
|
||||||
$feed = $this->insertOneFeed($user, '', $public);
|
|
||||||
|
|
||||||
$em = self::$DI['app']['EM'];
|
$entry = new FeedEntry();
|
||||||
|
|
||||||
$entry = new \Alchemy\Phrasea\Model\Entities\FeedEntry();
|
|
||||||
$entry->setFeed($feed);
|
$entry->setFeed($feed);
|
||||||
$entry->setTitle("test");
|
$entry->setTitle("test");
|
||||||
$entry->setSubtitle("description");
|
$entry->setSubtitle("description");
|
||||||
$entry->setAuthorName('user');
|
$entry->setAuthorName('user');
|
||||||
$entry->setAuthorEmail('user@email.com');
|
$entry->setAuthorEmail('user@email.com');
|
||||||
|
|
||||||
$publisher = $feed->getPublisher($user);
|
$publisher = $feed->getPublisher($user ?: self::$DI['user']);
|
||||||
|
|
||||||
if ($publisher !== null) {
|
if ($publisher !== null) {
|
||||||
$entry->setPublisher($publisher);
|
$entry->setPublisher($publisher);
|
||||||
@@ -403,20 +394,25 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
|
|
||||||
$feed->addEntry($entry);
|
$feed->addEntry($entry);
|
||||||
|
|
||||||
$em->persist($entry);
|
self::$DI['app']['EM']->persist($entry);
|
||||||
$em->persist($feed);
|
self::$DI['app']['EM']->persist($feed);
|
||||||
|
self::$DI['app']['EM']->flush();
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
return $entry;
|
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 = new FeedToken();
|
||||||
$token->setValue(self::$DI['app']['tokens']->generatePassword(12));
|
$token->setValue(self::$DI['app']['tokens']->generatePassword(12));
|
||||||
$token->setFeed($feed);
|
$token->setFeed($feed);
|
||||||
@@ -427,41 +423,47 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
self::$DI['app']['EM']->persist($token);
|
self::$DI['app']['EM']->persist($token);
|
||||||
self::$DI['app']['EM']->persist($feed);
|
self::$DI['app']['EM']->persist($feed);
|
||||||
self::$DI['app']['EM']->flush();
|
self::$DI['app']['EM']->flush();
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->fail('Fail to load one FeedToken : ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return $token;
|
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 = new AggregateToken();
|
||||||
$token->setValue(self::$DI['app']['tokens']->generatePassword(12));
|
$token->setValue(self::$DI['app']['tokens']->generatePassword(12));
|
||||||
$token->setUsrId($user->get_id());
|
$token->setUsrId($user->get_id());
|
||||||
|
|
||||||
self::$DI['app']['EM']->persist($token);
|
self::$DI['app']['EM']->persist($token);
|
||||||
self::$DI['app']['EM']->flush();
|
self::$DI['app']['EM']->flush();
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->fail('Fail to load one AggregateToken : ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return $token;
|
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);
|
$entry = $this->insertOneFeedEntry($user, $public);
|
||||||
|
|
||||||
for ($i = 0; $i < $qty; $i++) {
|
for ($i = 0; $i < $qty; $i++) {
|
||||||
$item = new \Alchemy\Phrasea\Model\Entities\FeedItem();
|
$item = new FeedItem();
|
||||||
$item->setEntry($entry);
|
$item->setEntry($entry);
|
||||||
|
|
||||||
if (null === $record) {
|
if (null === $record) {
|
||||||
@@ -473,125 +475,135 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
$item->setRecordId($actual->get_record_id());
|
$item->setRecordId($actual->get_record_id());
|
||||||
$item->setSbasId($actual->get_sbas_id());
|
$item->setSbasId($actual->get_sbas_id());
|
||||||
$item->setEntry($entry);
|
$item->setEntry($entry);
|
||||||
|
|
||||||
$entry->addItem($item);
|
$entry->addItem($item);
|
||||||
$em->persist($item);
|
|
||||||
|
self::$DI['app']['EM']->persist($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->persist($entry);
|
self::$DI['app']['EM']->persist($entry);
|
||||||
|
self::$DI['app']['EM']->flush();
|
||||||
$em->flush();
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->fail('Fail to load one FeedEntry : ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return $item;
|
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 {
|
$user = $user ?: self::$DI['user'];
|
||||||
$lazaretFixture = new PhraseaFixture\Lazaret\LoadOneFile();
|
|
||||||
|
|
||||||
$lazaretFixture->setUser(self::$DI['user']);
|
$lazaretSession = new LazaretSession();
|
||||||
$lazaretFixture->setCollectionId(self::$DI['collection']->get_base_id());
|
$lazaretSession->setUsrId($user->get_id());
|
||||||
|
$lazaretSession->setUpdated(new \DateTime('now'));
|
||||||
|
$lazaretSession->setCreated(new \DateTime('-1 day'));
|
||||||
|
|
||||||
$loader = new Loader();
|
$lazaretFile = new LazaretFile();
|
||||||
$loader->addFixture($lazaretFixture);
|
$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;
|
return $lazaretFile;
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->fail('Fail load one Basket : ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
* @param User_Adapter $user
|
||||||
* @return \Alchemy\Phrasea\Model\Entities\UsrListEntry
|
*
|
||||||
|
* @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)
|
protected function insertOneUsrListEntry(\User_adapter $owner, \User_adapter $user)
|
||||||
{
|
{
|
||||||
try {
|
$listOwner = new UsrListOwner();
|
||||||
$loader = new Loader();
|
$listOwner->setRole(UsrListOwner::ROLE_ADMIN);
|
||||||
|
$listOwner->setUser($owner);
|
||||||
|
|
||||||
$UsrOwner = new PhraseaFixture\UsrLists\UsrListOwner();
|
$list = new UsrList();
|
||||||
$UsrOwner->setUser($owner);
|
$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);
|
return $entry;
|
||||||
|
|
||||||
$loader->addFixture($UsrEntry);
|
|
||||||
|
|
||||||
$this->insertFixtureInDatabase($loader);
|
|
||||||
|
|
||||||
return $UsrEntry->entry;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->fail('Fail load one UsrListEntry : ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert five baskets and set current authenticated user as owner
|
* Inserts five baskets.
|
||||||
*
|
*
|
||||||
* @return \Alchemy\Phrasea\Model\Entities\Basket
|
* @return Basket[]
|
||||||
*/
|
*/
|
||||||
protected function insertFiveBasket()
|
protected function insertFiveBasket()
|
||||||
{
|
{
|
||||||
try {
|
$baskets = [];
|
||||||
$basketFixture = new PhraseaFixture\Basket\LoadFiveBaskets();
|
|
||||||
|
|
||||||
$basketFixture->setUser(self::$DI['user']);
|
for ($i = 0; $i < 5; $i ++) {
|
||||||
|
$basket = new Basket();
|
||||||
|
$basket->setName('test ' . $i);
|
||||||
|
$basket->setDescription('description');
|
||||||
|
$basket->setOwner(self::$DI['user']);
|
||||||
|
|
||||||
$loader = new Loader();
|
self::$DI['app']['EM']->persist($basket);
|
||||||
$loader->addFixture($basketFixture);
|
$baskets[] = $basket;
|
||||||
|
|
||||||
$this->insertFixtureInDatabase($loader);
|
|
||||||
|
|
||||||
return $basketFixture->baskets;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->fail('Fail load five Basket : ' . $e->getMessage());
|
|
||||||
}
|
}
|
||||||
|
self::$DI['app']['EM']->flush();
|
||||||
|
|
||||||
|
return $baskets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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)
|
protected function insertOneBasketElement(\User_Adapter $user = null, \record_adapter $record = null)
|
||||||
{
|
{
|
||||||
@@ -602,67 +614,66 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
$basket->addElement($element);
|
$basket->addElement($element);
|
||||||
$element->setBasket($basket);
|
$element->setBasket($basket);
|
||||||
|
|
||||||
self::$DI['app']['EM']->persist($element);
|
self::$DI['app']['EM']->persist($basket);
|
||||||
self::$DI['app']['EM']->flush();
|
self::$DI['app']['EM']->flush();
|
||||||
|
|
||||||
return $element;
|
return $element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Inserts one validation basket.
|
||||||
*
|
*
|
||||||
* @return \Alchemy\Phrasea\Model\Entities\Basket
|
* @param array $parameters
|
||||||
|
*
|
||||||
|
* @return Basket
|
||||||
*/
|
*/
|
||||||
protected function insertOneValidationBasket(array $parameters = [])
|
protected function insertOneValidationBasket(array $parameters = [])
|
||||||
{
|
{
|
||||||
$em = self::$DI['app']['EM'];
|
|
||||||
|
|
||||||
$basketElement = $this->insertOneBasketElement();
|
$basketElement = $this->insertOneBasketElement();
|
||||||
$basket = $basketElement->getBasket();
|
$basket = $basketElement->getBasket();
|
||||||
|
|
||||||
$Validation = new Alchemy\Phrasea\Model\Entities\ValidationSession();
|
$validation = new ValidationSession();
|
||||||
$Validation->setBasket($basket);
|
$validation->setBasket($basket);
|
||||||
$Validation->setInitiator(self::$DI['user']);
|
$validation->setInitiator(self::$DI['user']);
|
||||||
|
|
||||||
if (isset($parameters['expires']) && $parameters['expires'] instanceof \DateTime) {
|
if (isset($parameters['expires']) && $parameters['expires'] instanceof \DateTime) {
|
||||||
$Validation->setExpires($parameters['expires']);
|
$validation->setExpires($parameters['expires']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$basket->setValidation($Validation);
|
$basket->setValidation($validation);
|
||||||
$em->persist($Validation);
|
|
||||||
$em->merge($basket);
|
|
||||||
|
|
||||||
$Participant = new Alchemy\Phrasea\Model\Entities\ValidationParticipant();
|
$participant = new ValidationParticipant();
|
||||||
$Participant->setUser(self::$DI['user']);
|
$participant->setUser(self::$DI['user']);
|
||||||
$Participant->setCanAgree(true);
|
$participant->setCanAgree(true);
|
||||||
$Participant->setCanSeeOthers(true);
|
$participant->setCanSeeOthers(true);
|
||||||
|
|
||||||
$Validation->addParticipant($Participant);
|
$validation->addParticipant($participant);
|
||||||
$Participant->setSession($Validation);
|
$participant->setSession($validation);
|
||||||
|
|
||||||
$em->persist($Participant);
|
$data = new ValidationData();
|
||||||
$em->merge($Validation);
|
$data->setBasketElement($basketElement);
|
||||||
|
$data->setParticipant($participant);
|
||||||
|
$basketElement->addValidationData($data);
|
||||||
|
|
||||||
$Data = new Alchemy\Phrasea\Model\Entities\ValidationData();
|
self::$DI['app']['EM']->persist($basket);
|
||||||
$Data->setBasketElement($basketElement);
|
self::$DI['app']['EM']->persist($validation);
|
||||||
$Data->setParticipant($Participant);
|
self::$DI['app']['EM']->persist($participant);
|
||||||
$basketElement->addValidationData($Data);
|
self::$DI['app']['EM']->persist($data);
|
||||||
|
self::$DI['app']['EM']->persist($basketElement);
|
||||||
|
|
||||||
$em->persist($Data);
|
self::$DI['app']['EM']->flush();
|
||||||
$em->merge($basketElement);
|
|
||||||
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
return $basket;
|
return $basket;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new basket with current auhtenticated user as owner
|
* - Creates a new basket with current authenticated user as owner.
|
||||||
* Create a new sessionValidation with the newly created basket
|
* - Creates a new sessionValidation with the newly created basket.
|
||||||
* Set current authenticated user as sessionValidation initiator
|
* - Sets current authenticated user as sessionValidation initiator.
|
||||||
* Add 2 records as elments of the newly created basket
|
* - Adds 2 records as elements of the newly created basket.
|
||||||
* Add 2 participants to the newly created sessionValidation
|
* - Adds 2 participants to the newly created sessionValidation.
|
||||||
*
|
*
|
||||||
* @return \Alchemy\Phrasea\Model\Entities\Basket
|
* @return Basket
|
||||||
*/
|
*/
|
||||||
protected function insertOneBasketEnv()
|
protected function insertOneBasketEnv()
|
||||||
{
|
{
|
||||||
@@ -670,6 +681,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
$basket->setName('test');
|
$basket->setName('test');
|
||||||
$basket->setDescription('description');
|
$basket->setDescription('description');
|
||||||
$basket->setOwner(self::$DI['user']);
|
$basket->setOwner(self::$DI['user']);
|
||||||
|
|
||||||
self::$DI['app']['EM']->persist($basket);
|
self::$DI['app']['EM']->persist($basket);
|
||||||
|
|
||||||
foreach ([self::$DI['record_1'], self::$DI['record_2']] as $record) {
|
foreach ([self::$DI['record_1'], self::$DI['record_2']] as $record) {
|
||||||
@@ -702,58 +714,72 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load One WZ with
|
* Inserts one story.
|
||||||
* One basket
|
*
|
||||||
* One story
|
* @param User_Adapter $user
|
||||||
* One ValidationSession & one participant
|
* @param record_adapter $record
|
||||||
* @return
|
*
|
||||||
|
* @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()
|
protected function insertOneWZ()
|
||||||
{
|
{
|
||||||
try {
|
$this->insertOneStory();
|
||||||
$currentUser = self::$DI['user'];
|
$this->insertOneValidationSession($this->insertOneBasket(), self::$DI['user_alt1']);
|
||||||
$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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
/**
|
||||||
}
|
* Inserts one user.
|
||||||
|
*
|
||||||
protected function insertOneUser(User $user)
|
* @param string $login
|
||||||
|
* @param null $email
|
||||||
|
* @param bool $admin
|
||||||
|
*
|
||||||
|
* @return User
|
||||||
|
*/
|
||||||
|
protected function insertOneUser($login, $email = null, $admin = false)
|
||||||
{
|
{
|
||||||
try {
|
return self::$DI['app']['manipulator.user']->create($login, uniqid('pass'), $email, $admin);
|
||||||
$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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -762,7 +788,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
* @param string $method The request method
|
* @param string $method The request method
|
||||||
* @param string $uri The URI to fetch
|
* @param string $uri The URI to fetch
|
||||||
* @param array $parameters The Request parameters
|
* @param array $parameters The Request parameters
|
||||||
* @param array $httpAccept Contents of the Accept header
|
* @param string $httpAccept Contents of the Accept header
|
||||||
*
|
*
|
||||||
* @return Crawler
|
* @return Crawler
|
||||||
*/
|
*/
|
||||||
@@ -775,13 +801,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the sql tables with the current schema
|
* Updates the sql tables with the current schema.
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
private static function updateTablesSchema(Application $application)
|
private static function updateTablesSchema(Application $application)
|
||||||
{
|
{
|
||||||
if (!self::$updated) {
|
if (!self::$updated) {
|
||||||
|
|
||||||
if (file_exists(Setup_Upgrade::get_lock_file())) {
|
if (file_exists(Setup_Upgrade::get_lock_file())) {
|
||||||
unlink(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']
|
||||||
* self::$DI['user_alt1']
|
* self::$DI['user_alt1']
|
||||||
* self::$DI['user_alt2']
|
* self::$DI['user_alt2']
|
||||||
*
|
|
||||||
* @return void;
|
|
||||||
*/
|
*/
|
||||||
private static function createSetOfUserTests(Application $application)
|
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
|
* @param \User_Adapter $user
|
||||||
*/
|
*/
|
||||||
@@ -923,8 +946,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set self::$DI['collection']
|
* Sets self::$DI['collection'].
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
private static function setCollection(Application $application)
|
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)
|
private static function generateRecords(Application $app)
|
||||||
{
|
{
|
||||||
@@ -1087,11 +1109,9 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete previously created Ressources
|
* Deletes previously created Resources.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
private static function deleteRessources()
|
private static function deleteResources()
|
||||||
{
|
{
|
||||||
$skipped = \PhraseanetPHPUnitListener::getSkipped();
|
$skipped = \PhraseanetPHPUnitListener::getSkipped();
|
||||||
|
|
||||||
@@ -1116,6 +1136,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authenticates self::['user'] against application.
|
||||||
|
*
|
||||||
|
* @param Application $app
|
||||||
|
*/
|
||||||
protected function authenticate(Application $app)
|
protected function authenticate(Application $app)
|
||||||
{
|
{
|
||||||
$app['session']->clear();
|
$app['session']->clear();
|
||||||
@@ -1131,6 +1156,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
self::$DI['app']['authentication']->reinitUser();
|
self::$DI['app']['authentication']->reinitUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logout authenticated user from application.
|
||||||
|
*
|
||||||
|
* @param Application $app
|
||||||
|
*/
|
||||||
protected function logout(Application $app)
|
protected function logout(Application $app)
|
||||||
{
|
{
|
||||||
$app['session']->clear();
|
$app['session']->clear();
|
||||||
|
Reference in New Issue
Block a user