Пример #1
0
 public function run()
 {
     /**
      * @var $request Request
      */
     $request = Request::getInstance();
     $request->checkRequest();
     //        $request->checkSign();
     $actionFactory = new ActionFactory();
     $action = $actionFactory->getAction($request->_action);
     $action->run();
 }
Пример #2
0
 private function getReceiptInformation()
 {
     $this->_receipt = $this->_provider->getReceiptInformation(Request::getInstance());
 }
Пример #3
0
 private function initCallback()
 {
     $this->_provider->initCallback(Request::getInstance());
 }
Пример #4
0
 /**
  * @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());
 }
Пример #5
0
 /**
  * @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;
 }
Пример #6
0
 public function isMatch(Request $request)
 {
     if (preg_match($this->getParsedUri(), $request->getPath(), $matches)) {
         $this->bindValues($matches);
         return true;
     }
     return false;
 }
Пример #7
0
 /**
  * @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");
 }
Пример #8
0
 /**
  * @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);
 }
Пример #9
0
 private function isCorrectAmount()
 {
     return $this->_provider->isCorrectAmount(Request::getInstance());
 }