Install PHPUnit for UnitTesting

This commit is contained in:
Olivier PEREZ 2015-05-29 17:05:26 +02:00
parent 4cacb412c6
commit 92d84f3193
7 changed files with 1012 additions and 7 deletions

View File

@ -0,0 +1,23 @@
<?php
namespace Framadate;
abstract class FramaTestCase extends \PHPUnit_Framework_TestCase {
protected function getTestResourcePath($resourcepath) {
return __DIR__ . '/../resources/'.$resourcepath;
}
protected function readTestResource($resourcepath) {
return file_get_contents($this->getTestResourcePath($resourcepath));
}
protected function invoke(&$object, $methodName) {
$reflectionClass = new \ReflectionClass($object);
$reflectionMethod = $reflectionClass->getMethod($methodName);
$reflectionMethod->setAccessible(true);
$params = array_slice(func_get_args(), 2); // get all the parameters after $methodName
return $reflectionMethod->invokeArgs($object, $params);
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace Framadate\Services;
use Framadate\FramaTestCase;
class MailServiceUnitTest extends FramaTestCase {
/**
* @test
*/
function cconstruct() {
$this->assertEquals('a', 'a');
}
}

3
app/tests/bootstrap.php Normal file
View File

@ -0,0 +1,3 @@
<?php
$loader = require __DIR__ . '/../../vendor/autoload.php';
$loader->addPsr4('Framadate\\', __DIR__.'/Framadate');

View File

@ -14,6 +14,10 @@
"o80/i18n": "dev-develop" "o80/i18n": "dev-develop"
}, },
"require-dev": {
"phpunit/phpunit": "^4.5"
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Framadate\\": "app/classes/Framadate/" "Framadate\\": "app/classes/Framadate/"

972
composer.lock generated

File diff suppressed because it is too large Load Diff

1
phpunit.bat Normal file
View File

@ -0,0 +1 @@
vendor\bin\phpunit.bat --bootstrap app\tests\bootstrap.php app/tests

1
phpunit.sh Normal file
View File

@ -0,0 +1 @@
vendor\bin\phpunit --bootstrap app\tests\bootstrap.php app/tests