mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 04:53:26 +00:00
Add record preview Test
Fix CS
This commit is contained in:
@@ -8,6 +8,16 @@ require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAuthenticatedAbstract.
|
|||||||
class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||||
{
|
{
|
||||||
protected $client;
|
protected $client;
|
||||||
|
protected static $feed;
|
||||||
|
|
||||||
|
public static function tearDownAfterClass()
|
||||||
|
{
|
||||||
|
if(self::$feed instanceof Feed_Adapter){
|
||||||
|
self::$feed->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::tearDownAfterClass();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Alchemy\Phrasea\Controller\Prod\Records::whatCanIDelete
|
* @covers Alchemy\Phrasea\Controller\Prod\Records::whatCanIDelete
|
||||||
@@ -34,7 +44,7 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
try {
|
try {
|
||||||
new \record_adapter(self::$DI['app'], $record->get_sbas_id(), $record->get_record_id());
|
new \record_adapter(self::$DI['app'], $record->get_sbas_id(), $record->get_record_id());
|
||||||
$this->fail('Record not deleted');
|
$this->fail('Record not deleted');
|
||||||
} catch(\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
unset($response, $datas, $record);
|
unset($response, $datas, $record);
|
||||||
@@ -55,4 +65,184 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
unset($response, $datas, $record);
|
unset($response, $datas, $record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord
|
||||||
|
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
|
||||||
|
*/
|
||||||
|
public function testGetRecordDetailNotAjax()
|
||||||
|
{
|
||||||
|
self::$DI['client']->request('POST', '/prod/records/');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord
|
||||||
|
*/
|
||||||
|
public function testGetRecordDetailResult()
|
||||||
|
{
|
||||||
|
\phrasea::start(self::$DI['app']['phraseanet.configuration']);
|
||||||
|
$auth = new \Session_Authentication_None(self::$DI['user']);
|
||||||
|
self::$DI['app']->openAccount($auth);
|
||||||
|
self::$DI['record_24'];
|
||||||
|
|
||||||
|
$options = new \searchEngine_options();
|
||||||
|
$acl = self::$DI['app']['phraseanet.user']->ACL();
|
||||||
|
$options->set_bases(array_keys($acl->get_granted_base()), $acl);
|
||||||
|
$serializedOptions = serialize($options);
|
||||||
|
|
||||||
|
$this->XMLHTTPRequest('POST', '/prod/records/', array(
|
||||||
|
'env' => 'RESULT',
|
||||||
|
'options_serial' => $serializedOptions,
|
||||||
|
'pos' => 0,
|
||||||
|
'query' => ''
|
||||||
|
));
|
||||||
|
|
||||||
|
$response = self::$DI['client']->getResponse();
|
||||||
|
$data = json_decode($response->getContent());
|
||||||
|
|
||||||
|
$this->assertObjectHasAttribute('desc', $data);
|
||||||
|
$this->assertObjectHasAttribute('html_preview', $data);
|
||||||
|
$this->assertObjectHasAttribute('current', $data);
|
||||||
|
$this->assertObjectHasAttribute('others', $data);
|
||||||
|
$this->assertObjectHasAttribute('history', $data);
|
||||||
|
$this->assertObjectHasAttribute('popularity', $data);
|
||||||
|
$this->assertObjectHasAttribute('tools', $data);
|
||||||
|
$this->assertObjectHasAttribute('pos', $data);
|
||||||
|
$this->assertObjectHasAttribute('title', $data);
|
||||||
|
|
||||||
|
unset($response, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord
|
||||||
|
*/
|
||||||
|
public function testGetRecordDetailREG()
|
||||||
|
{
|
||||||
|
\phrasea::start(self::$DI['app']['phraseanet.configuration']);
|
||||||
|
$auth = new \Session_Authentication_None(self::$DI['user']);
|
||||||
|
self::$DI['app']->openAccount($auth);
|
||||||
|
self::$DI['record_story_1'];
|
||||||
|
|
||||||
|
$this->XMLHTTPRequest('POST', '/prod/records/', array(
|
||||||
|
'env' => 'REG',
|
||||||
|
'pos' => 0,
|
||||||
|
'query' => '',
|
||||||
|
'cont' => self::$DI['record_story_1']->get_serialize_key()
|
||||||
|
));
|
||||||
|
|
||||||
|
$response = self::$DI['client']->getResponse();
|
||||||
|
$data = json_decode($response->getContent());
|
||||||
|
$this->assertObjectHasAttribute('desc', $data);
|
||||||
|
$this->assertObjectHasAttribute('html_preview', $data);
|
||||||
|
$this->assertObjectHasAttribute('current', $data);
|
||||||
|
$this->assertObjectHasAttribute('others', $data);
|
||||||
|
$this->assertObjectHasAttribute('history', $data);
|
||||||
|
$this->assertObjectHasAttribute('popularity', $data);
|
||||||
|
$this->assertObjectHasAttribute('tools', $data);
|
||||||
|
$this->assertObjectHasAttribute('pos', $data);
|
||||||
|
$this->assertObjectHasAttribute('title', $data);
|
||||||
|
|
||||||
|
unset($response, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord
|
||||||
|
*/
|
||||||
|
public function testGetRecordDetailBasket()
|
||||||
|
{
|
||||||
|
\phrasea::start(self::$DI['app']['phraseanet.configuration']);
|
||||||
|
$auth = new \Session_Authentication_None(self::$DI['user']);
|
||||||
|
self::$DI['app']->openAccount($auth);
|
||||||
|
$basket = $this->insertOneBasket();
|
||||||
|
$record = self::$DI['record_1'];
|
||||||
|
|
||||||
|
$basketElement = new \Entities\BasketElement();
|
||||||
|
$basketElement->setBasket($basket);
|
||||||
|
$basketElement->setRecord($record);
|
||||||
|
$basketElement->setLastInBasket();
|
||||||
|
|
||||||
|
$basket->addBasketElement($basketElement);
|
||||||
|
|
||||||
|
self::$DI['app']['EM']->persist($basket);
|
||||||
|
self::$DI['app']['EM']->flush();
|
||||||
|
|
||||||
|
$this->XMLHTTPRequest('POST', '/prod/records/', array(
|
||||||
|
'env' => 'BASK',
|
||||||
|
'pos' => 0,
|
||||||
|
'query' => '',
|
||||||
|
'cont' => $basket->getId()
|
||||||
|
));
|
||||||
|
|
||||||
|
$response = self::$DI['client']->getResponse();
|
||||||
|
$data = json_decode($response->getContent());
|
||||||
|
|
||||||
|
$this->assertObjectHasAttribute('desc', $data);
|
||||||
|
$this->assertObjectHasAttribute('html_preview', $data);
|
||||||
|
$this->assertObjectHasAttribute('current', $data);
|
||||||
|
$this->assertObjectHasAttribute('others', $data);
|
||||||
|
$this->assertObjectHasAttribute('history', $data);
|
||||||
|
$this->assertObjectHasAttribute('popularity', $data);
|
||||||
|
$this->assertObjectHasAttribute('tools', $data);
|
||||||
|
$this->assertObjectHasAttribute('pos', $data);
|
||||||
|
$this->assertObjectHasAttribute('title', $data);
|
||||||
|
|
||||||
|
unset($response, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord
|
||||||
|
*/
|
||||||
|
public function testGetRecordDetailFeed()
|
||||||
|
{
|
||||||
|
\phrasea::start(self::$DI['app']['phraseanet.configuration']);
|
||||||
|
$auth = new \Session_Authentication_None(self::$DI['user']);
|
||||||
|
self::$DI['app']->openAccount($auth);
|
||||||
|
|
||||||
|
self::$feed = Feed_Adapter::create(
|
||||||
|
self::$DI['app'],
|
||||||
|
self::$DI['user'],
|
||||||
|
'titi',
|
||||||
|
'toto'
|
||||||
|
);
|
||||||
|
|
||||||
|
$feedEntry = Feed_Entry_Adapter::create(
|
||||||
|
self::$DI['app'],
|
||||||
|
self::$feed,
|
||||||
|
Feed_Publisher_Adapter::getPublisher(
|
||||||
|
self::$DI['app']['phraseanet.appbox'],
|
||||||
|
self::$feed,
|
||||||
|
self::$DI['user']
|
||||||
|
),
|
||||||
|
'titi',
|
||||||
|
'toto',
|
||||||
|
'tata',
|
||||||
|
'tutu@test.fr'
|
||||||
|
);
|
||||||
|
|
||||||
|
Feed_Entry_Item::create(
|
||||||
|
self::$DI['app']['phraseanet.appbox'],
|
||||||
|
$feedEntry,
|
||||||
|
self::$DI['record_1']
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->XMLHTTPRequest('POST', '/prod/records/', array(
|
||||||
|
'env' => 'FEED',
|
||||||
|
'pos' => 0,
|
||||||
|
'query' => '',
|
||||||
|
'cont' => $feedEntry->get_id()
|
||||||
|
));
|
||||||
|
|
||||||
|
$response = self::$DI['client']->getResponse();
|
||||||
|
$data = json_decode($response->getContent());
|
||||||
|
$this->assertObjectHasAttribute('desc', $data);
|
||||||
|
$this->assertObjectHasAttribute('html_preview', $data);
|
||||||
|
$this->assertObjectHasAttribute('current', $data);
|
||||||
|
$this->assertObjectHasAttribute('others', $data);
|
||||||
|
$this->assertObjectHasAttribute('history', $data);
|
||||||
|
$this->assertObjectHasAttribute('popularity', $data);
|
||||||
|
$this->assertObjectHasAttribute('tools', $data);
|
||||||
|
$this->assertObjectHasAttribute('pos', $data);
|
||||||
|
$this->assertObjectHasAttribute('title', $data);
|
||||||
|
|
||||||
|
unset($response, $data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user