From 915e7bcd32aa0f25e7d0f935a17be9dc622d1cf6 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Thu, 12 Dec 2019 16:53:15 +0100 Subject: [PATCH 1/3] PHRAS-2859_tests-do-corrupt-conf_4.1 fix : configuration.yml is not modified by unit-tests anymore --- .../Phrasea/Command/Plugin/AddPluginTest.php | 20 +++++++++++++ .../Command/Plugin/DisablePluginTest.php | 9 ++++++ .../Command/Plugin/EnablePluginTest.php | 9 ++++++ .../Phrasea/Controller/Prod/ExportTest.php | 6 +++- .../CLIProvider/PluginServiceProviderTest.php | 14 +++++++-- .../DisplaySettingServiceTest.php | 30 +++++++++---------- .../Subscriber/DebuggerSubscriberTest.php | 11 ++++++- ...thenticationManagerServiceProviderTest.php | 21 +++++++++++++ .../BorderManagerServiceProviderTest.php | 20 +++++++++++++ .../Provider/LocaleServiceProviderTest.php | 9 ++++++ .../Management/AutoloaderGeneratorTest.php | 19 ++++++++++++ .../Phrasea/Plugin/PluginManagerTest.php | 20 +++++++++++++ 12 files changed, 169 insertions(+), 19 deletions(-) diff --git a/tests/Alchemy/Tests/Phrasea/Command/Plugin/AddPluginTest.php b/tests/Alchemy/Tests/Phrasea/Command/Plugin/AddPluginTest.php index e1784cfcbf..523b4c00da 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Plugin/AddPluginTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Plugin/AddPluginTest.php @@ -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'; diff --git a/tests/Alchemy/Tests/Phrasea/Command/Plugin/DisablePluginTest.php b/tests/Alchemy/Tests/Phrasea/Command/Plugin/DisablePluginTest.php index 06029140c2..09a1b52c03 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Plugin/DisablePluginTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Plugin/DisablePluginTest.php @@ -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() diff --git a/tests/Alchemy/Tests/Phrasea/Command/Plugin/EnablePluginTest.php b/tests/Alchemy/Tests/Phrasea/Command/Plugin/EnablePluginTest.php index d5f8c22ba8..9408489b55 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Plugin/EnablePluginTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Plugin/EnablePluginTest.php @@ -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() diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php index da278639c2..886df13e81 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php @@ -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); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/PluginServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/PluginServiceProviderTest.php index ad07999d04..8af589cd4a 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/PluginServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/CLIProvider/PluginServiceProviderTest.php @@ -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); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Configuration/DisplaySettingServiceTest.php b/tests/Alchemy/Tests/Phrasea/Core/Configuration/DisplaySettingServiceTest.php index 3cc753a6be..71269e4755 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Configuration/DisplaySettingServiceTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Configuration/DisplaySettingServiceTest.php @@ -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(); } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/DebuggerSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/DebuggerSubscriberTest.php index 938207cdf1..308d0a9ced 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/DebuggerSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/DebuggerSubscriberTest.php @@ -35,6 +35,8 @@ class DebuggerSubscriberTest extends \PhraseanetTestCase unlink($app['phraseanet.configuration.config-compiled-path']); } + $bkp = $app['conf']->get('debugger'); + $app['conf']->set(['debugger', 'allowed-ips'], $authorized); $app['dispatcher']->addSubscriber(new DebuggerSubscriber($app)); @@ -48,7 +50,14 @@ class DebuggerSubscriberTest extends \PhraseanetTestCase $this->setExpectedException('Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException'); } - $app->handle(new Request([], [], [], [], [], ['REMOTE_ADDR' => $incomingIp])); + try { + $app->handle(new Request([], [], [], [], [], ['REMOTE_ADDR' => $incomingIp])); + } + catch (\Exception $e) { + // no-op + } + + $app['conf']->set('debugger', $bkp); } public function provideIpsAndEnvironments() diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php index fb128260f8..c28a005f72 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/AuthenticationManagerServiceProviderTest.php @@ -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() diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php index 3ebca4a7f5..14f16bb8d4 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php @@ -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); + } } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/LocaleServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/LocaleServiceProviderTest.php index 49d0d54fc8..db97e02e07 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/LocaleServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/LocaleServiceProviderTest.php @@ -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() diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/Management/AutoloaderGeneratorTest.php b/tests/Alchemy/Tests/Phrasea/Plugin/Management/AutoloaderGeneratorTest.php index 49bfc79340..42f6d2ea9d 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/Management/AutoloaderGeneratorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/Management/AutoloaderGeneratorTest.php @@ -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'; diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/PluginManagerTest.php b/tests/Alchemy/Tests/Phrasea/Plugin/PluginManagerTest.php index af439bdf15..39f676e4d1 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/PluginManagerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/PluginManagerTest.php @@ -11,6 +11,26 @@ use Alchemy\Phrasea\Plugin\Schema\PluginValidator; */ class PluginManagerTest extends PluginTestCase { + private $bkp; + + 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 testListGoodPlugins() { $prevPlugins = self::$DI['cli']['conf']->get('plugins'); From 24e56696e78d18fd2e4be9ea1dfdd41b3b14fe71 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Mon, 16 Dec 2019 18:15:43 +0100 Subject: [PATCH 2/3] PHRAS-2859_tests-do-corrupt-conf_4.1 fix test that overrides conf during install. --- .../Tests/Phrasea/Command/Setup/InstallTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/Alchemy/Tests/Phrasea/Command/Setup/InstallTest.php b/tests/Alchemy/Tests/Phrasea/Command/Setup/InstallTest.php index f05831d94b..f8e0a8b5a1 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Setup/InstallTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Setup/InstallTest.php @@ -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'); From f57e85ec2abfb2b29686a84c41c1f8e5444e5673 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Tue, 17 Dec 2019 11:17:01 +0100 Subject: [PATCH 3/3] PHRAS-2859_tests-do-corrupt-conf_4.1 fix tests --- .../Subscriber/DebuggerSubscriberTest.php | 25 ++++++++++------- .../Phrasea/Plugin/PluginManagerTest.php | 27 +++++-------------- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/DebuggerSubscriberTest.php b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/DebuggerSubscriberTest.php index 308d0a9ced..ee899a026a 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/DebuggerSubscriberTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Event/Subscriber/DebuggerSubscriberTest.php @@ -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'); } @@ -35,8 +49,6 @@ class DebuggerSubscriberTest extends \PhraseanetTestCase unlink($app['phraseanet.configuration.config-compiled-path']); } - $bkp = $app['conf']->get('debugger'); - $app['conf']->set(['debugger', 'allowed-ips'], $authorized); $app['dispatcher']->addSubscriber(new DebuggerSubscriber($app)); @@ -50,14 +62,7 @@ class DebuggerSubscriberTest extends \PhraseanetTestCase $this->setExpectedException('Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException'); } - try { - $app->handle(new Request([], [], [], [], [], ['REMOTE_ADDR' => $incomingIp])); - } - catch (\Exception $e) { - // no-op - } - - $app['conf']->set('debugger', $bkp); + $app->handle(new Request([], [], [], [], [], ['REMOTE_ADDR' => $incomingIp])); } public function provideIpsAndEnvironments() diff --git a/tests/Alchemy/Tests/Phrasea/Plugin/PluginManagerTest.php b/tests/Alchemy/Tests/Phrasea/Plugin/PluginManagerTest.php index 39f676e4d1..16288b353b 100644 --- a/tests/Alchemy/Tests/Phrasea/Plugin/PluginManagerTest.php +++ b/tests/Alchemy/Tests/Phrasea/Plugin/PluginManagerTest.php @@ -11,26 +11,6 @@ use Alchemy\Phrasea\Plugin\Schema\PluginValidator; */ class PluginManagerTest extends PluginTestCase { - private $bkp; - - 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 testListGoodPlugins() { $prevPlugins = self::$DI['cli']['conf']->get('plugins'); @@ -67,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()