Add Unit Test example
This commit is contained in:
27
web/app/phpunit.xml.dist
Normal file
27
web/app/phpunit.xml.dist
Normal 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
11
web/app/src/Foo.php
Normal 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
15
web/app/test/FooTest.php
Normal 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');
|
||||
}
|
||||
}
|
||||
8
web/app/test/bootstrap.php
Normal file
8
web/app/test/bootstrap.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
|
||||
/**
|
||||
* Setup autoloading
|
||||
*/
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
Reference in New Issue
Block a user