1
0
mirror of https://github.com/moparisthebest/wallabag synced 2024-12-18 05:32:23 -05:00

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'
This commit is contained in:
Vincent Jousse 2013-11-21 20:15:42 +01:00
parent 9bfeaf9cc0
commit f502810f43
6 changed files with 44 additions and 4 deletions

View File

@ -7,6 +7,6 @@
"knplabs/console-service-provider": "dev-master" "knplabs/console-service-provider": "dev-master"
}, },
"autoload": { "autoload": {
"psr-0": { "Poche": "src/" } "psr-0": { "Poche\\": "src/" }
} }
} }

View File

@ -26,8 +26,9 @@ class UnitTestsCommand extends BaseCommand
{ {
$atoum = $this->getProjectDirectory().'/vendor/bin/atoum'; $atoum = $this->getProjectDirectory().'/vendor/bin/atoum';
$unitTests = $this->getProjectDirectory().'/tests'; $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; return $status;
} }

16
src/Poche/Model/Entry.php Normal file
View File

@ -0,0 +1,16 @@
<?php
namespace Poche\Model;
class Entry
{
public function __construct($id, $title) {
$this->id = $id;
$this->title = $title;
}
public function getId() {
return $this->id;
}
}

View File

@ -1,5 +1,9 @@
<?php <?php
use Poche\Model\Entry;
$app->get('/', function () use ($app) { $app->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));
}); });

View File

@ -1 +1,2 @@
Poche v2 Poche v2<br/>
{{ entry.id }} - {{ entry.title }}

18
tests/unit/Entry.php Normal file
View File

@ -0,0 +1,18 @@
<?php
namespace tests\unit;
use \atoum;
class Entry extends atoum
{
public function testGetId()
{
$entry = new Poche\Model\Entry();
$this
->integer($entry->getId())
->isEqualTo('Test')
;
}
}