mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 22:43:19 +00:00
load environment via configuration file
This commit is contained in:
@@ -36,11 +36,13 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
* @var Symfony\Component\HttpKernel\Client
|
* @var Symfony\Component\HttpKernel\Client
|
||||||
*/
|
*/
|
||||||
protected $client;
|
protected $client;
|
||||||
/**
|
|
||||||
|
/**
|
||||||
*
|
*
|
||||||
* @var record_adapter
|
* @var record_adapter
|
||||||
*/
|
*/
|
||||||
protected static $story_1;
|
protected static $story_1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var record_adapter
|
* @var record_adapter
|
||||||
@@ -352,13 +354,13 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
* @var \Alchemy\Phrasea\Core
|
* @var \Alchemy\Phrasea\Core
|
||||||
*/
|
*/
|
||||||
protected static $core;
|
protected static $core;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var \Doctrine\ORM\Tools\SchemaTools
|
* @var \Doctrine\ORM\Tools\SchemaTools
|
||||||
*/
|
*/
|
||||||
protected $schematTool;
|
protected $schematTool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class metadatas
|
* Class metadatas
|
||||||
* @var Array
|
* @var Array
|
||||||
@@ -371,8 +373,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
if (!self::$time_start)
|
if (!self::$time_start)
|
||||||
self::$time_start = microtime(true);
|
self::$time_start = microtime(true);
|
||||||
|
|
||||||
if (!setup::is_installed())
|
|
||||||
exit("Phraseanet is not set up\n");
|
|
||||||
|
|
||||||
$appbox = appbox::get_instance();
|
$appbox = appbox::get_instance();
|
||||||
if (!self::$updated)
|
if (!self::$updated)
|
||||||
@@ -771,7 +771,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$appbox->get_session()->logout();
|
$appbox->get_session()->logout();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -784,6 +784,9 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
if (!setup::is_installed())
|
||||||
|
exit("Phraseanet is not set up\n");
|
||||||
|
|
||||||
if (null === self::$core)
|
if (null === self::$core)
|
||||||
{
|
{
|
||||||
if (is_file(__DIR__ . '/tests.sqlite'))
|
if (is_file(__DIR__ . '/tests.sqlite'))
|
||||||
@@ -792,15 +795,11 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
self::$core = bootstrap::getCore();
|
self::$core = bootstrap::getCore();
|
||||||
self::$core["EM"] = self::$core->share(function()
|
|
||||||
{
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\DoctrineTestSQLite();
|
|
||||||
return $doctrine->getEntityManager();
|
|
||||||
});
|
|
||||||
|
|
||||||
$em = self::$core->getEntityManager();
|
$em = self::$core->getEntityManager();
|
||||||
/* @var $em \Doctrine\ORM\EntityManager */
|
/* @var $em \Doctrine\ORM\EntityManager */
|
||||||
|
|
||||||
//create schema
|
//create schema
|
||||||
$this->schematTool = new \Doctrine\ORM\Tools\SchemaTool($em);
|
$this->schematTool = new \Doctrine\ORM\Tools\SchemaTool($em);
|
||||||
$this->classesMetatdas = array(
|
$this->classesMetatdas = array(
|
||||||
@@ -811,7 +810,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
, $em->getClassMetadata('Entities\ValidationParticipant')
|
, $em->getClassMetadata('Entities\ValidationParticipant')
|
||||||
, $em->getClassMetadata('Entities\ValidationSession')
|
, $em->getClassMetadata('Entities\ValidationSession')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->schematTool->createSchema($this->classesMetatdas);
|
$this->schematTool->createSchema($this->classesMetatdas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1019,7 +1018,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
$executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor(self::$core->getEntityManager(), $purger);
|
$executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor(self::$core->getEntityManager(), $purger);
|
||||||
$executor->execute(array());
|
$executor->execute(array());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function assertDateAtom($date)
|
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);
|
return $this->assertRegExp('/\d{4}[-]\d{2}[-]\d{2}[T]\d{2}[:]\d{2}[:]\d{2}[+]\d{2}[:]\d{2}/', $date);
|
||||||
@@ -1056,7 +1055,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
$this->fail('Fail load one Basket : ' . $e->getMessage());
|
$this->fail('Fail load one Basket : ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert five baskets and set current authenticated user as owner
|
* Insert five baskets and set current authenticated user as owner
|
||||||
*
|
*
|
||||||
@@ -1082,7 +1081,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
$this->fail('Fail load one Basket : ' . $e->getMessage());
|
$this->fail('Fail load one Basket : ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return \Entities\BasketElement
|
* @return \Entities\BasketElement
|
||||||
@@ -1090,25 +1089,24 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
protected function insertOneBasketElement()
|
protected function insertOneBasketElement()
|
||||||
{
|
{
|
||||||
$basket = $this->insertOneBasket();
|
$basket = $this->insertOneBasket();
|
||||||
|
|
||||||
$basketElement = new \Entities\BasketElement();
|
$basketElement = new \Entities\BasketElement();
|
||||||
$basketElement->setRecord(self::$record_1);
|
$basketElement->setRecord(self::$record_1);
|
||||||
$basketElement->setBasket($basket);
|
$basketElement->setBasket($basket);
|
||||||
|
|
||||||
$basket->addBasketElement($basketElement);
|
$basket->addBasketElement($basketElement);
|
||||||
|
|
||||||
$em = self::$core->getEntityManager();
|
$em = self::$core->getEntityManager();
|
||||||
|
|
||||||
$em->persist($basketElement);
|
$em->persist($basketElement);
|
||||||
|
|
||||||
$em->merge($basket);
|
$em->merge($basket);
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $basketElement;
|
return $basketElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return \Entities\Basket
|
* @return \Entities\Basket
|
||||||
@@ -1116,42 +1114,41 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
protected function insertOneValidationBasket()
|
protected function insertOneValidationBasket()
|
||||||
{
|
{
|
||||||
$em = self::$core->getEntityManager();
|
$em = self::$core->getEntityManager();
|
||||||
|
|
||||||
$basketElement = $this->insertOneBasketElement();
|
$basketElement = $this->insertOneBasketElement();
|
||||||
$basket = $basketElement->getBasket();
|
$basket = $basketElement->getBasket();
|
||||||
|
|
||||||
$Validation = new Entities\ValidationSession();
|
$Validation = new Entities\ValidationSession();
|
||||||
$Validation->setBasket($basket);
|
$Validation->setBasket($basket);
|
||||||
$Validation->setInitiator(self::$user);
|
$Validation->setInitiator(self::$user);
|
||||||
|
|
||||||
$basket->setValidation($Validation);
|
$basket->setValidation($Validation);
|
||||||
|
|
||||||
$em->persist($Validation);
|
$em->persist($Validation);
|
||||||
$em->merge($basket);
|
$em->merge($basket);
|
||||||
|
|
||||||
$Participant = new Entities\ValidationParticipant();
|
$Participant = new Entities\ValidationParticipant();
|
||||||
$Participant->setUser(self::$user);
|
$Participant->setUser(self::$user);
|
||||||
$Participant->setCanAgree(true);
|
$Participant->setCanAgree(true);
|
||||||
$Participant->setCanSeeOthers(true);
|
$Participant->setCanSeeOthers(true);
|
||||||
|
|
||||||
$Validation->addValidationParticipant($Participant);
|
$Validation->addValidationParticipant($Participant);
|
||||||
$Participant->setSession($Validation);
|
$Participant->setSession($Validation);
|
||||||
|
|
||||||
$em->persist($Participant);
|
$em->persist($Participant);
|
||||||
$em->merge($Validation);
|
$em->merge($Validation);
|
||||||
|
|
||||||
$Data = new Entities\ValidationData();
|
$Data = new Entities\ValidationData();
|
||||||
$Data->setBasketElement($basketElement);
|
$Data->setBasketElement($basketElement);
|
||||||
$Data->setParticipant($Participant);
|
$Data->setParticipant($Participant);
|
||||||
$basketElement->addValidationData($Data);
|
$basketElement->addValidationData($Data);
|
||||||
|
|
||||||
$em->persist($Data);
|
$em->persist($Data);
|
||||||
$em->merge($basketElement);
|
$em->merge($basketElement);
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $basket;
|
return $basket;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user