Skip to content

Commit ff6a1b6

Browse files
committed
update test case class
1 parent e4ff5a3 commit ff6a1b6

File tree

9 files changed

+60
-7
lines changed

9 files changed

+60
-7
lines changed

example/parse.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: inhere
5+
* Date: 2017/7/14
6+
* Time: 下午9:12
7+
*
8+
* you can test use:
9+
* php -S 127.0.0.1:5675 example/object.php
10+
*
11+
* then you can access url: http://127.0.0.1:5675
12+
*/
13+
14+
use Inhere\Route\Dispatcher\Dispatcher;
15+
use Inhere\Route\Example\Controllers\RestController;
16+
use Inhere\Route\ORouter;
17+
18+
require dirname(__DIR__) . '/test/boot.php';
19+
20+
function default_handler(array $args = []) {
21+
echo 'hello, welcome. you request URI: ' . $_SERVER['REQUEST_URI'];
22+
23+
var_dump($args);
24+
}
25+
26+
$router = new ORouter;
27+
28+
$router->get('/', 'default_handler');
29+
30+
$router->get('/user/info[/id/{int}]', 'default_handler');
31+
32+
$router->get('/my[/{name}[/{age}]]', 'default_handler', [
33+
'params' => [
34+
'age' => '\d+'
35+
],
36+
'defaults' => [
37+
'name' => 'God',
38+
'age' => 25,
39+
]
40+
]);
41+
42+
$router->dispatch();

php-run-with-debug.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
# profiler_enable - profiler功能的开关,默认值0,如果设为1,则每次请求都会生成一个性能报告文件。
4+
# export XDEBUG_CONFIG="profiler_enable=1"
5+
6+
# xdebug.profiler_enable_trigger 默认值也是0,如果设为1 则当我们的请求中包含 XDEBUG_PROFILE 参数时才会生成性能报告文件
7+
export XDEBUG_CONFIG="profiler_enable_trigger=1"
8+
9+
php $@

src/Base/AbstractRouter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public function rest(string $prefix, string $controllerClass, array $map = [], a
311311
/**
312312
* quick register a group universal routes for the controller class.
313313
* ```php
314-
* $router->rest('/users', UserController::class, [
314+
* $router->ctrl('/users', UserController::class, [
315315
* 'index' => 'get',
316316
* 'create' => 'post',
317317
* 'update' => 'post',

test/AbstractRouterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Inhere\Route\Base\AbstractRouter;
66

77
/**
8-
* @covers AbstractRouter
8+
* @covers \Inhere\Route\Base\AbstractRouter
99
*/
1010
class AbstractRouterTest extends TestCase
1111
{

test/DispatcherTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Inhere\Route\Dispatcher\Dispatcher;
66

77
/**
8-
* @covers Dispatcher
8+
* @covers \Inhere\Route\Dispatcher\Dispatcher
99
*/
1010
class DispatcherTest extends TestCase
1111
{

test/ORouterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Inhere\Route\ORouter;
66

77
/**
8-
* @covers ORouter
8+
* @covers \Inhere\Route\ORouter
99
*/
1010
class ORouterTest extends TestCase
1111
{

test/PreMatchRouterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
/**
1616
* Class PreMatchRouterTest
1717
* @package Inhere\Route\Test
18+
* @covers \Inhere\Route\PreMatchRouter
1819
*/
1920
class PreMatchRouterTest extends TestCase
2021
{
@@ -55,4 +56,4 @@ public function testRouteCacheExists()
5556
$this->assertSame($p, $path);
5657
$this->assertSame('handler1', $route['handler']);
5758
}
58-
}
59+
}

test/SRouterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Inhere\Route\SRouter;
77

88
/**
9-
* @covers SRouter
9+
* @covers \Inhere\Route\SRouter
1010
*/
1111
class SRouterTest extends TestCase
1212
{

test/ServerRouterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
/**
1616
* Class ServerRouterTest
1717
* @package Inhere\Route\Test
18+
* @covers \Inhere\Route\ServerRouter
1819
*/
1920
class ServerRouterTest extends TestCase
2021
{
@@ -55,4 +56,4 @@ public function testRouteCacheExists()
5556
$this->assertSame('handler3', $route['handler']);
5657
}
5758

58-
}
59+
}

0 commit comments

Comments
 (0)