fix test issue

This commit is contained in:
Manuel Raynaud
2013-07-11 15:57:26 +02:00
parent 6fa815d174
commit 1a7c9b2fd2
3 changed files with 86 additions and 32 deletions

View File

@@ -0,0 +1,55 @@
<?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\Command;
abstract class BaseModuleGenerate extends ContainerAwareCommand {
protected $module;
protected $moduleDirectory;
protected $reservedKeyWords = array(
"thelia"
);
protected $neededDirectories = array(
"Config",
"Model",
"Loop"
);
protected function verifyExistingModule()
{
if (file_exists($this->moduleDirectory)) {
throw new \RuntimeException(sprintf("%s module already exists", $this->module));
}
}
protected function formatModuleName($name)
{
if (in_array(strtolower($name), $this->reservedKeyWords)) {
throw new \RuntimeException(sprintf("%s module name is a reserved keyword", $name));
}
return ucfirst($name);
}
}

View File

@@ -28,20 +28,9 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
class ModuleGenerateCommand extends ContainerAwareCommand {
class ModuleGenerateCommand extends BaseModuleGenerate {
protected $module;
protected $moduleDirectory;
private $reservedKeyWords = array(
"thelia"
);
private $neededDirectories = array(
"Config",
"Model",
"Loop"
);
protected function configure()
{
@@ -64,13 +53,16 @@ class ModuleGenerateCommand extends ContainerAwareCommand {
$this->createDirectories();
$this->createFiles();
if(method_exists($this, "renderBlock")) {
//impossible to change output class in CommandTester...
$output->renderBlock(array(
'',
sprintf("module %s create with success", $this->module),
"You can now configure your module and complete plugin.xml file",
''
), "bg=green;fg=black");
}
$output->renderBlock(array(
'',
sprintf("module %s create with success", $this->module),
"You can now configure your module and complete plugin.xml file",
''
), "bg=green;fg=black");
}
private function createDirectories()
@@ -107,18 +99,5 @@ class ModuleGenerateCommand extends ContainerAwareCommand {
}
private function verifyExistingModule()
{
if (file_exists($this->moduleDirectory)) {
throw new \RuntimeException(sprintf("%s module already exists", $this->module));
}
}
private function formatModuleName($name)
{
if (in_array(strtolower($name), $this->reservedKeyWords)) {
throw new \RuntimeException(sprintf("%s module name is a reserved keyword", $name));
}
return ucfirst($name);
}
}

View File

@@ -1,5 +1,25 @@
<?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\Command\Output;