/** * @runInSeparateProcess */ function testAction() { $_SERVER['REQUEST_METHOD'] = 'GET'; $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['REQUEST_URI'] = '/hello'; $this->assertNotTrue(Route::action('GET', '/nothello', function () { return new Response(); })); $this->assertNotTrue(Route::action('GET', '/me/hello', function () { return new Response(); })); $this->assertNotTrue(Route::action('GET', '/hello/me', function () { return new Response(); })); $this->assertTrue(Route::action('GET', '/hello', function () { return new Response(); })); $this->assertNotTrue(Route::action('GET', '/hello', function () { return new Response(); })); Route::reset(); $_SERVER['REQUEST_URI'] = '/hello?a=b'; $this->assertTrue(Route::action('GET', '/hello', function () { return new Response(); })); Route::reset(); }
<?php use Framework\Route; Route::action('GET', '/welcome', function () { echo "welcome"; }); Route::action('GET', '/hello', 'SampleController@hello');