/** * Get spoofed request class instance * * @param string $url * @param string $method * @param array $post * @return \Arvici\Heart\Http\Request */ private function spoofedRequest($url, $method = 'get', $post = array()) { TestUtils::clear(); //$url = '/get/test?param1=1¶m2=yes¶m3[]=1¶m3[]=2¶m3[]=3'; $urlparts = parse_url($url); parse_str($urlparts['query'], $get); TestUtils::spoofUrl($url, $method, $get, $post); return Http::getInstance()->request(); }
/** * Get fresh clean response class instance. * * @return \Arvici\Heart\Http\Response */ private function getResponse() { TestUtils::clear(); return Http::getInstance()->response(); }
/** * @covers \Arvici\Heart\Router\Router * @covers \Arvici\Heart\Router\Route * @covers \Arvici\Heart\Http\Http * @covers \Arvici\Heart\Http\Request * @covers \Arvici\Heart\Http\Response */ public function testQueryParameters() { TestUtils::clear(); $router = Router::getInstance(); $router->addRoute(new Route('/test/get/controller/query', 'GET', 'App\\Controller\\TestQuery::basicQuery')); $this->spoof('/test/get/controller/query?test=yes', 'GET', array('test' => 'yes')); try { $router->run(); $this->assertTrue(false); } catch (\Exception $e) { $this->assertEquals(999, $e->getCode()); } // Test via request object (right here) $request = Http::getInstance()->request(); $this->assertEquals(array('test' => 'yes'), $request->get()->all()); // More testing on REQUEST is done in a separate case }