mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
fix AddPluginTest
This commit is contained in:
@@ -15,6 +15,21 @@ use Alchemy\Phrasea\Command\Command;
|
|||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
function normalizePath($path) {
|
||||||
|
return array_reduce(explode('/', $path), function ($a, $b) {
|
||||||
|
if($a === 0)
|
||||||
|
$a = '/';
|
||||||
|
|
||||||
|
if($b === '' || $b === '.')
|
||||||
|
return $a;
|
||||||
|
|
||||||
|
if($b === '..')
|
||||||
|
return dirname($a);
|
||||||
|
|
||||||
|
return preg_replace('/\/+/', '/', "$a/$b");
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
abstract class AbstractPluginCommand extends Command
|
abstract class AbstractPluginCommand extends Command
|
||||||
{
|
{
|
||||||
protected function validatePlugins(InputInterface $input, OutputInterface $output)
|
protected function validatePlugins(InputInterface $input, OutputInterface $output)
|
||||||
@@ -54,13 +69,12 @@ abstract class AbstractPluginCommand extends Command
|
|||||||
|
|
||||||
protected function doInstallPlugin($source, InputInterface $input, OutputInterface $output)
|
protected function doInstallPlugin($source, InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
|
||||||
$output->write("Validating plugin...");
|
$output->write("Validating plugin...");
|
||||||
$manifest = $this->container['plugins.plugins-validator']->validatePlugin($source);
|
$manifest = $this->container['plugins.plugins-validator']->validatePlugin($source);
|
||||||
$output->writeln(" <comment>OK</comment> found <info>".$manifest->getName()."</info>");
|
$output->writeln(" <comment>OK</comment> found <info>".$manifest->getName()."</info>");
|
||||||
|
|
||||||
$targetDir = $this->container['plugin.path'] . DIRECTORY_SEPARATOR . $manifest->getName();
|
$targetDir = $this->container['plugin.path'] . DIRECTORY_SEPARATOR . $manifest->getName();
|
||||||
if (realpath($targetDir) !== realpath($source)) {
|
if (normalizePath($targetDir) !== normalizePath($source)) {
|
||||||
$temporaryDir = $this->container['temporary-filesystem']->createTemporaryDirectory();
|
$temporaryDir = $this->container['temporary-filesystem']->createTemporaryDirectory();
|
||||||
$output->write("Importing <info>$source</info>...");
|
$output->write("Importing <info>$source</info>...");
|
||||||
$this->container['plugins.importer']->import($source, $temporaryDir);
|
$this->container['plugins.importer']->import($source, $temporaryDir);
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class AddPluginTest extends PluginCommandTestCase
|
|||||||
// the plugin is checked when updating config files
|
// the plugin is checked when updating config files
|
||||||
self::$DI['cli']['plugins.plugins-validator']->expects($this->at(0))
|
self::$DI['cli']['plugins.plugins-validator']->expects($this->at(0))
|
||||||
->method('validatePlugin')
|
->method('validatePlugin')
|
||||||
->with('tempdir')
|
->with('TestPlugin')
|
||||||
->will($this->returnValue($manifest));
|
->will($this->returnValue($manifest));
|
||||||
|
|
||||||
self::$DI['cli']['plugins.plugins-validator']->expects($this->at(1))
|
self::$DI['cli']['plugins.plugins-validator']->expects($this->at(1))
|
||||||
|
|||||||
Reference in New Issue
Block a user