mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 11:33:17 +00:00
Fix tests, add entity name in API responses
This commit is contained in:
@@ -41,6 +41,9 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
*/
|
*/
|
||||||
protected $core;
|
protected $core;
|
||||||
|
|
||||||
|
const OBJECT_TYPE_STORY = 'http://api.phraseanet.com/api/objects/story';
|
||||||
|
const OBJECT_TYPE_STORY_METADATA_BAG = 'http://api.phraseanet.com/api/objects/story-metadata-bag';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API constructor
|
* API constructor
|
||||||
*
|
*
|
||||||
@@ -1990,6 +1993,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
};
|
};
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
'@entity@' => self::OBJECT_TYPE_STORY,
|
||||||
'databox_id' => $story->get_sbas_id(),
|
'databox_id' => $story->get_sbas_id(),
|
||||||
'story_id' => $story->get_record_id(),
|
'story_id' => $story->get_record_id(),
|
||||||
'updated_on' => $story->get_modification_date()->format(DATE_ATOM),
|
'updated_on' => $story->get_modification_date()->format(DATE_ATOM),
|
||||||
@@ -1998,6 +2002,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
'thumbnail' => $this->list_embedable_media($story->get_thumbnail(), registry::get_instance()),
|
'thumbnail' => $this->list_embedable_media($story->get_thumbnail(), registry::get_instance()),
|
||||||
'uuid' => $story->get_uuid(),
|
'uuid' => $story->get_uuid(),
|
||||||
'metadatas' => array(
|
'metadatas' => array(
|
||||||
|
'@entity@' => self::OBJECT_TYPE_STORY_METADATA_BAG,
|
||||||
'dc:contributor' => $format($caption, databox_Field_DCESAbstract::Contributor),
|
'dc:contributor' => $format($caption, databox_Field_DCESAbstract::Contributor),
|
||||||
'dc:coverage' => $format($caption, databox_Field_DCESAbstract::Coverage),
|
'dc:coverage' => $format($caption, databox_Field_DCESAbstract::Coverage),
|
||||||
'dc:creator' => $format($caption, databox_Field_DCESAbstract::Creator),
|
'dc:creator' => $format($caption, databox_Field_DCESAbstract::Creator),
|
||||||
|
@@ -800,6 +800,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
|||||||
|
|
||||||
$this->evaluateSearchResponse($response);
|
$this->evaluateSearchResponse($response);
|
||||||
|
|
||||||
|
$this->assertArrayHasKey('stories', $response['results']);
|
||||||
|
$this->assertArrayHasKey('records', $response['results']);
|
||||||
|
|
||||||
$found = false;
|
$found = false;
|
||||||
|
|
||||||
foreach ($response['results']['records'] as $record) {
|
foreach ($response['results']['records'] as $record) {
|
||||||
@@ -833,6 +836,9 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
|||||||
|
|
||||||
$this->evaluateSearchResponse($response);
|
$this->evaluateSearchResponse($response);
|
||||||
|
|
||||||
|
$this->assertArrayHasKey('stories', $response['results']);
|
||||||
|
$this->assertArrayHasKey('records', $response['results']);
|
||||||
|
|
||||||
$found = false;
|
$found = false;
|
||||||
|
|
||||||
foreach ($response['results']['stories'] as $story) {
|
foreach ($response['results']['stories'] as $story) {
|
||||||
@@ -990,6 +996,10 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
|||||||
{
|
{
|
||||||
$this->setToken(self::$token);
|
$this->setToken(self::$token);
|
||||||
|
|
||||||
|
$media = self::$core['mediavorus']->guess(new \SplFileInfo(__DIR__ . '/../../../testfiles/cestlafete.jpg'));
|
||||||
|
static::$records['record_story_1']->substitute_subdef('preview', $media);
|
||||||
|
static::$records['record_story_1']->substitute_subdef('thumbnail', $media);
|
||||||
|
|
||||||
$keys = array_keys(static::$records['record_story_1']->get_subdefs());
|
$keys = array_keys(static::$records['record_story_1']->get_subdefs());
|
||||||
|
|
||||||
$route = '/stories/' . static::$records['record_story_1']->get_sbas_id() . '/' . static::$records['record_story_1']->get_record_id() . '/embed/';
|
$route = '/stories/' . static::$records['record_story_1']->get_sbas_id() . '/' . static::$records['record_story_1']->get_record_id() . '/embed/';
|
||||||
@@ -2180,7 +2190,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
|||||||
$this->assertArrayHasKey('response', $content);
|
$this->assertArrayHasKey('response', $content);
|
||||||
$this->assertTrue(is_array($content['meta']), 'Le bloc meta est un array');
|
$this->assertTrue(is_array($content['meta']), 'Le bloc meta est un array');
|
||||||
$this->assertTrue(is_array($content['response']), 'Le bloc reponse est un array');
|
$this->assertTrue(is_array($content['response']), 'Le bloc reponse est un array');
|
||||||
$this->assertEquals('1.2', $content['meta']['api_version']);
|
$this->assertEquals('1.3', $content['meta']['api_version']);
|
||||||
$this->assertNotNull($content['meta']['response_time']);
|
$this->assertNotNull($content['meta']['response_time']);
|
||||||
$this->assertEquals('UTF-8', $content['meta']['charset']);
|
$this->assertEquals('UTF-8', $content['meta']['charset']);
|
||||||
}
|
}
|
||||||
@@ -2354,6 +2364,8 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
|||||||
$this->assertTrue(is_int($story['collection_id']));
|
$this->assertTrue(is_int($story['collection_id']));
|
||||||
$this->assertArrayHasKey('thumbnail', $story);
|
$this->assertArrayHasKey('thumbnail', $story);
|
||||||
$this->assertArrayHasKey('uuid', $story);
|
$this->assertArrayHasKey('uuid', $story);
|
||||||
|
$this->assertArrayHasKey('@entity@', $story);
|
||||||
|
$this->assertEquals(\API_V1_adapter::OBJECT_TYPE_STORY, $story['@entity@']);
|
||||||
$this->assertTrue(\uuid::is_valid($story['uuid']));
|
$this->assertTrue(\uuid::is_valid($story['uuid']));
|
||||||
|
|
||||||
if ( ! is_null($story['thumbnail'])) {
|
if ( ! is_null($story['thumbnail'])) {
|
||||||
@@ -2374,6 +2386,20 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
|||||||
$this->assertArrayHasKey('records', $story);
|
$this->assertArrayHasKey('records', $story);
|
||||||
$this->assertInternalType('array', $story['records']);
|
$this->assertInternalType('array', $story['records']);
|
||||||
|
|
||||||
|
foreach ($story['metadatas'] as $key => $metadata) {
|
||||||
|
if (null !== $metadata) {
|
||||||
|
$this->assertInternalType('string', $metadata);
|
||||||
|
}
|
||||||
|
if ($key === '@entity@') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEquals(0, strpos($key, 'dc:'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertArrayHasKey('@entity@', $story['metadatas']);
|
||||||
|
$this->assertEquals(\API_V1_adapter::OBJECT_TYPE_STORY_METADATA_BAG, $story['metadatas']['@entity@']);
|
||||||
|
|
||||||
foreach ($story['records'] as $record) {
|
foreach ($story['records'] as $record) {
|
||||||
$this->evaluateGoodRecord($record);
|
$this->evaluateGoodRecord($record);
|
||||||
}
|
}
|
||||||
@@ -2493,8 +2519,5 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract
|
|||||||
$this->assertTrue(is_array($response['suggestions']));
|
$this->assertTrue(is_array($response['suggestions']));
|
||||||
$this->assertTrue(is_array($response['results']));
|
$this->assertTrue(is_array($response['results']));
|
||||||
$this->assertTrue(is_string($response['query']));
|
$this->assertTrue(is_string($response['query']));
|
||||||
|
|
||||||
$this->assertArrayHasKey('stories', $response['results']);
|
|
||||||
$this->assertArrayHasKey('records', $response['results']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user