write firts unit test with phpunit
This commit is contained in:
@@ -27,21 +27,5 @@ if(file_exists(__DIR__ . '/vendor/composer/autoload_classmap.php'))
|
|||||||
|
|
||||||
$loader->addClassMap($classMap);
|
$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();
|
$loader->register();
|
||||||
|
|||||||
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
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,3 +19,4 @@ define('THELIA_DB_CACHE', 'file');
|
|||||||
//define('THELIA_DB_CACHE', 'apc');
|
//define('THELIA_DB_CACHE', 'apc');
|
||||||
//define('THELIA_DB_CACHE', 'memcache');
|
//define('THELIA_DB_CACHE', 'memcache');
|
||||||
//define('THELIA_DB_CACHE', 'session');
|
//define('THELIA_DB_CACHE', 'session');
|
||||||
|
//define('THELIA_DB_CACHE', 'include');
|
||||||
|
|||||||
@@ -19,3 +19,4 @@ define('THELIA_DB_CACHE', 'file');
|
|||||||
//define('THELIA_DB_CACHE', 'apc');
|
//define('THELIA_DB_CACHE', 'apc');
|
||||||
//define('THELIA_DB_CACHE', 'memcache');
|
//define('THELIA_DB_CACHE', 'memcache');
|
||||||
//define('THELIA_DB_CACHE', 'session');
|
//define('THELIA_DB_CACHE', 'session');
|
||||||
|
//define('THELIA_DB_CACHE', 'include');
|
||||||
|
|||||||
@@ -18,4 +18,5 @@ define('THELIA_DB_DSN','pgsql:host=__DB_HOST__;port=__DB_PORT__;dbname=__DB_NAME
|
|||||||
define('THELIA_DB_CACHE', 'file');
|
define('THELIA_DB_CACHE', 'file');
|
||||||
//define('THELIA_DB_CACHE', 'apc');
|
//define('THELIA_DB_CACHE', 'apc');
|
||||||
//define('THELIA_DB_CACHE', 'memcache');
|
//define('THELIA_DB_CACHE', 'memcache');
|
||||||
//define('THELIA_DB_CACHE', 'session');
|
//define('THELIA_DB_CACHE', 'session');
|
||||||
|
//define('THELIA_DB_CACHE', 'include');
|
||||||
@@ -17,4 +17,5 @@ define('THELIA_DB_DSN','sqlite:__DB_FILE__');
|
|||||||
define('THELIA_DB_CACHE', 'file');
|
define('THELIA_DB_CACHE', 'file');
|
||||||
//define('THELIA_DB_CACHE', 'apc');
|
//define('THELIA_DB_CACHE', 'apc');
|
||||||
//define('THELIA_DB_CACHE', 'memcache');
|
//define('THELIA_DB_CACHE', 'memcache');
|
||||||
//define('THELIA_DB_CACHE', 'session');
|
//define('THELIA_DB_CACHE', 'session');
|
||||||
|
//define('THELIA_DB_CACHE', 'include');
|
||||||
13
phpunit.xml
Normal file
13
phpunit.xml
Normal 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>
|
||||||
Reference in New Issue
Block a user