Files
Phraseanet/tests/classes/Doctrine/Entities/BasketTest.php
Nicolas Le Goff 26bd977d5f Delete references to usr.usr_id field in entities
Conflicts:
	lib/Alchemy/Phrasea/Controller/Prod/Push.php
	lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php
	lib/conf.d/migrations.yml

Conflicts:
	lib/Alchemy/Phrasea/ACL/BasketACL.php
	lib/Alchemy/Phrasea/Authentication/Authenticator.php
	lib/Alchemy/Phrasea/Controller/Prod/Order.php
	lib/Alchemy/Phrasea/Controller/Prod/UsrLists.php
	lib/Alchemy/Phrasea/Controller/Root/RSSFeeds.php
	lib/Alchemy/Phrasea/Controller/Root/Session.php
	lib/Alchemy/Phrasea/Model/Entities/Basket.php
	lib/Alchemy/Phrasea/Model/Entities/BasketElement.php
	lib/Alchemy/Phrasea/Model/Entities/Feed.php
	lib/Alchemy/Phrasea/Model/Entities/FeedEntry.php
	lib/Alchemy/Phrasea/Model/Entities/FtpExport.php
	lib/Alchemy/Phrasea/Model/Entities/Session.php
	lib/Alchemy/Phrasea/Model/Entities/StoryWZ.php
	lib/Alchemy/Phrasea/Model/Entities/UsrList.php
	lib/Alchemy/Phrasea/Model/Entities/UsrListEntry.php
	lib/Alchemy/Phrasea/Model/Entities/UsrListOwner.php
	lib/Alchemy/Phrasea/Model/Entities/ValidationParticipant.php
	lib/Alchemy/Phrasea/Model/Entities/ValidationSession.php
	lib/Alchemy/Phrasea/Model/Repositories/StoryWZRepository.php
	lib/classes/API/V1/adapter.php
	templates/mobile/lightbox/sc_note.html.twig
	templates/web/admin/connected-users.html.twig
	templates/web/admin/publications/fiche.html.twig
	templates/web/lightbox/IE6/agreement_box.html.twig
	templates/web/lightbox/agreement_box.html.twig
	templates/web/lightbox/basket_content_report.html.twig
	templates/web/lightbox/sc_note.html.twig
	templates/web/prod/WorkZone/Browser/Basket.html.twig
	templates/web/prod/WorkZone/Browser/Results.html.twig
	templates/web/prod/WorkZone/Macros.html.twig
	templates/web/prod/actions/Feedback/List-Share.html.twig
	templates/web/prod/actions/Feedback/ListsMacros.html.twig
	templates/web/prod/orders/order_box.html.twig
	templates/web/prod/orders/order_item.html.twig
	templates/web/prod/upload/lazaret.html.twig
	tests/Alchemy/Tests/Phrasea/Controller/Root/SessionTest.php
2014-02-19 17:29:25 +01:00

148 lines
4.1 KiB
PHP

<?php
class EntityBasketTest extends PhraseanetPHPUnitAuthenticatedAbstract
{
/**
*
* @var \Alchemy\Phrasea\Model\Entities\Basket
*/
protected $basket;
/**
*
* @var \Doctrine\ORM\EntityManager
*/
protected $em;
public function setUp()
{
parent::setUp();
$this->em = self::$DI['app']['EM'];
$this->basket = $this->insertOneBasket();
}
public function testGetId()
{
$this->assertTrue(is_int($this->basket->getId()));
$otherBasket = $this->insertOneBasket();
$this->assertGreaterThan($this->basket->getId(), $otherBasket->getId());
}
public function testGetName()
{
$this->basket->setName('one name');
$this->em->persist($this->basket);
$this->em->flush();
$this->assertEquals('one name', $this->basket->getName());
}
public function testGetDescription()
{
$this->basket->setDescription('une jolie description pour mon super panier');
$this->em->persist($this->basket);
$this->em->flush();
$this->assertEquals('une jolie description pour mon super panier', $this->basket->getDescription());
}
public function testGetArchived()
{
$this->basket->setArchived(true);
$this->em->persist($this->basket);
$this->em->flush();
$this->assertTrue($this->basket->GetArchived());
$this->basket->setArchived(false);
$this->em->persist($this->basket);
$this->em->flush();
$this->assertFalse($this->basket->GetArchived());
}
public function testGetCreated()
{
$date = $this->basket->getCreated();
$this->assertInstanceOf('\DateTime', $date);
}
public function testGetUpdated()
{
$date = $this->basket->getUpdated();
$this->assertInstanceOf('\DateTime', $date);
}
public function testGetElements()
{
$elements = $this->basket->getElements();
$this->assertInstanceOf('\Doctrine\ORM\PersistentCollection', $elements);
$this->assertEquals(0, $elements->count());
$basketElement = new \Alchemy\Phrasea\Model\Entities\BasketElement();
$basketElement->setRecord(self::$DI['record_1']);
$basketElement->setBasket($this->basket);
$this->em->persist($basketElement);
$this->em->flush();
$this->em->refresh($this->basket);
$this->assertEquals(1, $this->basket->getElements()->count());
}
public function testGetPusher()
{
$this->assertNull($this->basket->getPusher(self::$DI['app'])); //no pusher
$this->basket->setPusherId(self::$DI['user']->get_id());
$this->assertInstanceOf('\User_Adapter', $this->basket->getPusher(self::$DI['app']));
$this->assertEquals($this->basket->getPusher(self::$DI['app'])->get_id(), self::$DI['user']->get_id());
}
public function testGetOwner()
{
$this->assertNotNull($this->basket->getUser()); //no owner
$this->basket->setUser(self::$DI['user']);
$this->assertInstanceOf('Alchemy\Phrasea\Model\Entities\User', $this->basket->getUser());
$this->assertEquals($this->basket->getUser()->getId(), self::$DI['user']->getId());
}
public function testGetValidation()
{
$this->assertNull($this->basket->getValidation());
$validationSession = new \Alchemy\Phrasea\Model\Entities\ValidationSession();
$validationSession->setBasket($this->basket);
$expires = new \DateTime();
$expires->modify('+1 week');
$validationSession->setExpires($expires);
$validationSession->setInitiator(self::$DI['user']);
$this->em->persist($validationSession);
$this->em->flush();
$this->em->refresh($this->basket);
$this->assertInstanceOf('\Alchemy\Phrasea\Model\Entities\ValidationSession', $this->basket->getValidation());
}
public function testGetIsRead()
{
$this->markTestIncomplete();
}
public function testGetSize()
{
$this->markTestIncomplete();
}
public function hasRecord()
{
$this->markTestIncomplete();
}
}