Skip to content

Commit f47df71

Browse files
committed
support test
1 parent 85f6955 commit f47df71

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
"App\\": "app/"
77
}
88
},
9+
"autoload-dev": {
10+
"psr-4": {
11+
"Tests\\": "tests/"
12+
}
13+
},
914
"authors": [
1015
{
1116
"name": "liutao",
@@ -17,7 +22,8 @@
1722
"microphp/framework": "dev-master"
1823
},
1924
"require-dev": {
20-
"friendsofphp/php-cs-fixer": "^3.22.0"
25+
"friendsofphp/php-cs-fixer": "^3.22.0",
26+
"phpunit/phpunit": "^10.2"
2127
},
2228
"scripts": {
2329
"cs": [

phpunit.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="./bin/bootstrap.php"
5+
colors="true"
6+
>
7+
<testsuites>
8+
<testsuite name="Unit">
9+
<directory suffix="Test.php">./tests/Unit</directory>
10+
</testsuite>
11+
<testsuite name="Feature">
12+
<directory suffix="Test.php">./tests/Feature</directory>
13+
</testsuite>
14+
</testsuites>
15+
<source>
16+
<include>
17+
<directory suffix=".php">./app</directory>
18+
</include>
19+
</source>
20+
<php>
21+
<env name="APP_ENV" value="testing"/>
22+
</php>
23+
</phpunit>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Feature\Controller;
6+
7+
8+
use League\Route\Route;
9+
use League\Route\Router;
10+
use MicroPHP\Framework\Application;
11+
use MicroPHP\Framework\Testing\TestCase;
12+
use Psr\Container\ContainerExceptionInterface;
13+
use Psr\Container\NotFoundExceptionInterface;
14+
15+
class IndexTest extends TestCase
16+
{
17+
public function test_index()
18+
{
19+
$result = $this->get('http://127.0.0.1:8080')->assertOk();
20+
$this->assertSame('Hello World', $result->getContent());
21+
}
22+
}

0 commit comments

Comments
 (0)