write firts unit test with phpunit

This commit is contained in:
Manuel Raynaud
2012-12-21 17:33:06 +01:00
parent e1a756405d
commit 4bcdf2479a
9 changed files with 77 additions and 18 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace Thelia\Tests\Tools;
use Thelia\Tools\DIGenerator;
class DIGeneratorTest extends \PHPUnit_Framework_TestCase
{
public function testGenDiModelWithoutModels()
{
$models = DIGenerator::genDiModel(__DIR__ . '/_filesEmpty');
$this->assertEmpty($models);
}
public function testGenDiModelWithModels()
{
$models = DIGenerator::genDiModel(__DIR__ . '/_files');
$this->assertArrayHasKey("A", $models);
$this->assertArrayHasKey("B", $models);
$this->assertCount(2, $models, "There is more than 2 models in this directory");
}
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
*/
public function testGenDiModelWithWrongDirectory()
{
$models = DIGenerator::genDiModel(__DIR__ . '/wrongDirectory');
}
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Thelia\Tests\Tools\_files;
class A {
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Thelia\Tests\Tools\_files;
class B
{
}