public function run() { $this->initDb(); /** @var Response $response */ $response = $this->router->dispatch($this->request->parseRequest()); $response->sendResponse(); }
/** @test */ public function executeFollowRequestToPinterestApi() { $response = $this->createSuccessApiResponse(); $mock = $this->getHttpMock(); $mock->shouldReceive('execute')->once()->andReturn(json_encode($response)); $mock->shouldReceive('execute')->once()->andReturnNull(); $this->setProperty('http', $mock); $this->assertEquals($response, $this->request->followMethodCall(1, Request::BOARD_ENTITY_ID, 'ur')); $this->assertNull($this->request->followMethodCall(1, Request::INTEREST_ENTITY_ID, 'ur')); }
public function testFollowMethodCall() { $response = $this->createSuccessApiResponse(); $mock = $this->getMock(Http::class, ['setOptions', 'execute', 'close']); $mock->expects($this->at(1))->method('execute')->willReturn(json_encode($response)); $mock->expects($this->at(2))->method('execute')->willReturn(null); $this->setProperty('http', $mock); $this->assertEquals($response, $this->request->followMethodCall(1, Request::BOARD_ENTITY_ID, 'ur')); $this->assertNull($this->request->followMethodCall(1, Request::INTEREST_ENTITY_ID, 'ur')); }
/** * @param array $record * @return array */ public function __invoke(array $record) { $request = $this->requestStack->getCurrentRequest(); if ($request === null) { $request = Request::createFromGlobals(); } $parts = ['command' => 'curl', 'headers' => implode(' ', $this->getHeaders()), 'url' => $request->getUri()]; if ($request->getMethod() !== 'GET') { $parts['data'] = '--data \'' . $request->getContent() . '\''; } if (!array_key_exists('extra', $record)) { $record['extra'] = []; } $record['extra']['requestAsCurl'] = implode(' ', $parts); return $record; }
/** * @covers \Project\Controller\ProjectController::searchAction */ public function testCanSearchProjects() { $this->routeMatch->setParam('action', 'search'); $queryParams = new Parameters(['search_item' => 'test', 'max_rows' => 12]); $this->request->setQuery($queryParams); $this->controller->dispatch($this->request, $this->response); $this->assertEquals(200, $this->controller->getResponse()->getStatusCode()); }
/** * @covers \Project\Controller\IdeaController::updateDescriptionAction */ public function testUpdateWrongIdeaDescriptionGives404() { $this->routeMatch->setParam('action', 'update-description'); $queryParams = new Parameters(['id' => 'description-0', 'value' => 'This is the new description']); $this->request->setPost($queryParams); $this->controller->dispatch($this->request, $this->response); $this->assertEquals(404, $this->controller->getResponse()->getStatusCode()); }
public function signOut() { if ($this->request) { $this->request->getSession()->clear(); return new RedirectResponse($this->request->getUri()); } return null; }
public function testFollowMethodCall() { $response = ['body' => 'result']; $mock = $this->getMock(Http::class, ['setOptions', 'execute', 'close']); $mock->expects($this->at(1))->method('execute')->willReturn(json_encode($response)); $mock->expects($this->at(2))->method('execute')->willReturn(null); $this->setProperty('http', $mock); $this->assertTrue($this->request->followMethodCall(1, Request::BOARD_ENTITY_ID, 'ur')); $this->assertFalse($this->request->followMethodCall(1, Request::INTEREST_ENTITY_ID, 'ur')); }