add new fxtures

This commit is contained in:
Nicolas Le Goff
2011-12-20 13:32:16 +01:00
parent 157ce3a586
commit bade38c5e8
4 changed files with 238 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhraseaFixture\Story;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\DataFixtures\FixtureInterface;
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class LoadOneStory extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
*
* @var \Entities\StoryWZ
*/
public $story;
public function load($manager)
{
$story = new \Entities\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

@@ -0,0 +1,54 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhraseaFixture\ValidationParticipant;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\DataFixtures\FixtureInterface;
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class LoadOneParticipant extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
*
* @var \Entities\ValidationParticipant
*/
public $validationParticipant;
public function load($manager)
{
$validationParticipant = new \Entities\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

@@ -0,0 +1,66 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhraseaFixture\ValidationParticipant;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\DataFixtures\FixtureInterface;
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class LoadParticipantWithSession extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
*
* @var \Entities\ValidationParticipant
*/
public $validationParticipant;
/**
*
* @var \Entities\ValidationSession
*/
private $session;
public function load($manager)
{
$validationParticipant = new \Entities\ValidationParticipant();
if (null === $this->user)
{
throw new \LogicException('Fill a user to store a new validation Session');
}
$validationParticipant->setParticipant($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(\Entities\ValidationSession $session)
{
$this->session = $session;
}
}

View File

@@ -0,0 +1,61 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PhraseaFixture\ValidationSession;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\DataFixtures\FixtureInterface;
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class LoadOneValidationSession extends \PhraseaFixture\AbstractWZ implements FixtureInterface
{
/**
*
* @var \Entities\ValidationSession
*/
public $validationSession;
public function load($manager)
{
$validationSession = new \Entities\ValidationSession();
$validationSession->setBasket(
$this->getReference('one-basket') // load the one-basket stored reference
);
$validationSession->setDescription('Une description au hasard');
$validationSession->setName('Un nom de validation');
$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);
}
}