Add Unit Test example

This commit is contained in:
Vincent Letourneau
2017-01-23 11:04:43 +01:00
parent 394d2d360e
commit 0c081d7fc9
4 changed files with 61 additions and 0 deletions

27
web/app/phpunit.xml.dist Normal file
View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="test/bootstrap.php"
colors="true">
<testsuites>
<testsuite name="PHP Test suite">
<directory>./test/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="false">
<directory suffix=".php">./src</directory>
<exclude>
<directory suffix=".php">./vendor</directory>
</exclude>
</whitelist>
</filter>
<php>
<ini name="date.timezone" value="UTC"/>
</php>
</phpunit>

11
web/app/src/Foo.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
namespace App\Acme;
class Foo
{
public function getName()
{
return 'Nginx PHP MySQL';
}
}

15
web/app/test/FooTest.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
namespace AppTest\Acme;
use App\Acme\Foo;
use PHPUnit\Framework\TestCase;
class FooTest extends TestCase
{
public function testGetName()
{
$foo = new Foo();
$this->assertEquals($foo->getName(), 'Nginx PHP MySQL');
}
}

View File

@@ -0,0 +1,8 @@
<?php
error_reporting(E_ALL | E_STRICT);
/**
* Setup autoloading
*/
require __DIR__ . '/../vendor/autoload.php';