From 4bcdf2479a2d111358fbf6a465e0b285284ba48e Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 21 Dec 2012 17:33:06 +0100 Subject: [PATCH] write firts unit test with phpunit --- core/autoload.php | 16 ------- .../Thelia/Tests/Tools/DIGeneratorTest.php | 43 +++++++++++++++++++ core/lib/Thelia/Tests/Tools/_files/A.php | 7 +++ core/lib/Thelia/Tests/Tools/_files/B.php | 8 ++++ local/config/config_db.mysql.php | 1 + local/config/config_db.oracle.php | 1 + local/config/config_db.pgsql.php | 3 +- local/config/config_db.sqlite.php | 3 +- phpunit.xml | 13 ++++++ 9 files changed, 77 insertions(+), 18 deletions(-) create mode 100644 core/lib/Thelia/Tests/Tools/DIGeneratorTest.php create mode 100644 core/lib/Thelia/Tests/Tools/_files/A.php create mode 100644 core/lib/Thelia/Tests/Tools/_files/B.php create mode 100644 phpunit.xml diff --git a/core/autoload.php b/core/autoload.php index 0ca1f5399..91cdc216c 100644 --- a/core/autoload.php +++ b/core/autoload.php @@ -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(); diff --git a/core/lib/Thelia/Tests/Tools/DIGeneratorTest.php b/core/lib/Thelia/Tests/Tools/DIGeneratorTest.php new file mode 100644 index 000000000..6dde74625 --- /dev/null +++ b/core/lib/Thelia/Tests/Tools/DIGeneratorTest.php @@ -0,0 +1,43 @@ +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'); + + + } +} diff --git a/core/lib/Thelia/Tests/Tools/_files/A.php b/core/lib/Thelia/Tests/Tools/_files/A.php new file mode 100644 index 000000000..f116cbd52 --- /dev/null +++ b/core/lib/Thelia/Tests/Tools/_files/A.php @@ -0,0 +1,7 @@ + + + + + + core/lib/Thelia/Tests + + +