Merge branch 'master' of https://github.com/alchemy-fr/Phraseanet into PHRAS-1832-port-1776-to-master

This commit is contained in:
aina-esokia
2018-03-01 17:41:45 +04:00
11 changed files with 225 additions and 95 deletions

View File

@@ -59,10 +59,10 @@ class ApiJsonTest extends ApiTestCase
);
$record = \record_adapter::createFromFile($file, $app);
$story['story_records'] = array(array(
$story['story_records'] = [[
'databox_id' => $record->getDataboxId(),
'record_id' => $record->getRecordId()
));
]];
$client = $this->getClient();
$client->request(
@@ -74,7 +74,7 @@ class ApiJsonTest extends ApiTestCase
'HTTP_ACCEPT' => $this->getAcceptMimeType(),
'CONTENT_TYPE' => 'application/json',
],
json_encode(array('stories' => array($story)))
json_encode(['stories' => [$story]])
);
$content = $this->unserialize($client->getResponse()->getContent());
@@ -105,10 +105,10 @@ class ApiJsonTest extends ApiTestCase
);
$record = \record_adapter::createFromFile($file, self::$DI['app']);
$records = array(
$records = [
'databox_id' => $record->getDataboxId(),
'record_id' => $record->getRecordId()
);
];
self::$DI['client']->request(
'POST',
@@ -119,7 +119,7 @@ class ApiJsonTest extends ApiTestCase
'HTTP_ACCEPT' => $this->getAcceptMimeType(),
'CONTENT_TYPE' => 'application/json',
],
json_encode(array('story_records' => array($records)))
json_encode(['story_records' => [$records]])
);
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
@@ -147,10 +147,10 @@ class ApiJsonTest extends ApiTestCase
$story->appendChild($record);
$route = sprintf('/api/v1/stories/%s/%s/delrecords', $story->getDataboxId(), $story->getRecordId());
$records = array(
$records = [
'databox_id' => $record->getDataboxId(),
'record_id' => $record->getRecordId()
);
];
self::$DI['client']->request(
'DELETE',
@@ -161,7 +161,7 @@ class ApiJsonTest extends ApiTestCase
'HTTP_ACCEPT' => $this->getAcceptMimeType(),
'CONTENT_TYPE' => 'application/json',
],
json_encode(array('story_records' => array($records)))
json_encode(['story_records' => [$records]])
);
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
@@ -877,7 +877,6 @@ class ApiJsonTest extends ApiTestCase
$this->setToken($this->userAccessToken);
$response = $this->request('POST', '/api/v1/records/search/', $this->getParameters(), ['HTTP_Accept' => $this->getAcceptMimeType()]);
$content = $this->unserialize($response->getContent());
$this->evaluateResponse200($response);
$this->evaluateMeta200($content);
@@ -909,7 +908,7 @@ class ApiJsonTest extends ApiTestCase
$mock = $this->getMock('Alchemy\Phrasea\SearchEngine\SearchEngineInterface');
$app['phraseanet.SE'] = $mock;
$mock
$mock
->expects($this->once())
->method('query')
->withAnyParameters()
@@ -1065,7 +1064,7 @@ class ApiJsonTest extends ApiTestCase
$route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/embed/';
self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType()));
self::$DI['client']->request('GET', $route, $this->getParameters(), [], array('HTTP_Accept' => $this->getAcceptMimeType()));
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
$this->evaluateResponse200(self::$DI['client']->getResponse());
@@ -1093,7 +1092,7 @@ class ApiJsonTest extends ApiTestCase
$route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/embed/';
self::$DI['client']->request('GET', $route, $this->getParameters(), array(), array('HTTP_Accept' => $this->getAcceptMimeType()));
self::$DI['client']->request('GET', $route, $this->getParameters(), [], array('HTTP_Accept' => $this->getAcceptMimeType()));
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
$this->evaluateResponse200(self::$DI['client']->getResponse());

View File

