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

@@ -27,21 +27,5 @@ if(file_exists(__DIR__ . '/vendor/composer/autoload_classmap.php'))
$loader->addClassMap($classMap);
}
//
//$loader->addClassMap(array(
// 'NotORM' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM.php',
// 'NotORM_Cache_Session' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM/Cache.php',
// 'NotORM_Cache_File' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM/Cache.php',
// 'NotORM_Cache_Include' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM/Cache.php',
// 'NotORM_Cache_Database' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM/Cache.php',
// 'NotORM_Cache_Memcache' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM/Cache.php',
// 'NotORM_Cache_APC' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM/Cache.php',
// 'NotORM_Literal' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM/Literal.php',
// 'NotORM_MultiResult' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM/MultiResult.php',
// 'NotORM_Result' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM/Result.php',
// 'NotORM_Row' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM/Row.php',
// 'NotORM_Structure_Convention' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM/Structure.php',
// 'NotORM_Structure_Discovery' => THELIA_ROOT . '/core/vendor/vrana/notorm/NotORM/Structure.php',
//));
$loader->register();

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
{
}

View File

@@ -19,3 +19,4 @@ define('THELIA_DB_CACHE', 'file');
//define('THELIA_DB_CACHE', 'apc');
//define('THELIA_DB_CACHE', 'memcache');
//define('THELIA_DB_CACHE', 'session');
//define('THELIA_DB_CACHE', 'include');

View File

@@ -19,3 +19,4 @@ define('THELIA_DB_CACHE', 'file');
//define('THELIA_DB_CACHE', 'apc');
//define('THELIA_DB_CACHE', 'memcache');
//define('THELIA_DB_CACHE', 'session');
//define('THELIA_DB_CACHE', 'include');

View File

@@ -19,3 +19,4 @@ define('THELIA_DB_CACHE', 'file');
//define('THELIA_DB_CACHE', 'apc');
//define('THELIA_DB_CACHE', 'memcache');
//define('THELIA_DB_CACHE', 'session');
//define('THELIA_DB_CACHE', 'include');

View File

@@ -18,3 +18,4 @@ define('THELIA_DB_CACHE', 'file');
//define('THELIA_DB_CACHE', 'apc');
//define('THELIA_DB_CACHE', 'memcache');
//define('THELIA_DB_CACHE', 'session');
//define('THELIA_DB_CACHE', 'include');

13
phpunit.xml Normal file
View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
bootstrap="core/autoload.php"
verbose="true"
>
<testsuites>
<testsuite name="Thelia">
<directory>core/lib/Thelia/Tests</directory>
</testsuite>
</testsuites>
</phpunit>