mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
This is a combination of 33 commits.
- Squashed Pull request #1730 - Squashed Pull request #1741 - Squashed Pull request #1742 - Squash merge branch 4.0 - Squashed Pull request #1744 - Squashed Pull request #1746 - Squashed merge branch 4.0 - Squashed merge branch 4.0 - Squashed merge branch 4.0 - Squashed merge branch 4.0 - Squashed Pull request #1758 - Avoid using imagine/imagine alias as it is causing install issues - Squashed merge branch 4.0 - Squashed Pull request #1763 - Squashed merge branch 4.0 - Squash of 6 commits - Squashed merge branch 4.0 - This is a combination of 2 commits. - Squashed Pull request #1775 - Squashed Pull request #1777 - Squashed Pull request #1779 - Squashed Pull request #1780 - Squashed Pull request #1782 - Adds a Pull request template - Squased Pull request #1783 - Squash Pull request #1786 - Squashed Pull request #1796 - Squashed merge branch 4.0 - Squash Pull request #1791 - Squashed merge branch 4.0 - Squashed Pull request #1808 - Squashed Pull request #1811 - Squashed Pull request #1809
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
namespace Alchemy\Tests\Phrasea\Controller\Admin;
|
||||
|
||||
use PHPExiftool\Driver\Tag\IPTC\ObjectName;
|
||||
use Alchemy\Phrasea\Vocabulary\Controller as VocabularyController;
|
||||
use Symfony\Component\HttpKernel\Client;
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
@@ -16,18 +14,17 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
public function testRoot()
|
||||
{
|
||||
$databoxes = self::$DI['app']->getDataboxes();
|
||||
$databoxes = $this->getApplication()->getDataboxes();
|
||||
$databox = array_shift($databoxes);
|
||||
|
||||
self::$DI['client']->request("GET", "/admin/fields/" . $databox->get_sbas_id());
|
||||
$response = $this->request("GET", "/admin/fields/" . $databox->get_sbas_id());
|
||||
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||
$this->assertTrue($response->isOk());
|
||||
}
|
||||
|
||||
public function testLanguage()
|
||||
{
|
||||
self::$DI['client']->request("GET", "/admin/fields/language.json");
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$response = $this->request("GET", "/admin/fields/language.json");
|
||||
|
||||
$this->assertTrue($response->isOk());
|
||||
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
||||
@@ -37,9 +34,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
$tag = new ObjectName();
|
||||
|
||||
self::$DI['client']->request("GET", "/admin/fields/tags/".$tag->getTagname());
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$response = $this->request("GET", "/admin/fields/tags/".$tag->getTagname());
|
||||
|
||||
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
||||
$data = json_decode($response->getContent(), true);
|
||||
@@ -52,13 +47,11 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
public function testListDcFields()
|
||||
{
|
||||
self::$DI['client']->request("GET", "/admin/fields/dc-fields");
|
||||
$response = $this->request("GET", "/admin/fields/dc-fields");
|
||||
|
||||
$response = self::$DI['client']->getResponse()->getContent();
|
||||
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
||||
|
||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||
|
||||
$data = json_decode($response, true);
|
||||
$data = json_decode($response->getContent(), true);
|
||||
$this->assertInternalType('array', $data);
|
||||
|
||||
foreach ($data as $dc) {
|
||||
@@ -72,49 +65,40 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
public function testListVocabularies()
|
||||
{
|
||||
self::$DI['client']->request("GET", "/admin/fields/vocabularies");
|
||||
$response = $this->request("GET", "/admin/fields/vocabularies");
|
||||
|
||||
$response = self::$DI['client']->getResponse()->getContent();
|
||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
||||
|
||||
$data = json_decode($response, true);
|
||||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
$this->assertInternalType('array', $data);
|
||||
|
||||
foreach ($data as $vocabulary) {
|
||||
$this->assertArrayHasKey('type', $vocabulary);
|
||||
$this->assertArrayHasKey('name', $vocabulary);
|
||||
|
||||
$voc = VocabularyController::get(self::$DI['app'], $vocabulary['type']);
|
||||
$this->assertInstanceOf('Alchemy\Phrasea\Vocabulary\ControlProvider\ControlProviderInterface', $voc);
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetVocabulary()
|
||||
{
|
||||
self::$DI['client']->request("GET", "/admin/fields/vocabularies/user");
|
||||
$response = $this->request("GET", "/admin/fields/vocabularies/user");
|
||||
|
||||
$response = self::$DI['client']->getResponse()->getContent();
|
||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
||||
|
||||
$data = json_decode($response, true);
|
||||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
$this->assertArrayHasKey('type', $data);
|
||||
$this->assertEquals('User', $data['type']);
|
||||
$this->assertArrayHasKey('name', $data);
|
||||
|
||||
$voc = VocabularyController::get(self::$DI['app'], $data['type']);
|
||||
$this->assertInstanceOf('Alchemy\Phrasea\Vocabulary\ControlProvider\UserProvider', $voc);
|
||||
}
|
||||
|
||||
public function testSearchTag()
|
||||
{
|
||||
self::$DI['client']->request("GET", "/admin/fields/tags/search?term=xmp-exif");
|
||||
$response = $this->request("GET", "/admin/fields/tags/search?term=xmp-exif");
|
||||
|
||||
$response = self::$DI['client']->getResponse()->getContent();
|
||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
||||
|
||||
$data = json_decode($response, true);
|
||||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
$this->assertGreaterThan(90, count($data));
|
||||
|
||||
@@ -128,7 +112,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
public function testUpdateFields()
|
||||
{
|
||||
$databoxes = self::$DI['app']->getDataboxes();
|
||||
$databoxes = $this->getApplication()->getDataboxes();
|
||||
$databox = array_shift($databoxes);
|
||||
$fieldObjects = [];
|
||||
// create two fields
|
||||
@@ -170,7 +154,7 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
]];
|
||||
|
||||
foreach ($fields as $fieldData) {
|
||||
$field = \databox_field::create(self::$DI['app'], $databox, $fieldData['name'], $fieldData['multi']);
|
||||
$field = \databox_field::create($this->getApplication(), $databox, $fieldData['name'], $fieldData['multi']);
|
||||
$field
|
||||
->set_thumbtitle($fieldData['thumbtitle'])
|
||||
->set_tag(\databox_field::loadClassFromTagName($fieldData['tag']))
|
||||
@@ -197,13 +181,11 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$body[count($body) - 1]['readonly'] = true;
|
||||
$body[count($body) - 1]['required'] = false;
|
||||
|
||||
self::$DI['client']->request("PUT", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), [], [], [], json_encode($body));
|
||||
$response = $this->request("PUT", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), [], [], json_encode($body));
|
||||
|
||||
$response = self::$DI['client']->getResponse()->getContent();
|
||||
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
||||
|
||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||
|
||||
$data = json_decode($response, true);
|
||||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
$this->assertTrue(is_array($data));
|
||||
|
||||
@@ -248,14 +230,11 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
'vocabulary-restricted' => true,
|
||||
]);
|
||||
|
||||
/** @var Client $client */
|
||||
$client = self::$DI['client'];
|
||||
$client->request("POST", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), [], [], [], $body);
|
||||
$response = $this->request("POST", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), [], [], $body);
|
||||
|
||||
$response = $client->getResponse()->getContent();
|
||||
$this->assertEquals("application/json", $client->getResponse()->headers->get("content-type"));
|
||||
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
||||
|
||||
$data = json_decode($response, true);
|
||||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
$this->assertTrue(is_array($data));
|
||||
|
||||
@@ -271,15 +250,14 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
public function testListField()
|
||||
{
|
||||
$databoxes = self::$DI['app']->getDataboxes();
|
||||
$databoxes = $this->getApplication()->getDataboxes();
|
||||
$databox = array_shift($databoxes);
|
||||
|
||||
self::$DI['client']->request("GET", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()));
|
||||
$response = $this->request("GET", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()));
|
||||
|
||||
$response = self::$DI['client']->getResponse()->getContent();
|
||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
||||
|
||||
$data = json_decode($response, true);
|
||||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
$this->assertInternalType('array', $data);
|
||||
|
||||
@@ -297,13 +275,11 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
$data = $field->toArray();
|
||||
|
||||
$client = $this->getClient();
|
||||
$client->request("GET", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()));
|
||||
$response = $this->request("GET", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()));
|
||||
|
||||
$response = $client->getResponse()->getContent();
|
||||
$this->assertEquals("application/json", $client->getResponse()->headers->get("content-type"));
|
||||
$this->assertEquals("application/json", $response->headers->get("content-type"));
|
||||
|
||||
$this->assertEquals($data, json_decode($response, true));
|
||||
$this->assertEquals($data, json_decode($response->getContent(), true));
|
||||
|
||||
$field->delete();
|
||||
}
|
||||
@@ -320,11 +296,9 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$data['business'] = true;
|
||||
$data['vocabulary-type'] = 'User';
|
||||
|
||||
$client = $this->getClient();
|
||||
$client->request("PUT", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()), [], [], [], json_encode($data));
|
||||
$response = $this->request("PUT", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()), [], [], json_encode($data));
|
||||
|
||||
$response = $client->getResponse()->getContent();
|
||||
$this->assertEquals($data, json_decode($response, true));
|
||||
$this->assertEquals($data, json_decode($response->getContent(), true));
|
||||
|
||||
$field->delete();
|
||||
}
|
||||
@@ -342,13 +316,10 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$data['business'] = true;
|
||||
$data['vocabulary-type'] = 'User';
|
||||
|
||||
/** @var Client $client */
|
||||
$client = self::$DI['client'];
|
||||
$client->request("DELETE", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()), [], [], [], json_encode($data));
|
||||
$response = $this->request("DELETE", sprintf("/admin/fields/%d/fields/%d", $databox->get_sbas_id(), $field->get_id()), [], [], json_encode($data));
|
||||
|
||||
$response = $client->getResponse()->getContent();
|
||||
$this->assertEquals('', $response);
|
||||
$this->assertEquals(204, $client->getResponse()->getStatusCode());
|
||||
$this->assertEquals('', $response->getContent());
|
||||
$this->assertEquals(204, $response->getStatusCode());
|
||||
|
||||
try {
|
||||
$databox->get_meta_structure()->get_element($fieldId);
|
||||
|
@@ -60,8 +60,8 @@ class ApiJsonTest extends ApiTestCase
|
||||
$record = \record_adapter::createFromFile($file, $app);
|
||||
|
||||
$story['story_records'] = array(array(
|
||||
'databox_id' => $record->get_sbas_id(),
|
||||
'record_id' => $record->get_record_id()
|
||||
'databox_id' => $record->getDataboxId(),
|
||||
'record_id' => $record->getRecordId()
|
||||
));
|
||||
|
||||
$client = $this->getClient();
|
||||
@@ -96,7 +96,7 @@ class ApiJsonTest extends ApiTestCase
|
||||
$this->setToken($this->userAccessToken);
|
||||
$story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']);
|
||||
|
||||
$route = sprintf('/api/v1/stories/%s/%s/addrecords', $story->get_sbas_id(), $story->get_record_id());
|
||||
$route = sprintf('/api/v1/stories/%s/%s/addrecords', $story->getDataboxId(), $story->getRecordId());
|
||||
|
||||
$file = new File(
|
||||
self::$DI['app'],
|
||||
@@ -106,8 +106,8 @@ class ApiJsonTest extends ApiTestCase
|
||||
$record = \record_adapter::createFromFile($file, self::$DI['app']);
|
||||
|
||||
$records = array(
|
||||
'databox_id' => $record->get_sbas_id(),
|
||||
'record_id' => $record->get_record_id()
|
||||
'databox_id' => $record->getDataboxId(),
|
||||
'record_id' => $record->getRecordId()
|
||||
);
|
||||
|
||||
self::$DI['client']->request(
|
||||
@@ -549,7 +549,7 @@ class ApiJsonTest extends ApiTestCase
|
||||
$record_1 = $this->getRecord1();
|
||||
$client = $this->getClient();
|
||||
|
||||
$route = '/api/v1/records/' . $record_1->get_sbas_id() . '/' . $record_1->get_record_id() . '/';
|
||||
$route = '/api/v1/records/' . $record_1->getDataboxId() . '/' . $record_1->getRecordId() . '/';
|
||||
$this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']);
|
||||
$client->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]);
|
||||
$content = $this->unserialize($client->getResponse()->getContent());
|
||||
@@ -903,11 +903,14 @@ class ApiJsonTest extends ApiTestCase
|
||||
->method('getSuggestions')
|
||||
->will($this->returnValue(new ArrayCollection()));
|
||||
|
||||
self::$DI['app']['phraseanet.SE'] = $this->getMock('Alchemy\Phrasea\SearchEngine\SearchEngineInterface');
|
||||
$app = $this->getApplication();
|
||||
$mock = $this->getMock('Alchemy\Phrasea\SearchEngine\SearchEngineInterface');
|
||||
$app['phraseanet.SE'] = $mock;
|
||||
|
||||
self::$DI['app']['phraseanet.SE']->expects($this->once())
|
||||
$mock
|
||||
->expects($this->once())
|
||||
->method('query')
|
||||
->with('koala', 0, 10)
|
||||
->withAnyParameters()
|
||||
->will($this->returnValue(
|
||||
$this->getMockBuilder('Alchemy\Phrasea\SearchEngine\SearchEngineResult')
|
||||
->disableOriginalConstructor()
|
||||
@@ -1012,7 +1015,7 @@ class ApiJsonTest extends ApiTestCase
|
||||
|
||||
/** @var \record_adapter $record_1 */
|
||||
$record_1 = self::$DI['record_1'];
|
||||
$route = '/api/v1/records/' . $record_1->get_sbas_id() . '/' . $record_1->get_record_id() . '/embed/';
|
||||
$route = '/api/v1/records/' . $record_1->getDataboxId() . '/' . $record_1->getRecordId() . '/embed/';
|
||||
$this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']);
|
||||
|
||||
/** @var Client $client */
|
||||
@@ -1099,7 +1102,7 @@ class ApiJsonTest extends ApiTestCase
|
||||
/** @var \record_adapter $story */
|
||||
$story = self::$DI['record_story_1'];
|
||||
|
||||
$route = '/api/v1/stories/' . $story->get_sbas_id() . '/' . $story->get_record_id() . '/embed/';
|
||||
$route = '/api/v1/stories/' . $story->getDataboxId() . '/' . $story->getRecordId() . '/embed/';
|
||||
$this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']);
|
||||
|
||||
/** @var Client $client */
|
||||
@@ -1234,13 +1237,15 @@ class ApiJsonTest extends ApiTestCase
|
||||
|
||||
public function testRecordsSetStatus()
|
||||
{
|
||||
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||
$app = $this->getApplication();
|
||||
$app['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||
$this->setToken($this->userAccessToken);
|
||||
|
||||
$route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/setstatus/';
|
||||
$record1 = $this->getRecord1();
|
||||
$route = '/api/v1/records/' . $record1->getDataboxId() . '/' . $record1->getRecordId() . '/setstatus/';
|
||||
|
||||
$record_status = strrev(self::$DI['record_1']->get_status());
|
||||
$statusStructure = self::$DI['record_1']->getStatusStructure();
|
||||
$record_status = strrev($record1->getStatus());
|
||||
$statusStructure = $record1->getStatusStructure();
|
||||
|
||||
$tochange = [];
|
||||
foreach ($statusStructure as $n => $datas) {
|
||||
@@ -1248,20 +1253,18 @@ class ApiJsonTest extends ApiTestCase
|
||||
}
|
||||
$this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']);
|
||||
|
||||
self::$DI['client']->request('POST', $route, $this->getParameters(['status' => $tochange]), [], ['HTTP_Accept' => $this->getAcceptMimeType()]);
|
||||
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
||||
$response = $this->request('POST', $route, $this->getParameters(['status' => $tochange]), ['HTTP_Accept' => $this->getAcceptMimeType()]);
|
||||
$content = $this->unserialize($response->getContent());
|
||||
|
||||
/**
|
||||
* Get fresh record_1
|
||||
*/
|
||||
$testRecord = new \record_adapter(self::$DI['app'], self::$DI['record_1']->get_sbas_id(), self::$DI['record_1']->get_record_id());
|
||||
// Get fresh record_1
|
||||
$testRecord = new \record_adapter($app, $record1->getDataboxId(), $record1->getRecordId());
|
||||
|
||||
$this->evaluateResponse200(self::$DI['client']->getResponse());
|
||||
$this->evaluateResponse200($response);
|
||||
$this->evaluateMeta200($content);
|
||||
|
||||
$this->evaluateRecordsStatusResponse($testRecord, $content);
|
||||
|
||||
$record_status = strrev($testRecord->get_status());
|
||||
$record_status = strrev($testRecord->getStatus());
|
||||
foreach ($statusStructure as $n => $datas) {
|
||||
$this->assertEquals(substr($record_status, ($n), 1), $tochange[$n]);
|
||||
}
|
||||
@@ -1270,25 +1273,23 @@ class ApiJsonTest extends ApiTestCase
|
||||
$tochange[$n] = $value == '0' ? '1' : '0';
|
||||
}
|
||||
|
||||
self::$DI['client']->request('POST', $route, $this->getParameters(['status' => $tochange]), [], ['HTTP_Accept' => $this->getAcceptMimeType()]);
|
||||
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
||||
$response = $this->request('POST', $route, $this->getParameters(['status' => $tochange]), ['HTTP_Accept' => $this->getAcceptMimeType()]);
|
||||
$content = $this->unserialize($response->getContent());
|
||||
|
||||
/**
|
||||
* Get fresh record_1
|
||||
*/
|
||||
$testRecord = new \record_adapter(self::$DI['app'], $testRecord->get_sbas_id(), $testRecord->get_record_id());
|
||||
// Get fresh record_1
|
||||
$testRecord = new \record_adapter($app, $testRecord->getDataboxId(), $testRecord->getRecordId());
|
||||
|
||||
$this->evaluateResponse200(self::$DI['client']->getResponse());
|
||||
$this->evaluateResponse200($response);
|
||||
$this->evaluateMeta200($content);
|
||||
|
||||
$this->evaluateRecordsStatusResponse($testRecord, $content);
|
||||
|
||||
$record_status = strrev($testRecord->get_status());
|
||||
$record_status = strrev($testRecord->getStatus());
|
||||
foreach ($statusStructure as $n => $datas) {
|
||||
$this->assertEquals(substr($record_status, ($n), 1), $tochange[$n]);
|
||||
}
|
||||
|
||||
self::$DI['record_1']->set_binary_status(str_repeat('0', 32));
|
||||
$record1->setStatus(str_repeat('0', 32));
|
||||
}
|
||||
|
||||
public function testMoveRecordToCollection()
|
||||
@@ -1299,11 +1300,11 @@ class ApiJsonTest extends ApiTestCase
|
||||
|
||||
$this->setToken($this->userAccessToken);
|
||||
|
||||
$route = '/api/v1/records/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/setcollection/';
|
||||
$route = '/api/v1/records/' . $record->getDataboxId() . '/' . $record->getRecordId() . '/setcollection/';
|
||||
|
||||
$base_id = false;
|
||||
foreach ($record->get_databox()->get_collections() as $collection) {
|
||||
if ($collection->get_base_id() != $record->get_base_id()) {
|
||||
foreach ($record->getDatabox()->get_collections() as $collection) {
|
||||
if ($collection->get_base_id() != $record->getBaseId()) {
|
||||
$base_id = $collection->get_base_id();
|
||||
break;
|
||||
}
|
||||
|
@@ -694,9 +694,9 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
||||
|
||||
protected function evaluateRecordsStatusResponse(\record_adapter $record, $content)
|
||||
{
|
||||
$statusStructure = $record->get_databox()->getStatusStructure();
|
||||
$statusStructure = $record->getDatabox()->getStatusStructure();
|
||||
|
||||
$r_status = strrev($record->get_status());
|
||||
$r_status = strrev($record->getStatus());
|
||||
$this->assertArrayHasKey('status', $content['response']);
|
||||
$this->assertEquals(count((array) $content['response']['status']), count($statusStructure->toArray()));
|
||||
foreach ($content['response']['status'] as $status) {
|
||||
@@ -714,7 +714,7 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
||||
|
||||
protected function injectMetadatas(\record_adapter $record)
|
||||
{
|
||||
foreach ($record->get_databox()->get_meta_structure()->get_elements() as $field) {
|
||||
foreach ($record->getDatabox()->get_meta_structure()->get_elements() as $field) {
|
||||
try {
|
||||
$values = $record->get_caption()->get_field($field->get_name())->get_values();
|
||||
$value = array_pop($values);
|
||||
|
@@ -57,7 +57,7 @@ class DownloadTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
//has_right_on_base return true
|
||||
$stubbedACL->expects($this->any())
|
||||
->method('has_right_on_bas')
|
||||
->method('has_right_on_base')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
//has_access_to_subdef return true
|
||||
|
@@ -142,7 +142,7 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
//inserted rows from this function are deleted in tearDownAfterClass
|
||||
$this->getClient()->request('POST', '/prod/export/ftp/', [
|
||||
'lst' => $this->getRecord1()->get_serialize_key(),
|
||||
'lst' => $this->getRecord1()->getId(),
|
||||
'user_dest' => $user->getId(),
|
||||
'address' => 'local.phrasea.test',
|
||||
'login' => $user->getEmail(),
|
||||
@@ -168,7 +168,7 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->mockNotificationDeliverer('Alchemy\Phrasea\Notification\Mail\MailRecordsExport');
|
||||
|
||||
$this->getClient()->request('POST', '/prod/export/mail/', [
|
||||
'lst' => $this->getRecord1()->get_serialize_key(),
|
||||
'lst' => $this->getRecord1()->getId(),
|
||||
'destmail' => 'user@example.com',
|
||||
'obj' => ['preview'],
|
||||
]);
|
||||
|
@@ -142,7 +142,7 @@ class LazaretTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
//Provide some valid test values
|
||||
$lazaretAttribute->expects($this->exactly(4))
|
||||
->method('getValue')
|
||||
->will($this->onConsecutiveCalls('metadataValue', $story->get_serialize_key(), '00001111', 'metafieldValue'));
|
||||
->will($this->onConsecutiveCalls('metadataValue', $story->getId(), '00001111', 'metafieldValue'));
|
||||
|
||||
//Add the 5 attribute
|
||||
$lazaretFile->addAttribute($lazaretAttribute);
|
||||
|
@@ -29,7 +29,7 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
});
|
||||
$client = $this->getClient();
|
||||
$client->request('POST', '/prod/order/', [
|
||||
'lst' => $this->getRecord1()->get_serialize_key(),
|
||||
'lst' => $this->getRecord1()->getId(),
|
||||
'deadline' => '+10 minutes'
|
||||
]);
|
||||
|
||||
@@ -54,7 +54,7 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
});
|
||||
|
||||
$response = $this->XMLHTTPRequest('POST', '/prod/order/', [
|
||||
'lst' => $this->getRecord1()->get_serialize_key(),
|
||||
'lst' => $this->getRecord1()->getId(),
|
||||
'deadline' => '+10 minutes'
|
||||
]);
|
||||
|
||||
@@ -71,7 +71,7 @@ class OrderTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
public function testDisplayOrders()
|
||||
{
|
||||
$this->XMLHTTPRequest('POST', '/prod/order/', [
|
||||
'lst' => $this->getRecord1()->get_serialize_key(),
|
||||
'lst' => $this->getRecord1()->getId(),
|
||||
'deadline' => '+10 minutes'
|
||||
]);
|
||||
$response = $this->request('GET', '/prod/order/', [
|
||||
|
@@ -102,12 +102,12 @@ class PropertyTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
self::$DI['app']['acl'] = $aclProvider;
|
||||
|
||||
self::$DI['client']->request('POST', '/prod/records/property/status/', [
|
||||
'apply_to_children' => [$story->get_sbas_id() => true],
|
||||
'apply_to_children' => [$story->getDataboxId() => true],
|
||||
'status' => [
|
||||
$record->get_sbas_id() => [6 => true, 8 => true, 11 => true]
|
||||
$record->getDataboxId() => [6 => true, 8 => true, 11 => true]
|
||||
],
|
||||
'lst' => implode(';', [
|
||||
$record->get_serialize_key(),$story->get_serialize_key()
|
||||
$record->getId(),$story->getId()
|
||||
])
|
||||
]);
|
||||
$response = self::$DI['client']->getResponse();
|
||||
@@ -116,11 +116,11 @@ class PropertyTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertTrue($datas['success']);
|
||||
$this->assertArrayHasKey('updated', $datas);
|
||||
|
||||
$record = new \record_adapter(self::$DI['app'], $record->get_sbas_id(), $record->get_record_id());
|
||||
$story = new \record_adapter(self::$DI['app'], $story->get_sbas_id(), $story->get_record_id());
|
||||
$record = new \record_adapter(self::$DI['app'], $record->getDataboxId(), $record->getRecordId());
|
||||
$story = new \record_adapter(self::$DI['app'], $story->getDataboxId(), $story->getRecordId());
|
||||
|
||||
$recordStatus = strrev($record->get_status());
|
||||
$storyStatus = strrev($story->get_status());
|
||||
$recordStatus = strrev($record->getStatus());
|
||||
$storyStatus = strrev($story->getStatus());
|
||||
|
||||
$this->assertEquals(1, substr($recordStatus, 6, 1));
|
||||
$this->assertEquals(1, substr($recordStatus, 8, 1));
|
||||
@@ -130,8 +130,8 @@ class PropertyTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertEquals(1, substr($storyStatus, 8, 1));
|
||||
$this->assertEquals(1, substr($storyStatus, 11, 1));
|
||||
|
||||
foreach ($story->get_children() as $child) {
|
||||
$childStatus = strrev($child->get_status());
|
||||
foreach ($story->getChildren() as $child) {
|
||||
$childStatus = strrev($child->getStatus());
|
||||
$this->assertEquals(1, substr($childStatus, 6, 1));
|
||||
$this->assertEquals(1, substr($childStatus, 8, 1));
|
||||
$this->assertEquals(1, substr($childStatus, 11, 1));
|
||||
@@ -155,11 +155,11 @@ class PropertyTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
self::$DI['client']->request('POST', '/prod/records/property/type/', [
|
||||
'lst' => implode(';', [
|
||||
$record->get_serialize_key(), $record2->get_serialize_key()
|
||||
$record->getId(), $record2->getId()
|
||||
]),
|
||||
'types' => [
|
||||
$record->get_serialize_key() => 'document',
|
||||
$record2->get_serialize_key() => 'flash',
|
||||
$record->getId() => 'document',
|
||||
$record2->getId() => 'flash',
|
||||
]
|
||||
]);
|
||||
$response = self::$DI['client']->getResponse();
|
||||
@@ -168,11 +168,11 @@ class PropertyTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertTrue($datas['success']);
|
||||
$this->assertArrayHasKey('updated', $datas);
|
||||
|
||||
$record = new \record_adapter(self::$DI['app'], $record->get_sbas_id(), $record->get_record_id());
|
||||
$record2 = new \record_adapter(self::$DI['app'], $record2->get_sbas_id(), $record2->get_record_id());
|
||||
$record = new \record_adapter(self::$DI['app'], $record->getDataboxId(), $record->getRecordId());
|
||||
$record2 = new \record_adapter(self::$DI['app'], $record2->getDataboxId(), $record2->getRecordId());
|
||||
|
||||
$this->assertEquals('document', $record->get_type());
|
||||
$this->assertEquals('flash', $record2->get_type());
|
||||
$this->assertEquals('document', $record->getType());
|
||||
$this->assertEquals('flash', $record2->getType());
|
||||
|
||||
$record->delete();
|
||||
$record2->delete();
|
||||
|
@@ -13,10 +13,6 @@ use Prophecy\Argument;
|
||||
*/
|
||||
class QueryTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Query::query
|
||||
*/
|
||||
public function testQuery()
|
||||
{
|
||||
$route = '/prod/query/';
|
||||
@@ -46,9 +42,6 @@ class QueryTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertInternalType('array', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Query::queryAnswerTrain
|
||||
*/
|
||||
public function testQueryAnswerTrain()
|
||||
{
|
||||
$app = $this->mockElasticsearchResult(self::$DI['record_2']);
|
||||
@@ -58,13 +51,11 @@ class QueryTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$options->onCollections($app->getAclForUser($app->getAuthenticatedUser())->get_granted_base());
|
||||
$serializedOptions = $options->serialize();
|
||||
|
||||
$client = $this->getClient();
|
||||
$client->request('POST', '/prod/query/answer-train/', [
|
||||
$response = $this->request('POST', '/prod/query/answer-train/', [
|
||||
'options_serial' => $serializedOptions,
|
||||
'pos' => 0,
|
||||
'query' => ''
|
||||
]);
|
||||
$response = $client->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
$datas = (array) json_decode($response->getContent());
|
||||
$this->assertArrayHasKey('current', $datas);
|
||||
|
@@ -18,9 +18,6 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Records::whatCanIDelete
|
||||
*/
|
||||
public function testWhatCanIDelete()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/prod/records/delete/what/', ['lst' => self::$DI['record_1']->get_serialize_key()]);
|
||||
@@ -29,40 +26,31 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
unset($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Records::doDeleteRecords
|
||||
*/
|
||||
public function testDoDeleteRecords()
|
||||
{
|
||||
$file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/cestlafete.jpg'), self::$DI['collection']);
|
||||
$record = \record_adapter::createFromFile($file, self::$DI['app']);
|
||||
$response = $this->XMLHTTPRequest('POST', '/prod/records/delete/', ['lst' => $record->get_serialize_key()]);
|
||||
$response = $this->XMLHTTPRequest('POST', '/prod/records/delete/', ['lst' => $record->getId()]);
|
||||
$datas = (array) json_decode($response->getContent());
|
||||
$this->assertContains($record->get_serialize_key(), $datas);
|
||||
$this->assertContains($record->getId(), $datas);
|
||||
try {
|
||||
new \record_adapter(self::$DI['app'], $record->get_sbas_id(), $record->get_record_id());
|
||||
new \record_adapter(self::$DI['app'], $record->getDataboxId(), $record->getRecordId());
|
||||
$this->fail('Record not deleted');
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Records::renewUrl
|
||||
*/
|
||||
public function testRenewUrl()
|
||||
{
|
||||
$file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/cestlafete.jpg'), self::$DI['collection']);
|
||||
$record = \record_adapter::createFromFile($file, self::$DI['app']);
|
||||
$response = $this->XMLHTTPRequest('POST', '/prod/records/renew-url/', ['lst' => $record->get_serialize_key()]);
|
||||
$response = $this->XMLHTTPRequest('POST', '/prod/records/renew-url/', ['lst' => $record->getId()]);
|
||||
$datas = (array) json_decode($response->getContent());
|
||||
$this->assertTrue(count($datas) > 0);
|
||||
$record->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord
|
||||
*/
|
||||
public function testGetRecordDetailNotAjax()
|
||||
{
|
||||
self::$DI['client']->request('POST', '/prod/records/');
|
||||
@@ -108,9 +96,6 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertArrayHasKey('title', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord
|
||||
*/
|
||||
public function testGetRecordDetailResult()
|
||||
{
|
||||
$app = $this->mockElasticsearchResult(self::$DI['record_1']);
|
||||
@@ -141,9 +126,6 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertArrayHasKey('title', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord
|
||||
*/
|
||||
public function testGetRecordDetailREG()
|
||||
{
|
||||
$this->authenticate(self::$DI['app']);
|
||||
@@ -168,9 +150,6 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertObjectHasAttribute('title', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord
|
||||
*/
|
||||
public function testGetRecordDetailBasket()
|
||||
{
|
||||
$this->authenticate(self::$DI['app']);
|
||||
@@ -198,9 +177,6 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
unset($response, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord
|
||||
*/
|
||||
public function testGetRecordDetailFeed()
|
||||
{
|
||||
$this->authenticate(self::$DI['app']);
|
||||
|
@@ -16,9 +16,8 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
public function testRouteSlash()
|
||||
{
|
||||
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||
self::$DI['client']->request('GET', '/prod/');
|
||||
$response = $this->request('GET', '/prod/');
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
$this->assertEquals('UTF-8', $response->getCharset());
|
||||
}
|
||||
|
@@ -100,7 +100,7 @@ class StoryTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
$story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']);
|
||||
|
||||
$route = sprintf("/prod/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id());
|
||||
$route = sprintf("/prod/story/%s/%s/addElements/", $story->getDataboxId(), $story->getRecordId());
|
||||
|
||||
$records = [
|
||||
self::$DI['record_1']->get_serialize_key(),
|
||||
@@ -115,7 +115,7 @@ class StoryTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
$this->assertEquals(302, $response->getStatusCode());
|
||||
|
||||
$this->assertEquals(2, $story->get_children()->get_count());
|
||||
$this->assertEquals(2, $story->getChildren()->get_count());
|
||||
$story->delete();
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ class StoryTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
$story = \record_adapter::createStory(self::$DI['app'], self::$DI['collection']);
|
||||
|
||||
$route = sprintf("/prod/story/%s/%s/addElements/", $story->get_sbas_id(), $story->get_record_id());
|
||||
$route = sprintf("/prod/story/%s/%s/addElements/", $story->getDataboxId(), $story->getRecordId());
|
||||
|
||||
$records = [
|
||||
self::$DI['record_1']->get_serialize_key(),
|
||||
@@ -140,7 +140,7 @@ class StoryTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
|
||||
$this->assertEquals(2, $story->get_children()->get_count());
|
||||
$this->assertEquals(2, $story->getChildren()->get_count());
|
||||
$story->delete();
|
||||
}
|
||||
|
||||
@@ -157,16 +157,16 @@ class StoryTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$story->appendChild($record);
|
||||
}
|
||||
|
||||
$totalRecords = $story->get_children()->get_count();
|
||||
$totalRecords = $story->getChildren()->get_count();
|
||||
$n = 0;
|
||||
foreach ($records as $record) {
|
||||
/* @var $record \record_adapter */
|
||||
$route = sprintf(
|
||||
"/prod/story/%s/%s/delete/%s/%s/"
|
||||
, $story->get_sbas_id()
|
||||
, $story->get_record_id()
|
||||
, $record->get_sbas_id()
|
||||
, $record->get_record_id()
|
||||
"/prod/story/%s/%s/delete/%s/%s/",
|
||||
$story->getDataboxId(),
|
||||
$story->getRecordId(),
|
||||
$record->getDataboxId(),
|
||||
$record->getRecordId()
|
||||
);
|
||||
|
||||
if (($n % 2) === 0) {
|
||||
@@ -188,7 +188,7 @@ class StoryTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertTrue($data['success']);
|
||||
}
|
||||
$n ++;
|
||||
$this->assertEquals($totalRecords - $n, $story->get_children()->get_count());
|
||||
$this->assertEquals($totalRecords - $n, $story->getChildren()->get_count());
|
||||
}
|
||||
$story->delete();
|
||||
}
|
||||
|
@@ -377,7 +377,7 @@ class UploadTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$id = explode('_', $datas['id']);
|
||||
$record = new \record_adapter(self::$DI['app'], $id[0], $id[1]);
|
||||
$this->assertFalse($record->isStory());
|
||||
$this->assertEquals(1, substr(strrev($record->get_status()), 4, 1));
|
||||
$this->assertEquals(1, substr(strrev($record->getStatus()), 4, 1));
|
||||
$this->assertEquals([], $datas['reasons']);
|
||||
}
|
||||
|
||||
|
@@ -269,8 +269,8 @@ class InformationsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
|
||||
'sbasid' => $this->getCollection()->get_sbas_id(),
|
||||
'collection' => $this->getCollection()->get_coll_id(),
|
||||
'sbasid' => $this->getRecord1()->get_sbas_id(),
|
||||
'rid' => $this->getRecord1()->get_record_id(),
|
||||
'sbasid' => $this->getRecord1()->getDataboxId(),
|
||||
'rid' => $this->getRecord1()->getRecordId(),
|
||||
]);
|
||||
|
||||
$response = $this->client->getResponse();
|
||||
@@ -285,8 +285,8 @@ class InformationsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
|
||||
'sbasid' => $this->getCollection()->get_sbas_id(),
|
||||
'collection' => $this->getCollection()->get_coll_id(),
|
||||
'sbasid' => $this->getRecord1()->get_sbas_id(),
|
||||
'rid' => $this->getRecord1()->get_record_id(),
|
||||
'sbasid' => $this->getRecord1()->getDataboxId(),
|
||||
'rid' => $this->getRecord1()->getRecordId(),
|
||||
'from' => 'TOOL'
|
||||
]);
|
||||
|
||||
@@ -302,8 +302,8 @@ class InformationsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
|
||||
'sbasid' => $this->getCollection()->get_sbas_id(),
|
||||
'collection' => $this->getCollection()->get_coll_id(),
|
||||
'sbasid' => $this->getRecord1()->get_sbas_id(),
|
||||
'rid' => $this->getRecord1()->get_record_id(),
|
||||
'sbasid' => $this->getRecord1()->getDataboxId(),
|
||||
'rid' => $this->getRecord1()->getRecordId(),
|
||||
'from' => 'DASH'
|
||||
]);
|
||||
|
||||
@@ -319,8 +319,8 @@ class InformationsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
'dmax' => $this->dmax->format('Y-m-d H:i:s'),
|
||||
'sbasid' => $this->getCollection()->get_sbas_id(),
|
||||
'collection' => $this->getCollection()->get_coll_id(),
|
||||
'sbasid' => $this->getRecord1()->get_sbas_id(),
|
||||
'rid' => $this->getRecord1()->get_record_id(),
|
||||
'sbasid' => $this->getRecord1()->getDataboxId(),
|
||||
'rid' => $this->getRecord1()->getRecordId(),
|
||||
'user' => $this->getUser()->getId()
|
||||
]);
|
||||
|
||||
|
@@ -388,7 +388,7 @@ class RSSFeedTest extends \PhraseanetWebTestCase
|
||||
$this->assertEquals($ressource->get_mime(), $value);
|
||||
break;
|
||||
case "medium":
|
||||
$this->assertEquals(strtolower($record->get_type()), $value);
|
||||
$this->assertEquals(strtolower($record->getType()), $value);
|
||||
break;
|
||||
case "isDefault":
|
||||
!$is_thumbnail ? $this->assertEquals("true", $value) : $this->assertEquals("false", $value);
|
||||
|
Reference in New Issue
Block a user