Fix build APIs / Session

This commit is contained in:
Romain Neutron
2011-12-30 10:28:50 +01:00
parent d6de10324d
commit f7698e0f24
5 changed files with 24 additions and 22 deletions

View File

@@ -318,6 +318,8 @@ class Core extends \Pimple
$this->getRequest()->setLocale($cookies->get('locale')); $this->getRequest()->setLocale($cookies->get('locale'));
} }
\Session_Handler::set_locale($this->getRequest()->getLocale());
return; return;
} }

View File

@@ -1116,7 +1116,7 @@ class API_V1_adapter extends API_V1_Abstract
{ {
$ret = array( $ret = array(
'created_on' => $basket->getCreated()->format(DATE_ATOM) 'created_on' => $basket->getCreated()->format(DATE_ATOM)
, 'description' => $basket->getDescription() , 'description' => (string) $basket->getDescription()
, 'name' => $basket->getName() , 'name' => $basket->getName()
, 'pusher_usr_id' => $basket->getPusherId() , 'pusher_usr_id' => $basket->getPusherId()
, 'ssel_id' => $basket->getId() , 'ssel_id' => $basket->getId()

View File

@@ -270,7 +270,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testSet_record_status() public function testSet_record_status()
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$stub = $this->getMock("API_V1_adapter", array("list_record_status"), array(false, &$appbox)); $stub = $this->getMock("API_V1_adapter", array("list_record_status"), array(false, &$appbox, bootstrap::getCore()));
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$databox = self::$record_1->get_databox(); $databox = self::$record_1->get_databox();
@@ -307,7 +307,7 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testSet_record_collection() public function testSet_record_collection()
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$stub = $this->getMock("API_V1_adapter", array("list_record"), array(false, &$appbox)); $stub = $this->getMock("API_V1_adapter", array("list_record"), array(false, &$appbox, bootstrap::getCore()));
$databox = self::$record_1->get_databox(); $databox = self::$record_1->get_databox();
$request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json')); $request = new Request(array("salut" => "salut c'est la fete"), array(), array(), array(), array(), array('HTTP_Accept' => 'application/json'));
@@ -375,10 +375,10 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$repo = $em->getRepository('\Entities\Basket'); $repo = $em->getRepository('\Entities\Basket');
/* @var $repo \Repositories\BasketRepository */ /* @var $repo \Repositories\BasketRepository */
$repo->findUserBasket($ssel_id, self::$core->getAuthenticatedUser()); $basket = $repo->findUserBasket($ssel_id, self::$core->getAuthenticatedUser());
$this->assertTrue($basket instanceof \Entities\Basket); $this->assertTrue($basket instanceof \Entities\Basket);
$em->remove($Basket); $em->remove($basket);
$em->flush(); $em->flush();
} }
@@ -445,9 +445,11 @@ 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())));
self::$core->getEntityManager()->refresh($basket); $repository =self::$core->getEntityManager()->getRepository('\Entities\Basket');
$this->assertEquals('PROUTO', $basket->getName()); $ret_bask = $repository->find($basket->getId());
$this->assertEquals('PROUTO', $ret_bask->getName());
} }
public function testSet_basket_description() public function testSet_basket_description()
@@ -463,17 +465,17 @@ 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())));
$em = self::$core->getEntityManager(); $repository =self::$core->getEntityManager()->getRepository('\Entities\Basket');
/* @var $em \Doctrine\ORM\EntityManager */
$em->refresh($basket);
$this->assertEquals('une belle description', $basket->getDescription()); $ret_bask = $repository->find($basket->getId());
$this->assertEquals('une belle description', $ret_bask->getDescription());
} }
public function testSearch_publications() public function testSearch_publications()
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$stub = $this->getMock("API_V1_adapter", array("list_publication"), array(false, &$appbox)); $stub = $this->getMock("API_V1_adapter", array("list_publication"), array(false, &$appbox, bootstrap::getCore()));
$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'));
$feed = Feed_Adapter::create($appbox, self::$user, "hello", "salut"); $feed = Feed_Adapter::create($appbox, self::$user, "hello", "salut");
$result = $this->object->search_publications($request, self::$user); $result = $this->object->search_publications($request, self::$user);

View File

@@ -890,7 +890,7 @@ class API_V1_test_adapter extends PhraseanetWebTestCaseAbstract
foreach ($content->response->basket as $basket_str) foreach ($content->response->basket as $basket_str)
{ {
$this->evaluateGoodBasket($basket_str); $this->evaluateGoodBasket($basket_str);
$this->assertEquals($basket_str->name, 'aéaa'); $this->assertEquals($basket_str->name, '<strong>aéaa');
} }
} }
@@ -924,10 +924,9 @@ class API_V1_test_adapter extends PhraseanetWebTestCaseAbstract
public function testDeleteBasket() public function testDeleteBasket()
{ {
$basket = $this->insertOneBasket(); $baskets = $this->insertFiveBasket();
$basket2 = $this->insertOneBasket();
$route = '/baskets/' . $basket->getId() . '/delete/?oauth_token=' . self::$token; $route = '/baskets/' . $baskets[0]->getId() . '/delete/?oauth_token=' . self::$token;
$this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE'));
@@ -947,7 +946,7 @@ class API_V1_test_adapter extends PhraseanetWebTestCaseAbstract
} }
if(!$found) if(!$found)
{ {
$this->fail('There should be a basket left'); $this->fail('There should be four baskets left');
} }
} }

View File

@@ -897,7 +897,7 @@ class API_V1_test_adapterYaml extends PhraseanetWebTestCaseAbstract
foreach ($content["response"]["basket"] as $basket_str) foreach ($content["response"]["basket"] as $basket_str)
{ {
$this->evaluateGoodBasket($basket_str); $this->evaluateGoodBasket($basket_str);
$this->assertEquals($basket_str["name"], 'aéaa'); $this->assertEquals($basket_str["name"], '<strong>aéaa');
} }
} }
@@ -928,10 +928,9 @@ class API_V1_test_adapterYaml extends PhraseanetWebTestCaseAbstract
public function testDeleteBasket() public function testDeleteBasket()
{ {
$basket = $this->insertOneBasket(); $baskets = $this->insertFiveBasket();
$basket2 = $this->insertOneBasket();
$route = '/baskets/' . $basket->getId() . '/delete/?oauth_token=' . self::$token; $route = '/baskets/' . $baskets[0]->getId() . '/delete/?oauth_token=' . self::$token;
$this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE'));
@@ -951,7 +950,7 @@ class API_V1_test_adapterYaml extends PhraseanetWebTestCaseAbstract
} }
if (!$found) if (!$found)
{ {
$this->fail('There should be a basket left'); $this->fail('There should be four baskets left');
} }
} }