fix tests, edit reset_install.sh, manage payment modules, change debugbar namespace to theliadebugbar
This commit is contained in:
@@ -62,26 +62,34 @@ class CacheClear extends ContainerAwareCommand
|
||||
|
||||
$this->clearCache($cacheDir, $output);
|
||||
if (!$input->getOption("without-assets")) {
|
||||
$this->clearCache(THELIA_WEB_DIR . "/assets", $output);
|
||||
$this->clearCache(THELIA_WEB_DIR . "assets", $output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function clearCache($dir, OutputInterface $output)
|
||||
{
|
||||
if (!is_writable($dir)) {
|
||||
throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $dir));
|
||||
}
|
||||
|
||||
$output->writeln(sprintf("Clearing cache in <info>%s</info> directory", $dir));
|
||||
|
||||
try {
|
||||
$directoryBrowser = new \DirectoryIterator($dir);
|
||||
} catch(\UnexpectedValueException $e) {
|
||||
// throws same exception code for does not exist and permission denied ...
|
||||
if(!file_exists($dir)) {
|
||||
$output->writeln(sprintf("<info>%s cache dir already clear</info>", $dir));
|
||||
return;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$fs = new Filesystem();
|
||||
try {
|
||||
$fs->remove($dir);
|
||||
|
||||
$output->writeln(sprintf("<info>%s cache dir cleared successfully</info>", $dir));
|
||||
} catch (IOException $e) {
|
||||
$output->writeln(sprintf("error during clearing cache : %s", $e->getMessage()));
|
||||
$output->writeln(sprintf("Error during clearing cache : %s", $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,31 +63,28 @@ class ModuleActivateCommand extends BaseModuleGenerate
|
||||
$module = ModuleQuery::create()->findOneByCode($moduleCode);
|
||||
|
||||
if(null === $module) {
|
||||
$output->renderBlock(array(
|
||||
'',
|
||||
sprintf("module %s not found", $moduleCode),
|
||||
''
|
||||
), "bg=red;fg=white");
|
||||
throw new \RuntimeException(sprintf("module %s not found", $moduleCode));
|
||||
}
|
||||
|
||||
try {
|
||||
new \TheliaDebugBar\TheliaDebugBar();
|
||||
|
||||
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
|
||||
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
|
||||
$moduleInstance->activate();
|
||||
} catch(\Exception $e) {
|
||||
$output->renderBlock(array(
|
||||
'',
|
||||
sprintf("Activation fail with Exception : [%d] %s", $e->getCode(), $e->getMessage()),
|
||||
''
|
||||
), "bg=red;fg=white");
|
||||
throw new \RuntimeException(sprintf("Activation fail with Exception : [%d] %s", $e->getCode(), $e->getMessage()));
|
||||
}
|
||||
|
||||
$output->renderBlock(array(
|
||||
'',
|
||||
sprintf("Activation succeed for module %s", $moduleCode),
|
||||
''
|
||||
), "bg=green;fg=black");
|
||||
//impossible to change output class in CommandTester...
|
||||
if (method_exists($output, "renderBlock")) {
|
||||
$output->renderBlock(array(
|
||||
'',
|
||||
sprintf("Activation succeed for module %s", $moduleCode),
|
||||
''
|
||||
), "bg=green;fg=black");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Exception\TaxEngineException;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
@@ -603,9 +604,13 @@ class Product extends BaseI18nLoop
|
||||
|
||||
$price = $product->getRealLowestPrice();
|
||||
|
||||
$taxedPrice = $product->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
try {
|
||||
$taxedPrice = $product->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
} catch(TaxEngineException $e) {
|
||||
$taxedPrice = null;
|
||||
}
|
||||
|
||||
// Find previous and next product, in the default category.
|
||||
$default_category_id = $product->getDefaultCategoryId();
|
||||
|
||||
@@ -151,13 +151,21 @@ class ProductSaleElements extends BaseLoop
|
||||
$loopResultRow = new LoopResultRow($loopResult, $PSEValue, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$price = $PSEValue->getPrice();
|
||||
$taxedPrice = $PSEValue->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
try {
|
||||
$taxedPrice = $PSEValue->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
} catch(TaxEngineException $e) {
|
||||
$taxedPrice = null;
|
||||
}
|
||||
$promoPrice = $PSEValue->getPromoPrice();
|
||||
$taxedPromoPrice = $PSEValue->getTaxedPromoPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
try {
|
||||
$taxedPromoPrice = $PSEValue->getTaxedPromoPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
} catch(TaxEngineException $e) {
|
||||
$taxedPromoPrice = null;
|
||||
}
|
||||
|
||||
$loopResultRow->set("ID", $PSEValue->getId())
|
||||
->set("QUANTITY", $PSEValue->getQuantity())
|
||||
|
||||
@@ -52,7 +52,13 @@ abstract class BaseModule extends ContainerAware
|
||||
if($moduleModel->getActivate() == self::IS_NOT_ACTIVATED) {
|
||||
$moduleModel->setActivate(self::IS_ACTIVATED);
|
||||
$moduleModel->save();
|
||||
$this->afterActivation();
|
||||
try {
|
||||
$this->afterActivation();
|
||||
} catch(\Exception $e) {
|
||||
$moduleModel->setActivate(self::IS_NOT_ACTIVATED);
|
||||
$moduleModel->save();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,20 +112,20 @@ abstract class BaseModule extends ContainerAware
|
||||
|
||||
$increment = 0;
|
||||
while(file_exists($imageDirectory . '/' . $imageFileName)) {
|
||||
$imageFileName = sprintf("module/%s-%d-%d-%s", $module->getCode(), $image->getId(), $increment, $fileName);
|
||||
$imageFileName = sprintf("%s-%d-%d-%s", $module->getCode(), $image->getId(), $increment, $fileName);
|
||||
$increment++;
|
||||
}
|
||||
|
||||
$imagePath = sprintf('%s/%s', $imageDirectory, $imageFileName);
|
||||
|
||||
if (! is_dir($imageDirectory)) {
|
||||
if(! mkdir($imageDirectory, 0777, true)) {
|
||||
if(! @mkdir($imageDirectory, 0777, true)) {
|
||||
$con->rollBack();
|
||||
throw new ModuleException(sprintf("Cannot create directory : %s", $imageDirectory), ModuleException::CODE_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
if(! copy($filePath, $imagePath)) {
|
||||
if(! @copy($filePath, $imagePath)) {
|
||||
$con->rollBack();
|
||||
throw new ModuleException(sprintf("Cannot copy file : %s to : %s", $filePath, $imagePath), ModuleException::CODE_NOT_FOUND);
|
||||
}
|
||||
|
||||
109
core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php
Executable file
109
core/lib/Thelia/Tests/Command/ModuleActivateCommandTest.php
Executable file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Tests\Command;
|
||||
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Thelia\Command\ModuleActivateCommand;
|
||||
use Thelia\Core\Application;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
/**
|
||||
* Class ModuleActivateCommandTest
|
||||
*
|
||||
* @package Thelia\Tests\Command
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class ModuleActivateCommandTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testModuleActivateCommand()
|
||||
{
|
||||
$module = ModuleQuery::create()->findOne();
|
||||
|
||||
if(null !== $module) {
|
||||
$application = new Application($this->getKernel());
|
||||
|
||||
$module->setActivate(BaseModule::IS_NOT_ACTIVATED);
|
||||
$module->save();
|
||||
|
||||
$moduleActivate = new ModuleActivateCommand();
|
||||
$moduleActivate->setContainer($this->getContainer());
|
||||
|
||||
$application->add($moduleActivate);
|
||||
|
||||
$command = $application->find("module:activate");
|
||||
$commandTester = new CommandTester($command);
|
||||
$commandTester->execute(array(
|
||||
"command" => $command->getName(),
|
||||
"module" => $module->getCode(),
|
||||
));
|
||||
|
||||
$this->assertEquals(BaseModule::IS_ACTIVATED, ModuleQuery::create()->findPk($module->getId())->getActivate());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessage module Letshopethismoduledoesnotexists not found
|
||||
*/
|
||||
public function testModuleActivateCommandUnknownModule()
|
||||
{
|
||||
$module = ModuleQuery::create()->findOne();
|
||||
$testedModule = ModuleQuery::create()->findOneByCode('Letshopethismoduledoesnotexists');
|
||||
|
||||
if(null !== $module && null == $testedModule) {
|
||||
$application = new Application($this->getKernel());
|
||||
|
||||
$module->setActivate(BaseModule::IS_NOT_ACTIVATED);
|
||||
$module->save();
|
||||
|
||||
$moduleActivate = new ModuleActivateCommand();
|
||||
$moduleActivate->setContainer($this->getContainer());
|
||||
|
||||
$application->add($moduleActivate);
|
||||
|
||||
$command = $application->find("module:activate");
|
||||
$commandTester = new CommandTester($command);
|
||||
$commandTester->execute(array(
|
||||
"command" => $command->getName(),
|
||||
"module" => "letshopethismoduledoesnotexists",
|
||||
));
|
||||
|
||||
$out = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function getKernel()
|
||||
{
|
||||
$kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface");
|
||||
|
||||
return $kernel;
|
||||
}
|
||||
|
||||
public function getContainer()
|
||||
{
|
||||
$container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
|
||||
|
||||
return $container;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat
|
||||
|
||||
|
||||
INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'DebugBar', 1, 1, 1, 'DebugBar\\DebugBar', NOW(), NOW()),
|
||||
(1, 'TheliaDebugBar', 1, 1, 1, 'TheliaDebugBar\\TheliaDebugBar', NOW(), NOW()),
|
||||
(2, 'Colissimo', 2, 0, 1, 'Colissimo\\Colissimo', NOW(), NOW()),
|
||||
(3, 'Cheque', 3, 0, 1, 'Cheque\\Cheque', NOW(), NOW()),
|
||||
(4, 'FakeCB', 3, 0, 2, 'FakeCB\\FakeCB', NOW(), NOW());
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<database defaultIdMethod="native" name="thelia" namespace="DebugBar\Model">
|
||||
<!--
|
||||
See propel documentation on http://propelorm.org for all information about schema file
|
||||
-->
|
||||
<external-schema filename="/home/manu/dev/www/thelia/local/config/schema.xml" referenceOnly="true" />
|
||||
</database>
|
||||
@@ -32,13 +32,13 @@
|
||||
<services>
|
||||
<service id="debugBar" class="DebugBar\DebugBar"/>
|
||||
|
||||
<service id="smarty.debugbar" class="DebugBar\Smarty\Plugin\DebugBar">
|
||||
<service id="smarty.debugbar" class="TheliaDebugBar\Smarty\Plugin\DebugBar">
|
||||
<argument type="service" id="debugBar"/>
|
||||
<argument >%kernel.debug%</argument>
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
</service>
|
||||
|
||||
<service id="debugBar.listener" class="DebugBar\Listeners\DebugBarListeners">
|
||||
<service id="debugBar.listener" class="TheliaDebugBar\Listeners\DebugBarListeners">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
6
local/modules/TheliaDebugBar/Config/schema.xml
Executable file
6
local/modules/TheliaDebugBar/Config/schema.xml
Executable file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<database defaultIdMethod="native" name="thelia" namespace="TheliaDebugBar\Model">
|
||||
<!--
|
||||
See propel documentation on http://propelorm.org for all information about schema file
|
||||
-->
|
||||
</database>
|
||||
@@ -21,14 +21,17 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace DebugBar\DataCollector;
|
||||
namespace TheliaDebugBar\DataCollector;
|
||||
|
||||
use DebugBar\DataCollector\DataCollector;
|
||||
use DebugBar\DataCollector\Renderable;
|
||||
use Propel\Runtime\Propel;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class PropelCollector
|
||||
* @package DebugBar\DataCollector
|
||||
* @package TheliaDebugBar\DataCollector
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class PropelCollector extends DataCollector implements Renderable, LoggerInterface
|
||||
@@ -21,11 +21,12 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace DebugBar\Listeners;
|
||||
namespace TheliaDebugBar\Listeners;
|
||||
|
||||
use DebugBar\DataCollector\MemoryCollector;
|
||||
use DebugBar\DataCollector\MessagesCollector;
|
||||
use DebugBar\DataCollector\PhpInfoCollector;
|
||||
use DebugBar\DataCollector\PropelCollector;
|
||||
use TheliaDebugBar\DataCollector\PropelCollector;
|
||||
use DebugBar\DataCollector\TimeDataCollector;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
@@ -35,7 +36,7 @@ use Thelia\Core\Event\TheliaEvents;
|
||||
|
||||
/**
|
||||
* Class DebugBarListeners
|
||||
* @package DebugBar\Listeners
|
||||
* @package TheliaDebugBar\Listeners
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class DebugBarListeners extends BaseAction implements EventSubscriberInterface {
|
||||
@@ -21,7 +21,7 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace DebugBar\Smarty\Plugin;
|
||||
namespace TheliaDebugBar\Smarty\Plugin;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Template\Smarty\an;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
@@ -21,11 +21,11 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace DebugBar;
|
||||
namespace TheliaDebugBar;
|
||||
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
class DebugBar extends BaseModule
|
||||
class TheliaDebugBar extends BaseModule
|
||||
{
|
||||
/**
|
||||
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class
|
||||
@@ -49,6 +49,6 @@ class DebugBar extends BaseModule
|
||||
|
||||
public function getCode()
|
||||
{
|
||||
return 'DebugBar';
|
||||
return 'TheliaDebugBar';
|
||||
}
|
||||
}
|
||||
@@ -2,41 +2,43 @@
|
||||
# @author Guillaume MOREL
|
||||
# v0.2
|
||||
|
||||
echo -e "\033[47m\033[1;31m\n[WARN] This script will reset this Thelia2 install\n\033[0m"
|
||||
echo -e "\033[47m\033[1;31m\n[WARNING] This script will reset this Thelia2 install\nPress ENTER to continue or ^C to cancel\033[0m"
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Clearing caches\e[00m\n"
|
||||
read test
|
||||
|
||||
echo -e "\n\033[01;34m[INFO] Clearing caches\033[00m\n"
|
||||
php Thelia cache:clear
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Downloading vendors\e[00m\n"
|
||||
echo -e "\n\033[01;34m[INFO] Downloading vendors\033[00m\n"
|
||||
composer install --prefer-dist --optimize-autoloader
|
||||
|
||||
cd local/config/
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Building Models file\e[00m\n"
|
||||
echo -e "\n\033[01;34m[INFO] Building Models file\033[00m\n"
|
||||
../../bin/propel build -v --output-dir=../../core/lib/
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Building SQL CREATE file\e[00m\n"
|
||||
echo -e "\n\033[01;34m[INFO] Building SQL CREATE file\033[00m\n"
|
||||
../../bin/propel sql:build -v --output-dir=../../install/
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Reloading Thelia2 database\e[00m\n"
|
||||
echo -e "\n\033[01;34m[INFO] Reloading Thelia2 database\033[00m\n"
|
||||
cd ../..
|
||||
rm install/sqldb.map
|
||||
php Thelia thelia:dev:reloadDB
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Installing fixtures\e[00m\n"
|
||||
echo -e "\n\033[01;34m[INFO] Installing fixtures\033[00m\n"
|
||||
php install/faker.php
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Adding admin\e[00m\n"
|
||||
echo -e "\n\033[01;34m[INFO] Adding admin\033[00m\n"
|
||||
php Thelia thelia:create-admin --login_name thelia2 --password thelia2 --last_name thelia2 --first_name thelia2
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Clearing caches\e[00m\n"
|
||||
echo -e "\n\033[01;34m[INFO] Clearing caches\033[00m\n"
|
||||
php Thelia cache:clear
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Activating Delivery Module(s)\e[00m\n"
|
||||
echo -e "\n\033[01;34m[INFO] Activating Delivery Module(s)\033[00m\n"
|
||||
php Thelia module:activate Colissimo
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Activating Payment Module(s)\e[00m\n"
|
||||
echo -e "\n\033[01;34m[INFO] Activating Payment Module(s)\033[00m\n"
|
||||
php Thelia module:activate Cheque
|
||||
php Thelia module:activate FakeCB
|
||||
|
||||
echo -e "\n\e[00;32m[SUCCESS] Reset done\e[00m\n"
|
||||
echo -e "\n\033[00;32m[SUCCESS] Reset done\033[00m\n"
|
||||
Reference in New Issue
Block a user