mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
Updated unitTests
This commit is contained in:
@@ -22,7 +22,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$appbox = appbox::get_instance();
|
$appbox = appbox::get_instance();
|
||||||
$this->object = new API_V1_adapter(FALSE, $appbox);
|
$this->object = new API_V1_adapter(FALSE, $appbox, self::$core);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGet_error_code()
|
public function testGet_error_code()
|
||||||
@@ -370,10 +370,16 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
$appbox = appbox::get_instance();
|
$appbox = appbox::get_instance();
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$usr_id = $session->get_usr_id();
|
$usr_id = $session->get_usr_id();
|
||||||
|
|
||||||
|
$em = self::$core->getEntityManager();
|
||||||
|
$repo = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
|
/* @var $repo \Repositories\BasketRepository */
|
||||||
|
$repo->findUserBasket($ssel_id, self::$core->getAuthenticatedUser());
|
||||||
|
|
||||||
$basket = basket_adapter::getInstance(appbox::get_instance(), $ssel_id, $usr_id);
|
$this->assertTrue($basket instanceof \Entities\Basket);
|
||||||
$this->assertTrue($basket instanceof basket_adapter);
|
$em->remove($Basket);
|
||||||
$basket->delete();
|
$em->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDelete_basket()
|
public function testDelete_basket()
|
||||||
@@ -381,8 +387,17 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
$appbox = appbox::get_instance();
|
$appbox = appbox::get_instance();
|
||||||
$usr_id = $appbox->get_session()->get_usr_id();
|
$usr_id = $appbox->get_session()->get_usr_id();
|
||||||
$user = User_Adapter::getInstance($usr_id, $appbox);
|
$user = User_Adapter::getInstance($usr_id, $appbox);
|
||||||
$basket = basket_adapter::create($appbox, 'test suppression', $user);
|
|
||||||
$ssel_id = $basket->get_ssel_id();
|
$em = self::$core->getEntityManager();
|
||||||
|
|
||||||
|
$Basket = new Entities\Basket();
|
||||||
|
$Basket->setName('Delete test');
|
||||||
|
$Basket->setOwner($user);
|
||||||
|
|
||||||
|
$em->persist($Basket);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
$ssel_id = $basket->getId();
|
||||||
|
|
||||||
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
$request = new Request(array(), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
|
||||||
$result = $this->object->delete_basket($request, $ssel_id);
|
$result = $this->object->delete_basket($request, $ssel_id);
|
||||||
@@ -390,12 +405,14 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
$this->assertEquals('application/json', $result->get_content_type());
|
$this->assertEquals('application/json', $result->get_content_type());
|
||||||
$this->assertTrue(is_object(json_decode($result->format())));
|
$this->assertTrue(is_object(json_decode($result->format())));
|
||||||
|
|
||||||
|
$repo = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
basket_adapter::getInstance($appbox, $ssel_id, $usr_id);
|
$repo->findUserBasket($ssel_id, $user);
|
||||||
$this->fail('An exception should have been raised');
|
$this->fail('An exception should have been raised');
|
||||||
}
|
}
|
||||||
catch (Exception_Basket_NotFound $e)
|
catch (Exception_NotFound $e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user