Skip to content

Commit 92d84f3

Browse files
committed
Install PHPUnit for UnitTesting
1 parent 4cacb41 commit 92d84f3

File tree

7 files changed

+1012
-7
lines changed

7 files changed

+1012
-7
lines changed

app/tests/Framadate/FramaTestCase.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
namespace Framadate;
3+
4+
abstract class FramaTestCase extends \PHPUnit_Framework_TestCase {
5+
6+
protected function getTestResourcePath($resourcepath) {
7+
return __DIR__ . '/../resources/'.$resourcepath;
8+
}
9+
10+
protected function readTestResource($resourcepath) {
11+
return file_get_contents($this->getTestResourcePath($resourcepath));
12+
}
13+
14+
protected function invoke(&$object, $methodName) {
15+
$reflectionClass = new \ReflectionClass($object);
16+
$reflectionMethod = $reflectionClass->getMethod($methodName);
17+
$reflectionMethod->setAccessible(true);
18+
19+
$params = array_slice(func_get_args(), 2); // get all the parameters after $methodName
20+
return $reflectionMethod->invokeArgs($object, $params);
21+
}
22+
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
namespace Framadate\Services;
3+
4+
use Framadate\FramaTestCase;
5+
6+
class MailServiceUnitTest extends FramaTestCase {
7+
8+
/**
9+
* @test
10+
*/
11+
function cconstruct() {
12+
$this->assertEquals('a', 'a');
13+
}
14+
15+
}

app/tests/bootstrap.php

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

composer.json

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"o80/i18n": "dev-develop"
1515
},
1616

17+
"require-dev": {
18+
"phpunit/phpunit": "^4.5"
19+
},
20+
1721
"autoload": {
1822
"psr-4": {
1923
"Framadate\\": "app/classes/Framadate/"

0 commit comments

Comments
 (0)