From c4d0e097fb68e533d1283818604f0ddb19331c68 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 28 Feb 2016 15:37:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=B7=AF=E7=94=B1=E7=B1=BB?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/thinkphp/library/think/routeTest.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/thinkphp/library/think/routeTest.php b/tests/thinkphp/library/think/routeTest.php index 07b994e7..337e142d 100644 --- a/tests/thinkphp/library/think/routeTest.php +++ b/tests/thinkphp/library/think/routeTest.php @@ -25,10 +25,23 @@ class routeTest extends \PHPUnit_Framework_TestCase { Route::get('hello/:name', 'index/hello'); Route::get(['hello/:name' => 'index/hello']); + Route::post('hello/:name', 'index/post'); + Route::put('hello/:name', 'index/put'); + Route::delete('hello/:name', 'index/delete'); + Route::any('user/:id', 'index/user'); $this->assertEquals(['type' => 'module', 'module' => [null, 'index', 'hello']], Route::check('hello/thinkphp')); $this->assertEquals(['hello/:name' => ['route' => 'index/hello', 'option' => [], 'pattern' => []]], Route::getRules('GET')); } + public function testResource() + { + Route::resource('res', 'index/blog'); + $this->assertEquals(['type' => 'module', 'module' => ['index', 'blog', 'index']], Route::check('res')); + $this->assertEquals(['type' => 'module', 'module' => ['index', 'blog', 'create']], Route::check('res/create')); + $this->assertEquals(['type' => 'module', 'module' => ['index', 'blog', 'read']], Route::check('res/8')); + $this->assertEquals(['type' => 'module', 'module' => ['index', 'blog', 'edit']], Route::check('res/8/edit')); + } + public function testRouteMap() { Route::map('hello', 'index/hello'); @@ -52,7 +65,7 @@ class routeTest extends \PHPUnit_Framework_TestCase $this->assertEquals(false, Route::check('test/thinkphp')); $this->assertEquals(false, Route::check('blog/thinkphp')); $this->assertEquals(['type' => 'module', 'module' => [null, 'blog', 'read']], Route::check('blog/5')); - $this->assertEquals(['type' => 'module', 'module' => [null, 'index', 'hello']], Route::check('hello/thinkphp')); + $this->assertEquals(['type' => 'module', 'module' => [null, 'index', 'hello']], Route::check('hello/thinkphp/abc/test')); } public function testCheckRouteGroup()