@@ -12,6 +12,7 @@
|
|||||||
- class event : Thelia\Core\Event\SessionEvent
|
- class event : Thelia\Core\Event\SessionEvent
|
||||||
- example : Thelia\Core\EventListener\SessionListener
|
- example : Thelia\Core\EventListener\SessionListener
|
||||||
- Creation of Thelia\Core\TheliakernelEvents class for referencing kernel event
|
- Creation of Thelia\Core\TheliakernelEvents class for referencing kernel event
|
||||||
|
- Add new command line that refresh modules list `Thelia module:refresh`
|
||||||
|
|
||||||
|
|
||||||
#2.0.1
|
#2.0.1
|
||||||
|
|||||||
54
core/lib/Thelia/Command/ModuleRefreshCommand.php
Normal file
54
core/lib/Thelia/Command/ModuleRefreshCommand.php
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* This file is part of the Thelia package. */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : dev@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||||
|
/* file that was distributed with this source code. */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Command;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Thelia\Module\ModuleManagement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ModuleRefreshCommand
|
||||||
|
* Refresh modules list
|
||||||
|
*
|
||||||
|
* @package Thelia\Command
|
||||||
|
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||||
|
*/
|
||||||
|
class ModuleRefreshCommand extends ContainerAwareCommand
|
||||||
|
{
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->setName('module:refresh')
|
||||||
|
->setDescription('Refresh modules list');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$moduleManagement = new ModuleManagement;
|
||||||
|
$moduleManagement->updateModules();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new \RuntimeException(sprintf('Refresh modules list fail with Exception : [%d] %s', $e->getCode(), $e->getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method_exists($output, 'renderBlock')) {
|
||||||
|
$output->renderBlock([
|
||||||
|
'',
|
||||||
|
'Modules list successfully refreshed',
|
||||||
|
''
|
||||||
|
],
|
||||||
|
'bg=green;fg=black'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
<command class="Thelia\Command\ModuleGenerateCommand"/>
|
<command class="Thelia\Command\ModuleGenerateCommand"/>
|
||||||
<command class="Thelia\Command\ModuleGenerateModelCommand"/>
|
<command class="Thelia\Command\ModuleGenerateModelCommand"/>
|
||||||
<command class="Thelia\Command\ModuleGenerateSqlCommand"/>
|
<command class="Thelia\Command\ModuleGenerateSqlCommand"/>
|
||||||
|
<command class="Thelia\Command\ModuleRefreshCommand"/>
|
||||||
<command class="Thelia\Command\ModuleActivateCommand"/>
|
<command class="Thelia\Command\ModuleActivateCommand"/>
|
||||||
<command class="Thelia\Command\ModuleDeactivateCommand"/>
|
<command class="Thelia\Command\ModuleDeactivateCommand"/>
|
||||||
<command class="Thelia\Command\CreateAdminUser"/>
|
<command class="Thelia\Command\CreateAdminUser"/>
|
||||||
|
|||||||
105
core/lib/Thelia/Tests/Command/ModuleRefreshCommandTest.php
Normal file
105
core/lib/Thelia/Tests/Command/ModuleRefreshCommandTest.php
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* This file is part of the Thelia package. */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : dev@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||||
|
/* file that was distributed with this source code. */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Tests\Command;
|
||||||
|
|
||||||
|
use PHPUnit_Framework_TestCase;
|
||||||
|
use Propel\Runtime\ActiveQuery\Criteria;
|
||||||
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
|
use Thelia\Command\ModuleRefreshCommand;
|
||||||
|
use Thelia\Core\Application;
|
||||||
|
use Thelia\Model\ModuleQuery;
|
||||||
|
use Thelia\Module\ModuleManagement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ModuleRefreshCommandTest
|
||||||
|
* Test refresh modules list command
|
||||||
|
*
|
||||||
|
* @package Thelia\Tests\Command
|
||||||
|
* @author Jérôme Billiras <jbilliras@openstudio.fr>
|
||||||
|
*
|
||||||
|
* Date: 2014-06-06
|
||||||
|
* Time: 17:29
|
||||||
|
*/
|
||||||
|
class ModuleRefreshCommandTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Test ModuleRefreshCommand
|
||||||
|
*/
|
||||||
|
public function testModuleRefreshCommand()
|
||||||
|
{
|
||||||
|
$moduleManagement = new ModuleManagement;
|
||||||
|
$moduleManagement->updateModules();
|
||||||
|
|
||||||
|
$module = ModuleQuery::create()->filterByType(1)->orderByPosition(Criteria::DESC)->findOne();
|
||||||
|
|
||||||
|
if ($module !== null) {
|
||||||
|
$module->delete();
|
||||||
|
|
||||||
|
$application = new Application($this->getKernel());
|
||||||
|
|
||||||
|
$moduleRefresh = new ModuleRefreshCommand;
|
||||||
|
$moduleRefresh->setContainer($this->getContainer());
|
||||||
|
|
||||||
|
$application->add($moduleRefresh);
|
||||||
|
|
||||||
|
$command = $application->find('module:refresh');
|
||||||
|
$commandTester = new CommandTester($command);
|
||||||
|
$commandTester->execute([
|
||||||
|
'command' => $command->getName()
|
||||||
|
]);
|
||||||
|
|
||||||
|
$expected = $module;
|
||||||
|
$actual = ModuleQuery::create()->filterByType(1)->orderByPosition(Criteria::DESC)->findOne();
|
||||||
|
|
||||||
|
$this->assertEquals($expected->getCode(), $actual->getCode(), 'Last standard module code must be same after deleting this one and calling module:refresh');
|
||||||
|
$this->assertEquals($expected->getType(), $actual->getType(), 'Last standard module type must be same after deleting this one and calling module:refresh');
|
||||||
|
$this->assertEquals($expected->getFullNamespace(), $actual->getFullNamespace(), 'Last standard module namespace must be same after deleting this one and calling module:refresh');
|
||||||
|
|
||||||
|
// Restore activation status
|
||||||
|
$actual
|
||||||
|
->setActivate($expected->getActivate())
|
||||||
|
->save();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$this->markTestIncomplete(
|
||||||
|
'This test cannot be complete without at least one standard module.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get HttpKernel mock
|
||||||
|
*
|
||||||
|
* @return Kernel Not really a Kernel but the mocked one
|
||||||
|
*/
|
||||||
|
public function getKernel()
|
||||||
|
{
|
||||||
|
$kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface');
|
||||||
|
|
||||||
|
return $kernel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get new ContainerBuilder
|
||||||
|
*
|
||||||
|
* @return ContainerBuilder
|
||||||
|
*/
|
||||||
|
public function getContainer()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder;
|
||||||
|
|
||||||
|
return $container;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user