public function testSendCachedWithoutCacheMakesRequest() { $cacheKey = 'CACHE_KEY'; $cacheFor = 100; $body = 'BODY'; $this->cachedRequestMock->expects($this->any())->method('getCacheKey')->willReturn($cacheKey); $this->cachedRequestMock->expects($this->once())->method('getCacheFor')->willReturn($cacheFor); $this->httpResponseMock->expects($this->any())->method('getBody')->willReturn($body); $this->guzzleClientMock->expects($this->once())->method('createRequest')->willReturn($this->guzzleRequestMock); $this->guzzleClientMock->expects($this->once())->method('send')->willReturn($this->httpResponseMock); $this->memcacheMock->expects($this->once())->method('get')->with($cacheKey)->willReturn(false); $this->memcacheMock->expects($this->once())->method('set')->with($cacheKey, $body, 0, $cacheFor); $client = new ClientCached($this->guzzleClientMock, $this->memcacheMock); $this->assertSame($body, $client->sendCached($this->cachedRequestMock)); }