From f502810f43438c338bdde88b0ac60359b582b57b Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Thu, 21 Nov 2013 20:15:42 +0100 Subject: [PATCH] Trying to test a dummy Entry class It seems that Atoum doesn't find the class to be tested when running `./console tests:unit` ==> Error E_USER_ERROR in /home/vjousse/usr/src/php/poche/tests/unit/Entry.php on unknown line, generated by unknown file: Tested class 'Entry' does not exist for test class 'tests\unit\Entry' --- composer.json | 2 +- src/Poche/Command/UnitTestsCommand.php | 3 ++- src/Poche/Model/Entry.php | 16 ++++++++++++++++ src/controllers.php | 6 +++++- src/views/index.twig | 3 ++- tests/unit/Entry.php | 18 ++++++++++++++++++ 6 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 src/Poche/Model/Entry.php create mode 100644 tests/unit/Entry.php diff --git a/composer.json b/composer.json index adfeed6..dcb639b 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,6 @@ "knplabs/console-service-provider": "dev-master" }, "autoload": { - "psr-0": { "Poche": "src/" } + "psr-0": { "Poche\\": "src/" } } } diff --git a/src/Poche/Command/UnitTestsCommand.php b/src/Poche/Command/UnitTestsCommand.php index 81fa809..f6f20e5 100644 --- a/src/Poche/Command/UnitTestsCommand.php +++ b/src/Poche/Command/UnitTestsCommand.php @@ -26,8 +26,9 @@ class UnitTestsCommand extends BaseCommand { $atoum = $this->getProjectDirectory().'/vendor/bin/atoum'; $unitTests = $this->getProjectDirectory().'/tests'; + $bootstrapFile = $this->getProjectDirectory().'/tests/bootstrap.php'; - passthru(sprintf('%s -d %s -ft', $atoum, $unitTests), $status); + passthru(sprintf('%s -d %s -bf %s -ft', $atoum, $unitTests, $bootstrapFile), $status); return $status; } diff --git a/src/Poche/Model/Entry.php b/src/Poche/Model/Entry.php new file mode 100644 index 0000000..6e5f950 --- /dev/null +++ b/src/Poche/Model/Entry.php @@ -0,0 +1,16 @@ +id = $id; + $this->title = $title; + } + + public function getId() { + return $this->id; + } + +} diff --git a/src/controllers.php b/src/controllers.php index 04e9378..410f9b7 100644 --- a/src/controllers.php +++ b/src/controllers.php @@ -1,5 +1,9 @@ get('/', function () use ($app) { - return $app['twig']->render('index.twig'); + + $entry = new Entry(1, "Titre de test"); + + return $app['twig']->render('index.twig', array('entry' => $entry)); }); diff --git a/src/views/index.twig b/src/views/index.twig index 0b0e0df..d7b17aa 100644 --- a/src/views/index.twig +++ b/src/views/index.twig @@ -1 +1,2 @@ -Poche v2 +Poche v2
+{{ entry.id }} - {{ entry.title }} diff --git a/tests/unit/Entry.php b/tests/unit/Entry.php new file mode 100644 index 0000000..329b3b7 --- /dev/null +++ b/tests/unit/Entry.php @@ -0,0 +1,18 @@ +integer($entry->getId()) + ->isEqualTo('Test') + ; + } +}