write firts unit test with phpunit
This commit is contained in:
43
core/lib/Thelia/Tests/Tools/DIGeneratorTest.php
Normal file
43
core/lib/Thelia/Tests/Tools/DIGeneratorTest.php
Normal 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');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
7
core/lib/Thelia/Tests/Tools/_files/A.php
Normal file
7
core/lib/Thelia/Tests/Tools/_files/A.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Tests\Tools\_files;
|
||||
|
||||
class A {
|
||||
|
||||
}
|
||||
8
core/lib/Thelia/Tests/Tools/_files/B.php
Normal file
8
core/lib/Thelia/Tests/Tools/_files/B.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Thelia\Tests\Tools\_files;
|
||||
|
||||
class B
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user