PHRAS-2859_tests-do-corrupt-conf_4.1

fix tests
This commit is contained in:
Jean-Yves Gaulier
2019-12-17 11:17:01 +01:00
parent 24e56696e7
commit f57e85ec2a
2 changed files with 22 additions and 30 deletions

View File

@@ -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()

View File

@@ -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()