/** * @test */ public function setCachedValueForRequestTest() { $response = new \Bullet\Response(); $response->content('Test content'); $uri = 'MyAliasedModel'; $request = $this->buildRequestWithUri($uri); $this->fixture->setCachedValueForRequest($request, $response); $cachedResponse = $this->fixture->getCachedValueForRequest($request); $this->assertInstanceOf('Bullet\\Response', $cachedResponse); $this->assertEquals('Test content', $cachedResponse); }
/** * Send HTTP response with status code and content */ public function response($statusCode = null, $content = null) { $res = null; // Get current response (passed nothing) if ($statusCode === null) { $res = $this->_response; // Set response } elseif ($statusCode instanceof \Bullet\Response) { $res = $this->_response = $statusCode; } // Create new response if none is going to be returned if ($res === null) { $res = new \Bullet\Response($content, $statusCode); // If content not set, use default HTTP if ($content === null) { $res->content($res->statusText($statusCode)); } } // Ensure no response body is sent for special status codes or for HEAD requests if (in_array($res->status(), array(204, 205, 304)) || $this->request()->method() === 'HEAD') { $res->content(''); } // If this is the first response sent, store it if ($this->_response === null) { $this->_response = $res; } return $res; }
/** * @test */ public function setCachedValueForRequestTest() { $response = new \Bullet\Response(); $response->content('Test content'); $uri = 'MyAliasedModel'; $request = $this->buildRequestWithUri($uri); /** @var \TYPO3\CMS\Core\Cache\Frontend\VariableFrontend|\PHPUnit_Framework_MockObject_MockObject $cacheInstance */ $cacheInstance = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\AbstractFrontend', array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', FALSE); $cacheInstance->expects($this->atLeastOnce())->method('set')->will($this->returnValue('')); $this->fixture->setCacheInstance($cacheInstance); $this->fixture->setCachedValueForRequest($request, $response); }