@@ -23,8 +23,11 @@ class SearchEngineResultTest extends \PhraseanetTestCase
self::$DI['record_2']
]);
$user_query = 'Gotainer';
$engine_query = '{text:"Gotainer"}'; // fake, real is really more complex
$queryText = 'azerty';
$queryAST = '<text:"azerty">'; // fake, real is really more complex
$queryCompiled = '{match:"azerty"}'; // fake, real is really more complex
$queryESLib = '{index:"test", match:{"azerty"}}'; // fake, real is really more complex
$duration = 1 / 3;
$offsetStart = 23;
$available = 25;
@@ -32,12 +35,30 @@ class SearchEngineResultTest extends \PhraseanetTestCase
$error = 'this is an error message';
$warning = 'this is a warning message';
$suggestions = new ArrayCollection([
new SearchEngineSuggestion($user_query, 'Richard', 22)
new SearchEngineSuggestion($queryText, 'Richard', 22)
]);
$propositions = new ArrayCollection();
$indexes = 'new-index';
$result = new SearchEngineResult($options, $results, $user_query, $engine_query, $duration, $offsetStart, $available, $total, $error, $warning, $suggestions, $propositions, $indexes);
$result = new SearchEngineResult(
$options,
$results,
$queryText, // the query as typed by the user
$queryAST,
$queryCompiled,
$queryESLib,
$duration,
$offsetStart,
$available,
$total,
$error,
$warning,
$suggestions,
$propositions,
$indexes
);
$this->assertEquals($warning, $result->getWarning());
$this->assertEquals(2, $result->getTotalPages(23));
@@ -45,8 +66,12 @@ class SearchEngineResultTest extends \PhraseanetTestCase
$this->assertEquals($total, $result->getTotal());
$this->assertEquals($suggestions, $result->getSuggestions());
$this->assertEquals($results, $result->getResults());
$this->assertEquals($user_query, $result->getUserQuery());
$this->assertEquals($engine_query, $result->getEngineQuery());
$this->assertEquals($queryText, $result->getQueryText());
$this->assertEquals($queryAST, $result->getQueryAST());
$this->assertEquals($queryCompiled, $result->getQueryCompiled());
$this->assertEquals($queryESLib, $result->getQueryESLib());
$this->assertEquals($propositions, $result->getProposals());
$this->assertEquals($indexes, $result->getIndexes());
$this->assertEquals($error, $result->getError());
@@ -62,8 +87,11 @@ class SearchEngineResultTest extends \PhraseanetTestCase
self::$DI['record_2']
]);
$user_query = 'Gotainer';
$engine_query = '{text:"Gotainer"}'; // fake, real is really more complex
$queryText = 'azerty';
$queryAST = '<text:"azerty">'; // fake, real is really more complex
$queryCompiled = '{match:"azerty"}'; // fake, real is really more complex
$queryESLib = '{index:"test", match:{"azerty"}}'; // fake, real is really more complex
$duration = 1 / 3;
$offsetStart = 0;
$available = 25;
@@ -71,12 +99,30 @@ class SearchEngineResultTest extends \PhraseanetTestCase
$error = 'this is an error message';
$warning = 'this is a warning message';
$suggestions = new ArrayCollection([
new SearchEngineSuggestion($user_query, 'Richard', 22)
new SearchEngineSuggestion($queryText, 'Richard', 22)
]);
$propositions = new ArrayCollection();
$indexes = 'new-index';
$result = new SearchEngineResult($options, $results, $user_query, $engine_query, $duration, $offsetStart, $available, $total, $error, $warning, $suggestions, $propositions, $indexes);
$result = new SearchEngineResult(
$options,
$results,
$queryText, // the query as typed by the user
$queryAST,
$queryCompiled,
$queryESLib,
$duration,
$offsetStart,
$available,
$total,
$error,
$warning,
$suggestions,
$propositions,
$indexes
);
$this->assertEquals(1, $result->getCurrentPage(10));
$this->assertEquals(1, $result->getCurrentPage(25));