fix some CS

This commit is contained in:
Manuel Raynaud
2013-01-09 09:13:25 +01:00
parent a168082d54
commit 4e21c25867
26 changed files with 422 additions and 346 deletions

View File

@@ -21,7 +21,6 @@
/* */
/*************************************************************************************/
namespace Thelia\Tests\Log;
use Thelia\Log\Tlog;
@@ -30,18 +29,19 @@ use Thelia\Core\Thelia;
class TlogTest extends \PHPUnit_Framework_TestCase
{
protected $logger;
protected $regex = "/(\\d)(.)(\\s+)((?:[a-z][a-z]+))(\\s+)(\\[.*?\\])(\\s+)(\\{.*?\\})(\\s+)((?:2|1)\\d{3}(?:-|\\/)(?:(?:0[1-9])|(?:1[0-2]))(?:-|\\/)(?:(?:0[1-9])|(?:[1-2][0-9])|(?:3[0-1]))(?:T|\\s)(?:(?:[0-1][0-9])|(?:2[0-3])):(?:[0-5][0-9]):(?:[0-5][0-9]))(.)(\\s+)(%s)/is";
public function setUp() {
public function setUp()
{
parent::setUp();
$_SERVER['REMOTE_ADDR'] = '::1';
$containerMock = $this->getMock("Symfony\Component\DependencyInjection\Container", array("get", "getParameter"));
$configModel = new ConfigModel();
$containerMock->expects($this->any())
->method("get")
->will($this->returnValue($configModel));
@@ -49,140 +49,139 @@ class TlogTest extends \PHPUnit_Framework_TestCase
->method("getParameter")
->with($this->stringContains("logger.class"))
->will($this->returnValue("Thelia\Log\Tlog"));
$this->logger = new Tlog($containerMock);
$this->logger->set_destinations("Thelia\Log\Destination\TlogDestinationText");
$this->logger->set_level(Tlog::TRACE);
$this->logger->set_files("*");
}
public function testTraceWithTraceLevel()
{
$logger = $this->logger;
$logger->set_level(Tlog::TRACE);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "foo"));
$logger->trace("foo");
}
public function testTraceWitoutTraceLevel()
{
$logger = $this->logger;
$logger->set_level(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->trace("foo");
}
public function testDebugWithDebugLevel()
{
$logger = $this->logger;
$logger->set_level(Tlog::DEBUG);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "foo"));
$logger->debug("foo");
}
public function testDebugWitoutDebugLevel()
{
$logger = $this->logger;
$logger->set_level(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->debug("foo");
}
public function testInfoWithInfoLevel()
{
$logger = $this->logger;
$logger->set_level(Tlog::INFO);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "foo"));
$logger->info("foo");
}
public function testInfoWitoutInfoLevel()
{
$logger = $this->logger;
$logger->set_level(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->info("foo");
}
public function testWarningWithWarningLevel()
{
$logger = $this->logger;
$logger->set_level(Tlog::WARNING);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "foo"));
$logger->warning("foo");
}
public function testWarningWitoutWarningLevel()
{
$logger = $this->logger;
$logger->set_level(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->warning("foo");
}
public function testErrorWithErrorLevel()
{
$logger = $this->logger;
$logger->set_level(Tlog::ERROR);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "foo"));
$logger->error("foo");
}
public function testErrorWitoutErrorLevel()
{
$logger = $this->logger;
$logger->set_level(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->error("foo");
}
public function testFatalWithFatalLevel()
{
$logger = $this->logger;
$logger->set_level(Tlog::FATAL);
//"#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "
$this->expectOutputRegex(sprintf($this->regex, "foo"));
$logger->fatal("foo");
}
public function testFatalWitoutFatalLevel()
{
$logger = $this->logger;
$logger->set_level(Tlog::MUET);
$this->expectOutputRegex("/^$/");
$logger->fatal("foo");
}
}
class ConfigModel
{
public function __call($name, $arguments) {
public function __call($name, $arguments)
{
return $arguments[1];
}
}
}

View File

@@ -32,34 +32,34 @@ class DIGeneratorTest extends \PHPUnit_Framework_TestCase
public function testGenDiModelWithoutModels()
{
$models = DIGenerator::genDiModel(__DIR__ . '/_filesEmpty');
$this->assertEmpty($models);
}
/**
* @covers DIGenerator::genDiModel
*/
public function testGenDiModelWithModels()
{
$models = DIGenerator::genDiModel(__DIR__ . '/_files');
$this->assertArrayHasKey("A", $models);
$this->assertArrayHasKey("B", $models);
$this->assertEquals("Thelia\Tests\Tools\_files\A", $models["A"]);
$this->assertCount(2, $models, "There is more than 2 models in this directory");
}
/**
* @covers DIGenerator::genDiModel
*/
public function testGenDiModelWithModelsAndExclusion()
{
$models = DIGenerator::genDiModel(__DIR__ . '/_files',array('B'));
$this->assertArrayHasKey("A", $models);
$this->assertCount(1, $models, "There is more than 2 models in this directory");
}
/**
* @expectedException RuntimeException
* @covers DIGenerator::genDiModel
@@ -67,7 +67,6 @@ class DIGeneratorTest extends \PHPUnit_Framework_TestCase
public function testGenDiModelWithWrongDirectory()
{
$models = DIGenerator::genDiModel(__DIR__ . '/wrongDirectory');
}
}

View File

@@ -2,6 +2,6 @@
namespace Thelia\Tests\Tools\_files;
class A {
class A
{
}

View File

@@ -4,5 +4,5 @@ namespace Thelia\Tests\Tools\_files;
class B
{
}