mirror of
https://framagit.org/framasoft/framadate/framadate
synced 2026-01-22 18:04:15 +00:00
Install PHPUnit for UnitTesting
This commit is contained in:
parent
4cacb412c6
commit
92d84f3193
7 changed files with 1012 additions and 7 deletions
23
app/tests/Framadate/FramaTestCase.php
Normal file
23
app/tests/Framadate/FramaTestCase.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
15
app/tests/Framadate/Services/MailServiceUnitTest.php
Normal file
15
app/tests/Framadate/Services/MailServiceUnitTest.php
Normal 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
3
app/tests/bootstrap.php
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
$loader = require __DIR__ . '/../../vendor/autoload.php';
|
||||
$loader->addPsr4('Framadate\\', __DIR__.'/Framadate');
|
||||
|
|
@ -14,6 +14,10 @@
|
|||
"o80/i18n": "dev-develop"
|
||||
},
|
||||
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.5"
|
||||
},
|
||||
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Framadate\\": "app/classes/Framadate/"
|
||||
|
|
|
|||
972
composer.lock
generated
972
composer.lock
generated
File diff suppressed because it is too large
Load diff
1
phpunit.bat
Normal file
1
phpunit.bat
Normal file
|
|
@ -0,0 +1 @@
|
|||
vendor\bin\phpunit.bat --bootstrap app\tests\bootstrap.php app/tests
|
||||
1
phpunit.sh
Normal file
1
phpunit.sh
Normal file
|
|
@ -0,0 +1 @@
|
|||
vendor\bin\phpunit --bootstrap app\tests\bootstrap.php app/tests
|
||||
Loading…
Add table
Add a link
Reference in a new issue