public function run() { /** * @var $request Request */ $request = Request::getInstance(); $request->checkRequest(); // $request->checkSign(); $actionFactory = new ActionFactory(); $action = $actionFactory->getAction($request->_action); $action->run(); }
private function getReceiptInformation() { $this->_receipt = $this->_provider->getReceiptInformation(Request::getInstance()); }
private function initCallback() { $this->_provider->initCallback(Request::getInstance()); }
/** * @covers \Core\Request\Request::json * @covers \Core\Request\Request::isJson */ public function testJsonAndIsJsonMethod() { $request = Request::create('http://example.com/somePath', 'GET', [], ['CONTENT_TYPE' => 'application/json; charset=utf-8'], [], [], '{"data": "value"}'); $this->assertSame('value', $request->json('data')); $this->assertTrue($request->isJson()); }
/** * @return RequestInterface * @throws \ErrorException */ public function getRequest() { if (!isset($this->request)) { if ($this->serviceExists('Request')) { $this->request = $this->get('Request'); } else { $this->setRequest(Request::createFromGlobals()); $this->register('Request', $this->request); } } return $this->request; }
public function isMatch(Request $request) { if (preg_match($this->getParsedUri(), $request->getPath(), $matches)) { $this->bindValues($matches); return true; } return false; }
/** * @covers \Core\Application\BaseApplication::run * @covers \Core\Application\BaseApplication::setRequest * @covers \Core\Request\Request::create * @covers \Core\Facade\Router::get */ public function testIfControllersCanReturnView() { MockPaths::createMockPaths(); $app = new Application(MockPaths::$basePath); Router::get('/user/{name}', '\\Core\\Tests\\Stubs\\Controllers\\StubController@testReturnView'); $app->setRequest(Request::create('http://example.com/user/sam')); $app->run(); $this->assertTrue(headers_sent()); $this->expectOutputString("Hello sam"); }
/** * @covers \Core\Router\Router::any */ public function testAnyMethod() { // GET $router = $this->getRouter(); $router->any('/page/{id}', function ($payload) { return $payload['id']; }); $response = $router->handle(Request::create('http://example.com/page/somePage')); $this->assertSame('somePage', $response); // POST $router = $this->getRouter(); $router->any('/page/{id}', function ($payload) { return $payload['id']; }); $response = $router->handle(Request::create('http://example.com/page/somePage', 'POST')); $this->assertSame('somePage', $response); // PUT $router = $this->getRouter(); $router->any('/page/{id}', function ($payload) { return $payload['id']; }); $response = $router->handle(Request::create('http://example.com/page/somePage', 'PUT')); $this->assertSame('somePage', $response); // PATCH $router = $this->getRouter(); $router->any('/page/{id}', function ($payload) { return $payload['id']; }); $response = $router->handle(Request::create('http://example.com/page/somePage', 'PATCH')); $this->assertSame('somePage', $response); // DELETE $router = $this->getRouter(); $router->any('/page/{id}', function ($payload) { return $payload['id']; }); $response = $router->handle(Request::create('http://example.com/page/somePage', 'DELETE')); $this->assertSame('somePage', $response); // OPTIONS $router = $this->getRouter(); $router->any('/page/{id}', function ($payload) { return $payload['id']; }); $response = $router->handle(Request::create('http://example.com/page/somePage', 'OPTIONS')); $this->assertSame('somePage', $response); }
private function isCorrectAmount() { return $this->_provider->isCorrectAmount(Request::getInstance()); }