Merge branch 'master' of https://github.com/thelia/thelia
This commit is contained in:
20
core/lib/Thelia/Tests/Command/BaseCommandTest.php
Normal file
20
core/lib/Thelia/Tests/Command/BaseCommandTest.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* User: manu
|
||||
* Date: 11/07/13
|
||||
* Time: 10:34
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
|
||||
namespace Thelia\Tests\Command;
|
||||
|
||||
|
||||
abstract class BaseCommandTest extends \PHPUnit_Framework_TestCase {
|
||||
public function getKernel()
|
||||
{
|
||||
$kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface");
|
||||
|
||||
return $kernel;
|
||||
}
|
||||
}
|
||||
108
core/lib/Thelia/Tests/Command/ModuleGenerateCommandTest.php
Normal file
108
core/lib/Thelia/Tests/Command/ModuleGenerateCommandTest.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?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 Symfony\Component\Filesystem\Filesystem;
|
||||
use Thelia\Core\Application;
|
||||
use Thelia\Command\ModuleGenerateCommand;
|
||||
|
||||
class ModuleGenerateCommandTest extends BaseCommandTest {
|
||||
|
||||
protected $command;
|
||||
protected $commandTester;
|
||||
|
||||
public static function clearTest()
|
||||
{
|
||||
$fs = new Filesystem();
|
||||
|
||||
if ($fs->exists(THELIA_MODULE_DIR . "Test")) {
|
||||
$fs->remove(THELIA_MODULE_DIR . "Test");
|
||||
}
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::clearTest();
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
self::clearTest();
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$application = new Application($this->getKernel());
|
||||
|
||||
$moduleGenerator = new ModuleGenerateCommand();
|
||||
|
||||
$application->add($moduleGenerator);
|
||||
|
||||
$this->command = $application->find("module:generate");
|
||||
$this->commandTester = new CommandTester($this->command);
|
||||
|
||||
}
|
||||
|
||||
public function testGenerateModule()
|
||||
{
|
||||
$tester = $this->commandTester;
|
||||
|
||||
$tester->execute(array(
|
||||
"command" => $this->command->getName(),
|
||||
"name" => "test"
|
||||
));
|
||||
|
||||
$fs = new Filesystem();
|
||||
|
||||
$this->assertTrue($fs->exists(THELIA_MODULE_DIR . "Test"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGenerateModule
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testGenerateDuplicateModule()
|
||||
{
|
||||
$tester = $this->commandTester;
|
||||
|
||||
$tester->execute(array(
|
||||
"command" => $this->command->getName(),
|
||||
"name" => "test"
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testGenerateWithReservedKeyWord()
|
||||
{
|
||||
$tester = $this->commandTester;
|
||||
|
||||
$tester->execute(array(
|
||||
"command" => $this->command->getName(),
|
||||
"name" => "thelia"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,7 @@ class TlogTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $logger;
|
||||
|
||||
//protected $regex = "/(\\d)(:)(\\s+)(%s)(\\s+)(\\[.*?\\])(\\s+)(\\{.*?\\})(\\s+)(\\d{4})(-)(\\d{2})(-)(\\d{2})(\\s+)(\\d{2})(:)(\\d{2})(:)(\\d{2})(:)(\\s+)(%s)([\n])/is";
|
||||
protected $regex = "/[0-9]+:[\s](%s)+[\s]\[[a-zA-Z\.]+:[a-zA-Z]+\(\)\][\s]\{[0-9]+\}[\s][0-9]{4}-[0-9]{2}-[0-9]{2}[\s][0-9]{2}:[0-9]{2}:[0-9]{2}:[\s](%s).*$/is";
|
||||
protected $regex = "/[0-9]+:[\s](%s)+[\s]\[[a-zA-Z\.]+:[a-zA-Z]+\(\)\][\s]\{[0-9]+\}[\s][0-9]{4}-[0-9]{2}-[0-9]{2}[\s][0-9]{1,2}:[0-9]{2}:[0-9]{2}:[\s](%s).*$/is";
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user