Fix story set metadata collection.

This commit is contained in:
Benoît Burnichon
2015-07-13 11:18:12 +02:00
parent afbacaa640
commit f5949cd9f4
3 changed files with 18 additions and 19 deletions

View File

@@ -49,8 +49,6 @@ class caption_record implements caption_interface, cache_cacheableInterface
$this->sbas_id = $record->get_sbas_id();
$this->record = $record;
$this->databox = $databox;
return $this;
}
public function get_record()

View File

@@ -676,16 +676,14 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
$values = $field->get_values();
$value = end($values);
$meta_struct_id = $field->get_meta_struct_id();
$meta_id = $value->getId();
$this->set_metadatas([[
'meta_struct_id' => $field->get_meta_struct_id(),
'meta_id' => $value->getId(),
'value' => $original_name,
]], true);
} catch (\Exception $e) {
$meta_struct_id = null;
$meta_id = null;
// Caption is not setup, ignore error
}
$this->set_metadatas([
['meta_struct_id' => $meta_struct_id, 'meta_id' => $meta_id, 'value' => $original_name],
], true);
}
$this->get_databox()->get_connection()->executeUpdate(

View File

@@ -73,22 +73,25 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
$this->setToken($this->userAccessToken);
$route = '/api/v1/stories';
$story['base_id'] = self::$DI['collection']->get_base_id();
$collection = $this->getCollection();
$story['base_id'] = $collection->get_base_id();
$story['title'] = uniqid('story');
$app = $this->getApplication();
$file = new File(
self::$DI['app'],
self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/p4logo.jpg'),
self::$DI['collection']
$app,
$app['mediavorus']->guess(__DIR__ . '/../../../../../files/p4logo.jpg'),
$collection
);
$record = \record_adapter::createFromFile($file, self::$DI['app']);
$record = \record_adapter::createFromFile($file, $app);
$story['story_records'] = array(array(
'databox_id' => $record->get_sbas_id(),
'record_id' => $record->get_record_id()
));
self::$DI['client']->request(
$client = $this->getClient();
$client->request(
'POST',
$route,
$this->getParameters(),
@@ -99,16 +102,16 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
],
json_encode(array('stories' => array($story)))
);
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
$content = $this->unserialize($client->getResponse()->getContent());
$this->evaluateResponse200(self::$DI['client']->getResponse());
$this->evaluateResponse200($client->getResponse());
$this->evaluateMeta200($content);
$data = $content['response'];
$this->assertArrayHasKey('stories', $data);
$this->assertCount(1, $data['stories']);
list($empty, $path, $databox_id, $story_id) = explode('/', current($data['stories']));
$databox = self::$DI['app']->findDataboxById($databox_id);
$databox = $app->findDataboxById($databox_id);
$story = $databox->get_record($story_id);
$story->delete();
$record->delete();