mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Merge branch 'master' of https://github.com/alchemy-fr/Phraseanet into PHRAS-2741-worker-service-part1
This commit is contained in:
@@ -10,6 +10,26 @@ use Alchemy\Phrasea\Command\Plugin\AddPlugin;
|
||||
*/
|
||||
class AddPluginTest extends PluginCommandTestCase
|
||||
{
|
||||
private $bkp = null;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->bkp = self::$DI['app']['conf']->get('plugins');
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
if(is_null($this->bkp)) {
|
||||
self::$DI['app']['conf']->remove('plugins');
|
||||
}
|
||||
else {
|
||||
self::$DI['app']['conf']->set('plugins', $this->bkp);
|
||||
}
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
||||
public function testExecute()
|
||||
{
|
||||
$source = 'TestPlugin';
|
||||
|
@@ -22,6 +22,8 @@ class DisablePluginTest extends PluginCommandTestCase
|
||||
->with($this->equalTo('name'))
|
||||
->will($this->returnValue('test-plugin'));
|
||||
|
||||
$bkp = self::$DI['cli']['conf']->get('plugins');
|
||||
|
||||
self::$DI['cli']['conf']->set(['plugins', 'test-plugin', 'enabled'], $initial);
|
||||
|
||||
$command = new DisablePlugin();
|
||||
@@ -29,6 +31,13 @@ class DisablePluginTest extends PluginCommandTestCase
|
||||
|
||||
$this->assertSame(0, $command->execute($input, $output));
|
||||
$this->assertFalse(self::$DI['cli']['conf']->get(['plugins', 'test-plugin', 'enabled']));
|
||||
|
||||
if(is_null($bkp)) {
|
||||
self::$DI['cli']['conf']->remove('plugins');
|
||||
}
|
||||
else {
|
||||
self::$DI['cli']['conf']->set('plugins', $bkp);
|
||||
}
|
||||
}
|
||||
|
||||
public function provideVariousInitialConfs()
|
||||
|
@@ -22,6 +22,8 @@ class EnablePluginTest extends PluginCommandTestCase
|
||||
->with($this->equalTo('name'))
|
||||
->will($this->returnValue('test-plugin'));
|
||||
|
||||
$bkp = self::$DI['cli']['conf']->get('plugins');
|
||||
|
||||
self::$DI['cli']['conf']->set(['plugins', 'test-plugin', 'enabled'], $initial);
|
||||
|
||||
$command = new EnablePlugin();
|
||||
@@ -29,6 +31,13 @@ class EnablePluginTest extends PluginCommandTestCase
|
||||
|
||||
$this->assertSame(0, $command->execute($input, $output));
|
||||
$this->assertTrue(self::$DI['cli']['conf']->get(['plugins', 'test-plugin', 'enabled']));
|
||||
|
||||
if(is_null($bkp)) {
|
||||
self::$DI['cli']['conf']->remove('plugins');
|
||||
}
|
||||
else {
|
||||
self::$DI['cli']['conf']->set('plugins', $bkp);
|
||||
}
|
||||
}
|
||||
|
||||
public function provideVariousInitialConfs()
|
||||
|
@@ -12,6 +12,21 @@ use Alchemy\Phrasea\Core\Configuration\StructureTemplate;
|
||||
*/
|
||||
class InstallTest extends \PhraseanetTestCase
|
||||
{
|
||||
private $bkp = null;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->bkp = self::$DI['app']['conf']->get('main');
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
self::$DI['app']['conf']->set('main', $this->bkp);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
||||
public function testRunWithoutProblems()
|
||||
{
|
||||
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||
@@ -78,9 +93,12 @@ class InstallTest extends \PhraseanetTestCase
|
||||
case 'db-password':
|
||||
return $infoDb['database']['password'];
|
||||
break;
|
||||
case 'yes':
|
||||
return true;
|
||||
break;
|
||||
case 'es-host':
|
||||
return 'localhost';
|
||||
case 'es-port':
|
||||
return 9200;
|
||||
case 'es-index':
|
||||
return 'phrasea_test';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
@@ -229,6 +229,9 @@ class FieldsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
'dces-element' => null,
|
||||
'vocabulary-type' => 'User',
|
||||
'vocabulary-restricted' => true,
|
||||
'gui_editable' => true,
|
||||
'gui_visible' => true,
|
||||
'generate_cterms' => true,
|
||||
]);
|
||||
|
||||
$response = $this->request("POST", sprintf("/admin/fields/%d/fields", $databox->get_sbas_id()), [], [], $body);
|
||||
|
@@ -1281,7 +1281,7 @@ class ApiJsonTest extends ApiTestCase
|
||||
|
||||
$tochange = [];
|
||||
foreach ($statusStructure as $n => $datas) {
|
||||
$tochange[$n] = substr($record_status, ($n - 1), 1) == '0' ? '1' : '0';
|
||||
$tochange[$n] = substr($record_status, $n, 1) == '0' ? '1' : '0';
|
||||
}
|
||||
|
||||
$this->evaluateMethodNotAllowedRoute($route, ['GET', 'PUT', 'DELETE']);
|
||||
@@ -1305,7 +1305,8 @@ class ApiJsonTest extends ApiTestCase
|
||||
// test record_status in string
|
||||
$record_status_expected = $record_status;
|
||||
|
||||
$pos = strpos($record_status, '1');
|
||||
$bitToChange = [];
|
||||
$pos = strpos($record_status, '1', 4);
|
||||
$bitToChange[$pos] = '1';
|
||||
|
||||
$response = $this->request('POST', $route, $this->getParameters(['status' => $bitToChange]), ['HTTP_Accept' => $this->getAcceptMimeType()]);
|
||||
|
@@ -132,9 +132,11 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
$app = $this->getApplication();
|
||||
|
||||
$bkp = $app['conf']->get('registry');
|
||||
|
||||
if (!$app['conf']->get(['registry', 'ftp', 'ftp-enabled'])) {
|
||||
$app['conf']->set(['registry', 'ftp', 'ftp-enabled'], true);
|
||||
self::$GV_activeFTP = true;
|
||||
self::$GV_activeFTP = true;
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
@@ -158,6 +160,8 @@ class ExportTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertArrayHasKey('message', $datas);
|
||||
$this->assertTrue($datas['success']);
|
||||
unset($response, $datas);
|
||||
|
||||
$app['conf']->set('registry', $bkp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2017,6 +2017,9 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
$app = $this->getApplication();
|
||||
$this->logout($app);
|
||||
|
||||
$bkp = $app['phraseanet.configuration']['session'];
|
||||
|
||||
$app['phraseanet.configuration']['session'] = [
|
||||
'idle' => 10,
|
||||
'lifetime' => 60475,
|
||||
@@ -2027,12 +2030,17 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||
$this->assertEquals('hidden', $crawler->filter('input[name="remember-me"]')->attr('type'));
|
||||
|
||||
$app['phraseanet.configuration']['session'] = $bkp;
|
||||
}
|
||||
|
||||
public function testLoginPageWithNoIdleSessionTime()
|
||||
{
|
||||
$app = $this->getApplication();
|
||||
$this->logout($app);
|
||||
|
||||
$bkp = $app['phraseanet.configuration']['session'];
|
||||
|
||||
$app['phraseanet.configuration']['session'] = [
|
||||
'idle' => 0,
|
||||
'lifetime' => 60475,
|
||||
@@ -2043,6 +2051,8 @@ class LoginTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||
$this->assertEquals('checkbox', $crawler->filter('input[name="remember-me"]')->attr('type'));
|
||||
|
||||
$app['phraseanet.configuration']['session'] = $bkp;
|
||||
}
|
||||
|
||||
private function addUsrAuthDoctrineEntitySupport($id, $out, $participants = false)
|
||||
|
@@ -81,16 +81,26 @@ class PluginServiceProviderTest extends ServiceProviderTestCase
|
||||
}
|
||||
|
||||
$app = self::$DI['cli'];
|
||||
$app['conf']->set(['binaries', 'php_binary'], null);
|
||||
|
||||
$bkp = $app['conf']->get(['main', 'binaries']);
|
||||
|
||||
$app['conf']->set(['main', 'binaries', 'php_binary'], null);
|
||||
$app->register(new PluginServiceProvider());
|
||||
$this->assertInstanceOf('Alchemy\Phrasea\Plugin\Management\ComposerInstaller', $app['plugins.composer-installer']);
|
||||
|
||||
$app['conf']->set(['main', 'binaries'], $bkp);
|
||||
}
|
||||
|
||||
public function testInstallerCanDetectPhpConf()
|
||||
{
|
||||
$app = self::$DI['cli'];
|
||||
$app['conf']->set(['binaries', 'php_binary'], null);
|
||||
|
||||
$bkp = $app['conf']->get(['main', 'binaries']);
|
||||
|
||||
$app['conf']->set(['main', 'binaries', 'php_binary'], null);
|
||||
$app->register(new PluginServiceProvider());
|
||||
$this->assertInstanceOf('Alchemy\Phrasea\Plugin\Management\ComposerInstaller', $app['plugins.composer-installer']);
|
||||
|
||||
$app['conf']->set(['main', 'binaries'], $bkp);
|
||||
}
|
||||
}
|
||||
|
@@ -11,33 +11,33 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
*/
|
||||
class DisplaySettingServiceTest extends \PhraseanetTestCase
|
||||
{
|
||||
private static $userSettings;
|
||||
private static $appSettings;
|
||||
private $userSettings = false;
|
||||
private $appSettings = false;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (null === self::$userSettings) {
|
||||
self::$userSettings = self::$DI['app']['conf']->get(['user-settings'], []);
|
||||
}
|
||||
|
||||
if (null === self::$appSettings) {
|
||||
self::$appSettings = self::$DI['app']['conf']->get(['registry'], []);
|
||||
}
|
||||
$this->userSettings = self::$DI['app']['conf']->get(['user-settings']);
|
||||
$this->appSettings = self::$DI['app']['conf']->get(['registry']);
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
public function tearDown()
|
||||
{
|
||||
if (null !== self::$userSettings) {
|
||||
self::$DI['app']['conf']->set('user-settings', self::$userSettings);
|
||||
if (is_null($this->userSettings)) {
|
||||
self::$DI['app']['conf']->remove('user-settings');
|
||||
}
|
||||
else {
|
||||
self::$DI['app']['conf']->set('user-settings', $this->userSettings);
|
||||
}
|
||||
|
||||
if (null !== self::$appSettings) {
|
||||
self::$DI['app']['conf']->set('registry', self::$appSettings);
|
||||
if (is_null($this->appSettings)) {
|
||||
self::$DI['app']['conf']->remove('registry');
|
||||
}
|
||||
else {
|
||||
self::$DI['app']['conf']->set('registry', $this->appSettings);
|
||||
}
|
||||
|
||||
self::$userSettings = self::$appSettings = null;
|
||||
parent::tearDownAfterClass();
|
||||
}
|
||||
|
||||
|
@@ -12,8 +12,22 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class DebuggerSubscriberTest extends \PhraseanetTestCase
|
||||
{
|
||||
private $bkp = null;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->bkp = self::$DI['app']['conf']->get('debugger');
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
if(is_null($this->bkp)) {
|
||||
self::$DI['app']['conf']->remove('debugger');
|
||||
}
|
||||
else {
|
||||
self::$DI['app']['conf']->set('debugger', $this->bkp);
|
||||
}
|
||||
if (is_file(__DIR__ . '/Fixtures/configuration-debugger.php')) {
|
||||
unlink(__DIR__ . '/Fixtures/configuration-debugger.php');
|
||||
}
|
||||
|
@@ -19,6 +19,9 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
$app = new Application(Application::ENV_TEST);
|
||||
$app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app));
|
||||
|
||||
$bkp = $app['phraseanet.configuration']['session'];
|
||||
|
||||
$app['phraseanet.configuration']['session'] = [
|
||||
'idle' => 0,
|
||||
'lifetime' => 60475,
|
||||
@@ -39,12 +42,17 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session'));
|
||||
$this->assertNotNUll($client->getResponse()->headers->get('location'));
|
||||
$this->assertRegExp('#/login\?redirect=..(?:%2F|/)prod#', $client->getResponse()->headers->get('location'));
|
||||
|
||||
$app['phraseanet.configuration']['session'] = $bkp;
|
||||
}
|
||||
|
||||
public function testEndSessionXmlXhttpRequest()
|
||||
{
|
||||
$app = new Application(Application::ENV_TEST);
|
||||
$app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app));
|
||||
|
||||
$bkp = $app['phraseanet.configuration']['session'];
|
||||
|
||||
$app['phraseanet.configuration']['session'] = [
|
||||
'idle' => 0,
|
||||
'lifetime' => 60475,
|
||||
@@ -67,6 +75,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
$this->assertTrue($client->getResponse()->isClientError());
|
||||
$this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session'));
|
||||
|
||||
$app['phraseanet.configuration']['session'] = $bkp;
|
||||
}
|
||||
|
||||
public function testEndSessionAuthenticated()
|
||||
@@ -85,6 +95,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$app['orm.em']->expects($this->exactly(4))->method('persist')->will($this->returnValue(null));
|
||||
$app['orm.em']->expects($this->exactly(2))->method('flush')->will($this->returnValue(null));
|
||||
|
||||
$bkp = $app['phraseanet.configuration']['session'];
|
||||
|
||||
$app['phraseanet.configuration']['session'] = [
|
||||
'idle' => 0,
|
||||
'lifetime' => 60475,
|
||||
@@ -101,6 +113,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$client->request('GET', '/prod');
|
||||
|
||||
$this->assertTrue($client->getResponse()->isOK());
|
||||
|
||||
$app['phraseanet.configuration']['session'] = $bkp;
|
||||
}
|
||||
|
||||
public function testEndSessionAuthenticatedWithOutdatedIdle()
|
||||
@@ -120,6 +134,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$app['orm.em']->expects($this->any())->method('persist')->will($this->returnValue(null));
|
||||
$app['orm.em']->expects($this->any())->method('flush')->will($this->returnValue(null));
|
||||
|
||||
$bkp = $app['phraseanet.configuration']['session'];
|
||||
|
||||
$app['phraseanet.configuration']['session'] = [
|
||||
'idle' => 10,
|
||||
'lifetime' => 60475,
|
||||
@@ -139,6 +155,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session'));
|
||||
$this->assertNotNUll($client->getResponse()->headers->get('location'));
|
||||
$this->assertRegExp('#/login\?redirect=..(?:%2F|/)prod#', $client->getResponse()->headers->get('location'));
|
||||
|
||||
$app['phraseanet.configuration']['session'] = $bkp;
|
||||
}
|
||||
|
||||
public function testEndSessionAuthenticatedWithOutdatedIdleXmlHttpRequest()
|
||||
@@ -158,6 +176,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$app['orm.em']->expects($this->any())->method('persist')->will($this->returnValue(null));
|
||||
$app['orm.em']->expects($this->any())->method('flush')->will($this->returnValue(null));
|
||||
|
||||
$bkp = $app['phraseanet.configuration']['session'];
|
||||
|
||||
$app['phraseanet.configuration']['session'] = [
|
||||
'idle' => 10,
|
||||
'lifetime' => 60475,
|
||||
@@ -178,6 +198,8 @@ class SessionManagerSubscriberTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
|
||||
$this->assertTrue($client->getResponse()->isClientError());
|
||||
$this->assertNotNUll($client->getResponse()->headers->get('x-phraseanet-end-session'));
|
||||
|
||||
$app['phraseanet.configuration']['session'] = $bkp;
|
||||
}
|
||||
|
||||
public function testUndefinedModule()
|
||||
|
@@ -95,6 +95,8 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase
|
||||
{
|
||||
$app = $this->loadApp();
|
||||
|
||||
$bkp = $app['conf']->get('authentication');
|
||||
|
||||
$app['conf']->set(['authentication', 'captcha', 'trials-before-display'], 42);
|
||||
|
||||
//$app['orm.em'] = $this->createEntityManagerMock();
|
||||
@@ -102,14 +104,21 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase
|
||||
|
||||
$manager = $app['auth.native.failure-manager'];
|
||||
$this->assertEquals(42, $manager->getTrials());
|
||||
|
||||
$app['conf']->set('authentication', $bkp);
|
||||
}
|
||||
|
||||
public function testFailureAccountCreator()
|
||||
{
|
||||
$app = $this->getApplication();
|
||||
|
||||
$bkp = $app['conf']->get('authentication');
|
||||
|
||||
$app->register(new ConfigurationServiceProvider());
|
||||
$app['conf']->set(['authentication', 'auto-create'], ['templates' => []]);
|
||||
$app['authentication.providers.account-creator'];
|
||||
|
||||
$app['conf']->set('authentication', $bkp);
|
||||
}
|
||||
|
||||
public function testAuthNativeWithCaptchaEnabled()
|
||||
@@ -121,6 +130,8 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase
|
||||
$app->register(new RepositoriesServiceProvider());
|
||||
$app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox'];
|
||||
|
||||
$bkp = $app['conf']->get('authentication');
|
||||
|
||||
$app['conf']->set(['authentication', 'captcha'], ['enabled' => true]);
|
||||
|
||||
$app['orm.em'] = $this->createEntityManagerMock();
|
||||
@@ -131,6 +142,8 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase
|
||||
$app['recaptcha'] = $this->createReCaptchaMock();
|
||||
|
||||
$this->assertInstanceOf(FailureHandledNativeAuthentication::class, $app['auth.native']);
|
||||
|
||||
$app['conf']->set('authentication', $bkp);
|
||||
}
|
||||
|
||||
public function testAuthNativeWithCaptchaDisabled()
|
||||
@@ -141,6 +154,8 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase
|
||||
$app->register(new ConfigurationServiceProvider());
|
||||
$app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox'];
|
||||
|
||||
$bkp = $app['conf']->get('authentication');
|
||||
|
||||
$app['conf']->set(['authentication', 'captcha'], ['enabled' => false]);
|
||||
|
||||
$app['orm.em'] = $this->createEntityManagerMock();
|
||||
@@ -148,6 +163,8 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase
|
||||
$app['recaptcha'] = $this->createReCaptchaMock();
|
||||
|
||||
$this->assertInstanceOf(NativeAuthentication::class, $app['auth.native']);
|
||||
|
||||
$app['conf']->set('authentication', $bkp);
|
||||
}
|
||||
|
||||
public function testAccountCreator()
|
||||
@@ -156,6 +173,8 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase
|
||||
$template1 = $user = $app['manipulator.user']->createTemplate('template1', self::$DI['user']);
|
||||
$template2 = $user = $app['manipulator.user']->createTemplate('template2', self::$DI['user']);
|
||||
|
||||
$bkp = $app['conf']->get('authentication');
|
||||
|
||||
$app['conf']->set(['authentication', 'auto-create'], ['templates' => [$template1->getId(), $template2->getId()]]);
|
||||
|
||||
$this->assertEquals([$template1->getLogin(), $template2->getLogin()], array_map(function (User $user) {
|
||||
@@ -164,6 +183,8 @@ class AuthenticationManagerServiceProviderTest extends ServiceProviderTestCase
|
||||
|
||||
$this->removeUser($app, $template1);
|
||||
$this->removeUser($app, $template2);
|
||||
|
||||
$app['conf']->set('authentication', $bkp);
|
||||
}
|
||||
|
||||
private function createUserRepositoryMock()
|
||||
|
@@ -38,10 +38,20 @@ class BorderManagerServiceProviderTest extends ServiceProviderTestCase
|
||||
$app->register(new PhraseanetServiceProvider());
|
||||
$app['root.path'] = __DIR__ . '/../../../../../..';
|
||||
$app->register(new ConfigurationServiceProvider());
|
||||
|
||||
$bkp = $app['conf']->get('border-manager');
|
||||
|
||||
$app['conf']->set(['border-manager', 'enabled'], false);
|
||||
|
||||
$this->assertInstanceOf('Alchemy\Phrasea\Border\Manager', $app['border-manager']);
|
||||
$this->assertNull($app['phraseanet.metadata-reader']->getPdfToText());
|
||||
|
||||
if(is_null($bkp)) {
|
||||
$app['conf']->remove('border-manager');
|
||||
}
|
||||
else {
|
||||
$app['conf']->set('border-manager', $bkp);
|
||||
}
|
||||
}
|
||||
|
||||
public function testItLoadsWithXPDF()
|
||||
@@ -63,9 +73,19 @@ class BorderManagerServiceProviderTest extends ServiceProviderTestCase
|
||||
$app->register(new BorderManagerServiceProvider());
|
||||
$app['root.path'] = __DIR__ . '/../../../../../..';
|
||||
$app->register(new ConfigurationServiceProvider());
|
||||
|
||||
$bkp = $app['conf']->get('border-manager');
|
||||
|
||||
$app['conf']->set(['border-manager', 'enabled'], false);
|
||||
|
||||
$this->assertInstanceOf('Alchemy\Phrasea\Border\Manager', $app['border-manager']);
|
||||
$this->assertInstanceOf('XPDF\PdfToText', $app['phraseanet.metadata-reader']->getPdfToText());
|
||||
|
||||
if(is_null($bkp)) {
|
||||
$app['conf']->remove('border-manager');
|
||||
}
|
||||
else {
|
||||
$app['conf']->set('border-manager', $bkp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,9 @@ class LocaleServiceProviderTest extends \PhraseanetTestCase
|
||||
$app->register(new LocaleServiceProvider());
|
||||
$app['root.path'] = __DIR__ . '/../../../../../..';
|
||||
$app->register(new ConfigurationServiceProvider());
|
||||
|
||||
$bkp = $app['conf']->get('languages');
|
||||
|
||||
$app['conf']->set(['languages', 'available'], ['fr', 'zh', 'de']);
|
||||
|
||||
$original = Application::getAvailableLanguages();
|
||||
@@ -34,6 +37,8 @@ class LocaleServiceProviderTest extends \PhraseanetTestCase
|
||||
unset($original['nl']);
|
||||
|
||||
$this->assertEquals($original, $app['locales.available']);
|
||||
|
||||
$app['conf']->set('languages', $bkp);
|
||||
}
|
||||
|
||||
public function testLocalesCustomizedWithError()
|
||||
@@ -43,6 +48,8 @@ class LocaleServiceProviderTest extends \PhraseanetTestCase
|
||||
$app['root.path'] = __DIR__ . '/../../../../../..';
|
||||
$app->register(new ConfigurationServiceProvider());
|
||||
|
||||
$bkp = $app['conf']->get('languages');
|
||||
|
||||
$app['conf']->set(['languages', 'available'], ['en_US']);
|
||||
|
||||
$app['monolog'] = $this->getMock('Psr\Log\LoggerInterface');
|
||||
@@ -52,6 +59,8 @@ class LocaleServiceProviderTest extends \PhraseanetTestCase
|
||||
$original = Application::getAvailableLanguages();
|
||||
|
||||
$this->assertEquals($original, $app['locales.available']);
|
||||
|
||||
$app['conf']->set('languages', $bkp);
|
||||
}
|
||||
|
||||
public function testLocaleBeforeBoot()
|
||||
|
@@ -15,6 +15,25 @@ use Symfony\Component\Process\ExecutableFinder;
|
||||
*/
|
||||
class AutoloaderGeneratorTest extends \PhraseanetTestCase
|
||||
{
|
||||
private $bkp = null;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->bkp = self::$DI['app']['conf']->get('plugins');
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
if(is_null($this->bkp)) {
|
||||
self::$DI['app']['conf']->remove('plugins');
|
||||
}
|
||||
else {
|
||||
self::$DI['app']['conf']->set('plugins', $this->bkp);
|
||||
}
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGeneratedFileAfterInstall()
|
||||
{
|
||||
$pluginDir = __DIR__ . '/../Fixtures/PluginDirInstalled/test-plugin';
|
||||
|
@@ -47,9 +47,16 @@ class PluginManagerTest extends PluginTestCase
|
||||
|
||||
public function testHasPlugin()
|
||||
{
|
||||
$prevPlugins = self::$DI['cli']['conf']->get('plugins');
|
||||
|
||||
self::$DI['cli']['conf']->set('plugins', []);
|
||||
self::$DI['cli']['conf']->set(['plugins', 'test-plugin', 'enabled'], true);
|
||||
|
||||
$manager = new PluginManager(__DIR__ . '/Fixtures/PluginDirInstalled', self::$DI['cli']['plugins.plugins-validator'], self::$DI['cli']['conf']);
|
||||
$this->assertTrue($manager->hasPlugin('test-plugin'));
|
||||
$this->assertFalse($manager->hasPlugin('test-plugin2'));
|
||||
|
||||
self::$DI['cli']['conf']->set('plugins', $prevPlugins);
|
||||
}
|
||||
|
||||
private function createValidatorMock()
|
||||
|
@@ -48,6 +48,7 @@ class TextNodeTest extends \PHPUnit_Framework_TestCase
|
||||
$query_context->getUnrestrictedFields()->willReturn([$field]);
|
||||
$query_context->getPrivateFields()->willReturn([]);
|
||||
$query_context->localizeField($field)->willReturn(['foo.fr', 'foo.en']);
|
||||
$query_context->truncationField($field)->willReturn([]);
|
||||
|
||||
$node = new TextNode('bar', new Context('baz'));
|
||||
$query = $node->buildQuery($query_context->reveal());
|
||||
@@ -80,12 +81,18 @@ class TextNodeTest extends \PHPUnit_Framework_TestCase
|
||||
$query_context
|
||||
->localizeField($public_field)
|
||||
->willReturn(['foo.fr', 'foo.en']);
|
||||
$query_context
|
||||
->truncationField($public_field)
|
||||
->willReturn([]);
|
||||
$query_context
|
||||
->getPrivateFields()
|
||||
->willReturn([$private_field]);
|
||||
$query_context
|
||||
->localizeField($private_field)
|
||||
->willReturn(['private_caption.bar.fr', 'private_caption.bar.en']);
|
||||
$query_context
|
||||
->truncationField($private_field)
|
||||
->willReturn([]);
|
||||
|
||||
$node = new TextNode('baz');
|
||||
$query = $node->buildQuery($query_context->reveal());
|
||||
@@ -136,6 +143,7 @@ class TextNodeTest extends \PHPUnit_Framework_TestCase
|
||||
$query_context->getUnrestrictedFields()->willReturn([$field]);
|
||||
$query_context->getPrivateFields()->willReturn([]);
|
||||
$query_context->localizeField($field)->willReturn(['foo.fr', 'foo.en']);
|
||||
$query_context->truncationField($field)->willReturn([]);
|
||||
|
||||
$node = new TextNode('bar');
|
||||
$node->setConcepts([
|
||||
@@ -180,12 +188,18 @@ class TextNodeTest extends \PHPUnit_Framework_TestCase
|
||||
$query_context
|
||||
->localizeField($public_field)
|
||||
->willReturn(['foo.fr', 'foo.en']);
|
||||
$query_context
|
||||
->truncationField($public_field)
|
||||
->willReturn([]);
|
||||
$query_context
|
||||
->getPrivateFields()
|
||||
->willReturn([$private_field]);
|
||||
$query_context
|
||||
->localizeField($private_field)
|
||||
->willReturn(['private_caption.bar.fr', 'private_caption.bar.en']);
|
||||
$query_context
|
||||
->truncationField($private_field)
|
||||
->willReturn([]);
|
||||
|
||||
$node = new TextNode('baz');
|
||||
$node->setConcepts([
|
||||
|
@@ -18,7 +18,7 @@ class QueryContextTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$structure = $this->prophesize(Structure::class)->reveal();
|
||||
$available_locales = ['ab', 'cd', 'ef'];
|
||||
$context = new QueryContext($structure, $available_locales, 'fr');
|
||||
$context = new QueryContext(null, $structure, $available_locales, 'fr');
|
||||
$narrowed = $context->narrowToFields(['some_field']);
|
||||
$this->assertEquals(['some_field'], $narrowed->getFields());
|
||||
}
|
||||
@@ -33,10 +33,10 @@ class QueryContextTest extends \PHPUnit_Framework_TestCase
|
||||
'bar' => $bar_field
|
||||
]);
|
||||
|
||||
$context = new QueryContext($structure->reveal(), [], 'fr');
|
||||
$context = new QueryContext(null, $structure->reveal(), [], 'fr');
|
||||
$this->assertEquals([$foo_field, $bar_field], $context->getUnrestrictedFields());
|
||||
|
||||
$narrowed_context = new QueryContext($structure->reveal(), [], 'fr', ['foo']);
|
||||
$narrowed_context = new QueryContext(null, $structure->reveal(), [], 'fr', ['foo']);
|
||||
$this->assertEquals([$foo_field], $narrowed_context->getUnrestrictedFields());
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ class QueryContextTest extends \PHPUnit_Framework_TestCase
|
||||
'bar' => $bar_field
|
||||
]);
|
||||
|
||||
$context = new QueryContext($structure->reveal(), [], 'fr');
|
||||
$context = new QueryContext(null, $structure->reveal(), [], 'fr');
|
||||
$this->assertEquals([$foo_field, $bar_field], $context->getPrivateFields());
|
||||
|
||||
$narrowed_context = new QueryContext($structure->reveal(), [], 'fr', ['foo']);
|
||||
$narrowed_context = new QueryContext(null, $structure->reveal(), [], 'fr', ['foo']);
|
||||
$this->assertEquals([$foo_field], $narrowed_context->getPrivateFields());
|
||||
}
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
|
||||
$field->isFacet()->willReturn(false);
|
||||
$field->hasConceptInference()->willReturn(false);
|
||||
$field->getDependantCollections()->willReturn(['1']);
|
||||
$field->get_databox_id()->willReturn('1');
|
||||
|
||||
$structure->add($field->reveal());
|
||||
$this->assertCount(1, $structure->getAllFields());
|
||||
@@ -60,6 +61,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
|
||||
$field->isPrivate()->willReturn(false);
|
||||
$field->isFacet()->willReturn(false);
|
||||
$field->hasConceptInference()->willReturn(false);
|
||||
$field->get_databox_id()->willReturn('1');
|
||||
|
||||
$other = new Field('foo', FieldMapping::TYPE_STRING);
|
||||
|
||||
|
@@ -14,14 +14,14 @@ use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Typed;
|
||||
class ValueCheckerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider escapeRawProvider
|
||||
* @dataProvider valueCheckerProvider
|
||||
*/
|
||||
public function testValueCompatibility($subject, $value, $compatible)
|
||||
{
|
||||
$this->assertEquals($compatible, ValueChecker::isValueCompatible($subject, $value));
|
||||
}
|
||||
|
||||
public function escapeRawProvider()
|
||||
public function valueCheckerProvider()
|
||||
{
|
||||
$values = [
|
||||
[FieldMapping::TYPE_FLOAT , 42 , true ],
|
||||
|
Reference in New Issue
Block a user