From 63fce45974993ee49f430eafea63778dc8f5e173 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Wed, 19 Feb 2020 16:20:36 +0100 Subject: [PATCH 1/2] PHRAS-2854_generate-js-fixtures add message to tell to remove plugins --- .../Phrasea/Command/Developer/JsFixtures.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php b/lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php index 890fed9e6d..4427cd4ce6 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php +++ b/lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php @@ -15,6 +15,7 @@ use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Command\Command; use Alchemy\Phrasea\Exception\RuntimeException; use Alchemy\Phrasea\Model\Entities\User; +use Alchemy\Phrasea\Plugin\Plugin; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\HttpKernel\Client; @@ -30,6 +31,15 @@ class JsFixtures extends Command protected function doExecute(InputInterface $input, OutputInterface $output) { + /** @var Plugin $plugin */ + $msg = []; + foreach($this->container['plugins.manager']->listPlugins() as $plugin) { + $msg[] = sprintf(" bin/setup plugins:remove \"%s\"", $plugin->getName()); + } + if(count($msg) !== 0) { + throw new RuntimeException("You must remove plugins first:\n" . join("\n", $msg)); + } + if (!file_exists($this->container['db.fixture.info']['path'])) { throw new RuntimeException('You must generate sqlite db first, run "bin/developer phraseanet:regenerate-sqlite" command.'); } @@ -104,6 +114,7 @@ class JsFixtures extends Command private function writeResponse(OutputInterface $output, $method, $path, $to, $authenticateUser = false) { $environment = Application::ENV_TEST; + /** @var Application $app */ $app = require __DIR__ . '/../../Application/Root.php'; $app['orm.em'] = $app->extend('orm.em', function($em, $app) { return $app['orm.ems'][$app['db.fixture.hash.key']]; @@ -119,12 +130,14 @@ class JsFixtures extends Command $output->writeln(sprintf("Generating %s", $target)); if ($authenticateUser) { - $this->loginUser($app, $user); + // $this->loginUser($app, $user); + $app->getAuthenticator()->openAccount($user); } $client->request($method, $path); $response = $client->getResponse(); if ($authenticateUser) { - $this->logoutUser($app); + // $this->logoutUser($app); + $app->getAuthenticator()->closeAccount(); } if (false === $response->isOk()) { $this->deleteUser($user); From 4f99fb57c7368f15ee8754ad549250def4f83429 Mon Sep 17 00:00:00 2001 From: Jean-Yves Gaulier Date: Wed, 19 Feb 2020 17:10:32 +0100 Subject: [PATCH 2/2] cleanup debug --- lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php b/lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php index 4427cd4ce6..112914d088 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php +++ b/lib/Alchemy/Phrasea/Command/Developer/JsFixtures.php @@ -130,14 +130,12 @@ class JsFixtures extends Command $output->writeln(sprintf("Generating %s", $target)); if ($authenticateUser) { - // $this->loginUser($app, $user); - $app->getAuthenticator()->openAccount($user); + $this->loginUser($app, $user); } $client->request($method, $path); $response = $client->getResponse(); if ($authenticateUser) { - // $this->logoutUser($app); - $app->getAuthenticator()->closeAccount(); + $this->logoutUser($app); } if (false === $response->isOk()) { $this->deleteUser($user);