mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
Fix unit tests when running without phrasea2 extension
This commit is contained in:
@@ -41,6 +41,10 @@ class PhraseaEngine implements SearchEngineInterface
|
|||||||
*/
|
*/
|
||||||
public function __construct(Application $app)
|
public function __construct(Application $app)
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('phrasea2')) {
|
||||||
|
throw new RuntimeException('Phrasea2 is required to use Phrasea search engine.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ class ConsoleAPITest extends \PhraseanetTestCase
|
|||||||
*/
|
*/
|
||||||
public function testThatCommandsExitWithZero($console)
|
public function testThatCommandsExitWithZero($console)
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('phrasea2')) {
|
||||||
|
$this->markTestSkipped('Phrasea2 is required');
|
||||||
|
}
|
||||||
|
|
||||||
$process = new Process(__DIR__ . '/../../../../../bin/'.$console);
|
$process = new Process(__DIR__ . '/../../../../../bin/'.$console);
|
||||||
$process->run();
|
$process->run();
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class OverviewTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
public function testDatafilesRouteNotAuthenticatedIsOkInPublicFeed()
|
public function testDatafilesRouteNotAuthenticatedIsOkInPublicFeed()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
self::$DI['record_5']->move_to_collection(self::$DI['collection_no_access'], self::$DI['app']['phraseanet.appbox']);
|
self::$DI['record_5']->move_to_collection(self::$DI['collection_no_access'], self::$DI['app']['phraseanet.appbox']);
|
||||||
self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_5']->get_sbas_id() . '/' . self::$DI['record_5']->get_record_id() . '/preview/');
|
self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_5']->get_sbas_id() . '/' . self::$DI['record_5']->get_record_id() . '/preview/');
|
||||||
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
|
$this->assertEquals(200, self::$DI['client']->getResponse()->getStatusCode());
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class Sha256Test extends \PhraseanetTestCase
|
|||||||
{
|
{
|
||||||
$session = self::$DI['app']['EM']->find('Phraseanet:LazaretSession', 1);
|
$session = self::$DI['app']['EM']->find('Phraseanet:LazaretSession', 1);
|
||||||
|
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
self::$DI['app']['border-manager']->process($session, File::buildFromPathfile($this->media->getFile()->getPathname(), self::$DI['collection'], self::$DI['app']), null, Manager::FORCE_RECORD);
|
self::$DI['app']['border-manager']->process($session, File::buildFromPathfile($this->media->getFile()->getPathname(), self::$DI['collection'], self::$DI['app']), null, Manager::FORCE_RECORD);
|
||||||
|
|
||||||
$mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', ['getSha256'], [self::$DI['app'], $this->media, self::$DI['collection']]);
|
$mock = $this->getMock('\\Alchemy\\Phrasea\\Border\\File', ['getSha256'], [self::$DI['app'], $this->media, self::$DI['collection']]);
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ class ManagerTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$records[] = $record;
|
$records[] = $record;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']), $postProcessRecord));
|
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']), $postProcessRecord));
|
||||||
$shaChecker = new Sha256(self::$DI['app']);
|
$shaChecker = new Sha256(self::$DI['app']);
|
||||||
$this->object->registerChecker($shaChecker);
|
$this->object->registerChecker($shaChecker);
|
||||||
@@ -118,6 +119,7 @@ class ManagerTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$postProcessRecord = function ($record) use (&$records) {
|
$postProcessRecord = function ($record) use (&$records) {
|
||||||
$records[] = $record;
|
$records[] = $record;
|
||||||
};
|
};
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$this->assertEquals(Manager::LAZARET_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']), NULL, Manager::FORCE_LAZARET));
|
$this->assertEquals(Manager::LAZARET_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']), NULL, Manager::FORCE_LAZARET));
|
||||||
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']), $postProcessRecord));
|
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']), $postProcessRecord));
|
||||||
|
|
||||||
@@ -202,6 +204,7 @@ class ManagerTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
$file->addAttribute(new Status(self::$DI['app'], strrev($status)));
|
$file->addAttribute(new Status(self::$DI['app'], strrev($status)));
|
||||||
|
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, $file, $postProcessRecord, Manager::FORCE_RECORD));
|
$this->assertEquals(Manager::RECORD_CREATED, $this->object->process($this->session, $file, $postProcessRecord, Manager::FORCE_RECORD));
|
||||||
|
|
||||||
$record = current($records);
|
$record = current($records);
|
||||||
@@ -552,6 +555,7 @@ class ManagerTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$records[] = $record;
|
$records[] = $record;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']));
|
$visa = $this->object->getVisa(File::buildFromPathfile(self::$file1, self::$DI['collection'], self::$DI['app']));
|
||||||
|
|
||||||
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Visa', $visa);
|
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Visa', $visa);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class CheckConfigTest extends \PhraseanetTestCase
|
|||||||
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||||
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||||
|
|
||||||
|
self::$DI['cli']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$command = new CheckConfig('check:config');
|
$command = new CheckConfig('check:config');
|
||||||
$command->setContainer(self::$DI['cli']);
|
$command->setContainer(self::$DI['cli']);
|
||||||
$this->assertLessThan(2, $command->execute($input, $output));
|
$this->assertLessThan(2, $command->execute($input, $output));
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class AdminDashboardTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
public function testRouteDashboard()
|
public function testRouteDashboard()
|
||||||
{
|
{
|
||||||
$this->setAdmin(true);
|
$this->setAdmin(true);
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
self::$DI['app']['phraseanet.configuration-tester']->getRequirements();
|
self::$DI['app']['phraseanet.configuration-tester']->getRequirements();
|
||||||
self::$DI['client']->request('GET', '/admin/dashboard/', [
|
self::$DI['client']->request('GET', '/admin/dashboard/', [
|
||||||
'flush_cache' => 'ok',
|
'flush_cache' => 'ok',
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Controller\Admin;
|
namespace Alchemy\Tests\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\SearchEngine\Elastic\ElasticSearchEngine;
|
||||||
use Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine;
|
use Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine;
|
||||||
use Alchemy\Phrasea\SearchEngine\SphinxSearch\SphinxSearchEngine;
|
use Alchemy\Phrasea\SearchEngine\SphinxSearch\SphinxSearchEngine;
|
||||||
|
|
||||||
@@ -36,10 +37,16 @@ class SearchEngineTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
$app = $this->loadApp();
|
$app = $this->loadApp();
|
||||||
|
|
||||||
return [
|
$SE = [[new SphinxSearchEngine($app, 'localhost', 9306, 'localhost', 9308)]];
|
||||||
[new PhraseaEngine($app)],
|
|
||||||
[new SphinxSearchEngine($app, 'localhost', 9306, 'localhost', 9308)],
|
if (extension_loaded('phrasea2')) {
|
||||||
];
|
$SE[] = [new PhraseaEngine($app)];
|
||||||
|
}
|
||||||
|
if (false !== $ret = @file_get_contents('http://localhost:9200')) {
|
||||||
|
$SE[] = [ElasticSearchEngine::create($app)];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $SE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -469,6 +469,7 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
if (null === self::$adminToken) {
|
if (null === self::$adminToken) {
|
||||||
$this->markTestSkipped('there is no user with admin rights');
|
$this->markTestSkipped('there is no user with admin rights');
|
||||||
}
|
}
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
|
|
||||||
$this->setToken(self::$adminToken);
|
$this->setToken(self::$adminToken);
|
||||||
|
|
||||||
@@ -741,6 +742,10 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
|
|
||||||
public function testSearchRoute()
|
public function testSearchRoute()
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('phrasea2')) {
|
||||||
|
$this->markTestSkipped('Phrasea2 extension is required for this test');
|
||||||
|
}
|
||||||
|
|
||||||
$this->setToken(self::$token);
|
$this->setToken(self::$token);
|
||||||
self::$DI['client']->request('POST', '/api/v1/search/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]);
|
self::$DI['client']->request('POST', '/api/v1/search/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]);
|
||||||
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
||||||
@@ -770,6 +775,10 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
|
|
||||||
public function testSearchRouteWithStories()
|
public function testSearchRouteWithStories()
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('phrasea2')) {
|
||||||
|
$this->markTestSkipped('Phrasea2 extension is required for this test');
|
||||||
|
}
|
||||||
|
|
||||||
$this->setToken(self::$token);
|
$this->setToken(self::$token);
|
||||||
|
|
||||||
self::$DI['record_story_1'];
|
self::$DI['record_story_1'];
|
||||||
@@ -802,6 +811,10 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
|
|
||||||
public function testRecordsSearchRoute()
|
public function testRecordsSearchRoute()
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('phrasea2')) {
|
||||||
|
$this->markTestSkipped('Phrasea2 extension is required for this test');
|
||||||
|
}
|
||||||
|
|
||||||
$this->setToken(self::$token);
|
$this->setToken(self::$token);
|
||||||
self::$DI['client']->request('POST', '/api/v1/records/search/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]);
|
self::$DI['client']->request('POST', '/api/v1/records/search/', $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]);
|
||||||
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
|
||||||
@@ -855,6 +868,7 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
{
|
{
|
||||||
$this->setToken(self::$token);
|
$this->setToken(self::$token);
|
||||||
|
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$this->injectMetadatas(self::$DI['record_1']);
|
$this->injectMetadatas(self::$DI['record_1']);
|
||||||
|
|
||||||
$route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/caption/';
|
$route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/caption/';
|
||||||
@@ -1029,6 +1043,7 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
|
|
||||||
public function testRecordsSetMetadatas()
|
public function testRecordsSetMetadatas()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$this->setToken(self::$token);
|
$this->setToken(self::$token);
|
||||||
|
|
||||||
$record = self::$DI['record_1'];
|
$record = self::$DI['record_1'];
|
||||||
@@ -1086,6 +1101,7 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
|
|
||||||
public function testRecordsSetStatus()
|
public function testRecordsSetStatus()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$this->setToken(self::$token);
|
$this->setToken(self::$token);
|
||||||
|
|
||||||
$route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/setstatus/';
|
$route = '/api/v1/records/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/setstatus/';
|
||||||
@@ -1144,6 +1160,7 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
|
|
||||||
public function testMoveRecordToCollection()
|
public function testMoveRecordToCollection()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/test001.jpg'), self::$DI['collection']);
|
$file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../../../../../files/test001.jpg'), self::$DI['collection']);
|
||||||
$record = \record_adapter::createFromFile($file, self::$DI['app']);
|
$record = \record_adapter::createFromFile($file, self::$DI['app']);
|
||||||
|
|
||||||
@@ -1344,6 +1361,7 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
|
|
||||||
public function testAddRecord()
|
public function testAddRecord()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$this->setToken(self::$token);
|
$this->setToken(self::$token);
|
||||||
$route = '/api/v1/records/add/';
|
$route = '/api/v1/records/add/';
|
||||||
|
|
||||||
@@ -1363,6 +1381,7 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
|
|||||||
|
|
||||||
public function testAddRecordForceRecord()
|
public function testAddRecordForceRecord()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$this->setToken(self::$token);
|
$this->setToken(self::$token);
|
||||||
$route = '/api/v1/records/add/';
|
$route = '/api/v1/records/add/';
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetClient()
|
public function testGetClient()
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('phrasea2')) {
|
||||||
|
$this->markTestSkipped('Phrasea2 is required for this test');
|
||||||
|
}
|
||||||
|
|
||||||
$this->authenticate(self::$DI['app']);
|
$this->authenticate(self::$DI['app']);
|
||||||
self::$DI['client']->request("GET", "/client/");
|
self::$DI['client']->request("GET", "/client/");
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||||
@@ -61,6 +65,10 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testExecuteQuery()
|
public function testExecuteQuery()
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('phrasea2')) {
|
||||||
|
$this->markTestSkipped('Phrasea2 is required for this test');
|
||||||
|
}
|
||||||
|
|
||||||
$queryParameters = [];
|
$queryParameters = [];
|
||||||
$queryParameters["mod"] = self::$DI['app']['settings']->getUserSetting(self::$DI['user'], 'client_view', '3X6');
|
$queryParameters["mod"] = self::$DI['app']['settings']->getUserSetting(self::$DI['user'], 'client_view', '3X6');
|
||||||
$queryParameters["bas"] = array_keys(self::$DI['app']['acl']->get(self::$DI['user'])->get_granted_base());
|
$queryParameters["bas"] = array_keys(self::$DI['app']['acl']->get(self::$DI['user'])->get_granted_base());
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ class LazaretTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testAddElement()
|
public function testAddElement()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$originalEm = self::$DI['app']['EM'];
|
$originalEm = self::$DI['app']['EM'];
|
||||||
$em = $this->createEntityManagerMock();
|
$em = $this->createEntityManagerMock();
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ class QueryTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testQuery()
|
public function testQuery()
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('phrasea2')) {
|
||||||
|
$this->markTestSkipped('Phrasea2 is required for this test');
|
||||||
|
}
|
||||||
$route = '/prod/query/';
|
$route = '/prod/query/';
|
||||||
|
|
||||||
self::$DI['client']->request('POST', $route);
|
self::$DI['client']->request('POST', $route);
|
||||||
@@ -30,6 +33,9 @@ class QueryTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testQueryAnswerTrain()
|
public function testQueryAnswerTrain()
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('phrasea2')) {
|
||||||
|
$this->markTestSkipped('Phrasea2 is required for this test');
|
||||||
|
}
|
||||||
$this->authenticate(self::$DI['app']);
|
$this->authenticate(self::$DI['app']);
|
||||||
self::$DI['record_2'];
|
self::$DI['record_2'];
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,9 @@ class RecordsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetRecordDetailResult()
|
public function testGetRecordDetailResult()
|
||||||
{
|
{
|
||||||
|
if (!extension_loaded('phrasea2')) {
|
||||||
|
$this->markTestSkipped('Phrasea2 is required for this test');
|
||||||
|
}
|
||||||
$this->authenticate(self::$DI['app']);
|
$this->authenticate(self::$DI['app']);
|
||||||
self::$DI['record_1'];
|
self::$DI['record_1'];
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class RootTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRouteSlash()
|
public function testRouteSlash()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
self::$DI['client']->request('GET', '/prod/');
|
self::$DI['client']->request('GET', '/prod/');
|
||||||
|
|
||||||
$response = self::$DI['client']->getResponse();
|
$response = self::$DI['client']->getResponse();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class StoryTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
{
|
{
|
||||||
public function testRootPost()
|
public function testRootPost()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$route = "/prod/story/";
|
$route = "/prod/story/";
|
||||||
|
|
||||||
$collections = self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser())
|
$collections = self::$DI['app']['acl']->get(self::$DI['app']['authentication']->getUser())
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class ToolsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
|
|
||||||
public function testRouteChangeDoc()
|
public function testRouteChangeDoc()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$record = self::$DI['record_1'];
|
$record = self::$DI['record_1'];
|
||||||
|
|
||||||
$crawler = self::$DI['client']->request('POST', '/prod/tools/hddoc/', [
|
$crawler = self::$DI['client']->request('POST', '/prod/tools/hddoc/', [
|
||||||
|
|||||||
@@ -293,6 +293,7 @@ class UploadTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testUploadForceRecord()
|
public function testUploadForceRecord()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$params = [
|
$params = [
|
||||||
'base_id' => self::$DI['collection']->get_base_id(),
|
'base_id' => self::$DI['collection']->get_base_id(),
|
||||||
'forceAction' => Manager::FORCE_RECORD,
|
'forceAction' => Manager::FORCE_RECORD,
|
||||||
@@ -328,6 +329,7 @@ class UploadTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testUploadRecordStatus()
|
public function testUploadRecordStatus()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
$params = [
|
$params = [
|
||||||
'base_id' => self::$DI['collection']->get_base_id(),
|
'base_id' => self::$DI['collection']->get_base_id(),
|
||||||
'forceAction' => Manager::FORCE_RECORD,
|
'forceAction' => Manager::FORCE_RECORD,
|
||||||
|
|||||||
@@ -1111,6 +1111,8 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testGetLogout()
|
public function testGetLogout()
|
||||||
{
|
{
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
|
|
||||||
$this->assertTrue(self::$DI['app']['authentication']->isAuthenticated());
|
$this->assertTrue(self::$DI['app']['authentication']->isAuthenticated());
|
||||||
self::$DI['client']->request('GET', '/login/logout/', ['app' => 'prod']);
|
self::$DI['client']->request('GET', '/login/logout/', ['app' => 'prod']);
|
||||||
$this->assertFalse(self::$DI['app']['authentication']->isAuthenticated());
|
$this->assertFalse(self::$DI['app']['authentication']->isAuthenticated());
|
||||||
|
|||||||
@@ -7,6 +7,14 @@ namespace Alchemy\Tests\Phrasea\Core\Provider;
|
|||||||
*/
|
*/
|
||||||
class SearchEngineServiceProviderTest extends ServiceProviderTestCase
|
class SearchEngineServiceProviderTest extends ServiceProviderTestCase
|
||||||
{
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
if (!extension_loaded('phrasea2')) {
|
||||||
|
$this->markTestSkipped('Phrasea2 is required for this test');
|
||||||
|
}
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
public function provideServiceDescription()
|
public function provideServiceDescription()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ class ElasticSearchEngineTest extends SearchEngineAbstractTest
|
|||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
|
if (false === @file_get_contents('http://localhost:9200')) {
|
||||||
|
$this->markTestSkipped('Unable to connect to elasticsearch.');
|
||||||
|
}
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$es = ElasticSearchEngine::create(self::$DI['app']);
|
$es = ElasticSearchEngine::create(self::$DI['app']);
|
||||||
|
|||||||
@@ -7,6 +7,15 @@ use Alchemy\Phrasea\SearchEngine\Phrasea\ConfigurationPanel;
|
|||||||
|
|
||||||
class PhraseaConfigurationPanelTest extends ConfigurationPanelAbstractTest
|
class PhraseaConfigurationPanelTest extends ConfigurationPanelAbstractTest
|
||||||
{
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
if (!extension_loaded('phrasea2')) {
|
||||||
|
$this->markTestSkipped('Phrasea extension is not loaded');
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
public function getPanel()
|
public function getPanel()
|
||||||
{
|
{
|
||||||
return new ConfigurationPanel(new PhraseaEngine(self::$DI['app']), self::$DI['app']['conf']);
|
return new ConfigurationPanel(new PhraseaEngine(self::$DI['app']), self::$DI['app']['conf']);
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ class PhraseaEngineTest extends SearchEngineAbstractTest
|
|||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
|
||||||
if (!extension_loaded('phrasea2')) {
|
if (!extension_loaded('phrasea2')) {
|
||||||
$this->markTestSkipped('Phrasea extension is not loaded');
|
$this->markTestSkipped('Phrasea extension is not loaded');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initialize()
|
public function initialize()
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ abstract class SearchEngineAbstractTest extends \PhraseanetAuthenticatedTestCase
|
|||||||
$this->markTestSkipped('Unable to initialize search Engine');
|
$this->markTestSkipped('Unable to initialize search Engine');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self::$DI['app']['phraseanet.SE'] = self::$searchEngine;
|
||||||
|
self::$DI['app']['phraseanet.SE.subscriber'] = self::$searchEngine->createSubscriber(self::$DI['app']);
|
||||||
|
|
||||||
$options = new SearchEngineOptions();
|
$options = new SearchEngineOptions();
|
||||||
$options->onCollections($databox->get_collections());
|
$options->onCollections($databox->get_collections());
|
||||||
|
|
||||||
@@ -268,11 +271,16 @@ abstract class SearchEngineAbstractTest extends \PhraseanetAuthenticatedTestCase
|
|||||||
$record = self::$DI['record_2'];
|
$record = self::$DI['record_2'];
|
||||||
$query_string = 'boomboklot' . $record->get_record_id() . 'defaultNotIndexed';
|
$query_string = 'boomboklot' . $record->get_record_id() . 'defaultNotIndexed';
|
||||||
|
|
||||||
$this->editRecord($query_string, $record);
|
|
||||||
|
|
||||||
self::$searchEngine->resetCache();
|
self::$searchEngine->resetCache();
|
||||||
$results = self::$searchEngine->query($query_string, 0, 1, $this->options);
|
$results = self::$searchEngine->query($query_string, 0, 1, $this->options);
|
||||||
$this->assertEquals(0, $results->getTotal());
|
$this->assertEquals(0, $results->getTotal());
|
||||||
|
|
||||||
|
$this->editRecord($query_string, $record);
|
||||||
|
|
||||||
|
self::$searchEngine->resetCache();
|
||||||
|
$this->updateIndex();
|
||||||
|
$results = self::$searchEngine->query($query_string, 0, 1, $this->options);
|
||||||
|
$this->assertEquals(1, $results->getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddRecord()
|
public function testAddRecord()
|
||||||
|
|||||||
@@ -149,7 +149,10 @@ class ConfigurationTesterTest extends AbstractSetupTester
|
|||||||
|
|
||||||
public function testGetRequirements()
|
public function testGetRequirements()
|
||||||
{
|
{
|
||||||
foreach ($this->getTester()->getRequirements() as $requirements) {
|
$app = new Application('test');
|
||||||
|
$app['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
|
|
||||||
|
foreach ($this->getTester($app)->getRequirements() as $requirements) {
|
||||||
$this->assertInstanceOf('Alchemy\Phrasea\Setup\RequirementCollectionInterface', $requirements);
|
$this->assertInstanceOf('Alchemy\Phrasea\Setup\RequirementCollectionInterface', $requirements);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ namespace Alchemy\Tests\Phrasea\Setup\Probe;
|
|||||||
|
|
||||||
class SearchEngineProbeTest extends ProbeTestCase
|
class SearchEngineProbeTest extends ProbeTestCase
|
||||||
{
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
|
}
|
||||||
|
|
||||||
protected function getClassName()
|
protected function getClassName()
|
||||||
{
|
{
|
||||||
return 'Alchemy\Phrasea\Setup\Probe\SearchEngineProbe';
|
return 'Alchemy\Phrasea\Setup\Probe\SearchEngineProbe';
|
||||||
|
|||||||
@@ -670,4 +670,23 @@ abstract class PhraseanetTestCase extends WebTestCase
|
|||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function createSearchEngineMock()
|
||||||
|
{
|
||||||
|
$mock = $this->getMock('Alchemy\Phrasea\SearchEngine\SearchEngineInterface');
|
||||||
|
$mock->expects($this->any())
|
||||||
|
->method('createSubscriber')
|
||||||
|
->will($this->returnValue($this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface')));
|
||||||
|
$mock->expects($this->any())
|
||||||
|
->method('getConfigurationPanel')
|
||||||
|
->will($this->returnValue($this->getMock('Alchemy\Phrasea\SearchEngine\ConfigurationPanelInterface')));
|
||||||
|
$mock->expects($this->any())
|
||||||
|
->method('getStatus')
|
||||||
|
->will($this->returnValue([]));
|
||||||
|
$mock->staticExpects($this->any())
|
||||||
|
->method('createSubscriber')
|
||||||
|
->will($this->returnValue($this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface')));
|
||||||
|
|
||||||
|
return $mock;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -393,6 +393,7 @@ class databox_fieldTest extends \PhraseanetTestCase
|
|||||||
{
|
{
|
||||||
$AddedValue = 'scalar value';
|
$AddedValue = 'scalar value';
|
||||||
|
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
self::$DI['record_1']->set_metadatas([
|
self::$DI['record_1']->set_metadatas([
|
||||||
[
|
[
|
||||||
'meta_id' => null,
|
'meta_id' => null,
|
||||||
|
|||||||
@@ -339,6 +339,7 @@ class record_adapterTest extends \PhraseanetAuthenticatedTestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self::$DI['app']['phraseanet.SE'] = $this->createSearchEngineMock();
|
||||||
self::$DI['record_1']->set_metadatas($metadatas, true);
|
self::$DI['record_1']->set_metadatas($metadatas, true);
|
||||||
|
|
||||||
$caption = self::$DI['record_1']->get_caption();
|
$caption = self::$DI['record_1']->get_caption();
|
||||||
|
|||||||
Reference in New Issue
Block a user