public function testDispatch() { $changedRequest = $this->createRequest('GET', '/'); $changedRequest->shouldReceive('getAttribute')->once()->with('cookie', [])->andReturn(['name' => 'wan2land']); $request = $this->createRequest('GET', '/'); $request->shouldReceive('withAttribute')->once()->with('cookie', ['name' => 'wan2land'])->andReturn($changedRequest); $route = new Route(TestIssue1Controller::class, 'login', [TestIssue1Middleware::class]); $response = $route->execute($request, new DefaultLoader(), new WanduResponsifier()); $this->assertEquals('login@Issue1, cookie={"name":"wan2land"}', $response->getBody()->__toString()); }
public function testExecuteWithPreventedMiddleware() { $route = new Route(TestRouteController::class, 'index', [TestAuthFailMiddleware::class]); $request = $this->createRequest('GET', '/'); ob_start(); $response = $route->execute($request, null, new WanduResponsifier()); $contents = ob_get_contents(); ob_end_clean(); $this->assertEquals('', $contents); $this->assertInstanceOf(ResponseInterface::class, $response); $this->assertEquals('Fail...', $response->getBody()->__toString()); }