public function testGetModifiedResponse() { $this->driver->expects($this->once())->method('getMax')->with(['foo', Keeper::LAST_UPDATE_KEY])->will($this->returnValue($this->time)); /** @var $request \PHPUnit_Framework_MockObject_MockObject|Request */ $request = $this->getMock(Request::class); /** @var $response \PHPUnit_Framework_MockObject_MockObject|Response */ $response = $this->getMock(Response::class); /** @var $configured_response \PHPUnit_Framework_MockObject_MockObject|Response */ $configured_response = $this->getMock(Response::class); $configured_response->expects($this->once())->method('isNotModified')->with($request)->will($this->returnValue(true)); $configured_response->expects($this->atLeastOnce())->method('getStatusCode')->will($this->returnValue(Response::HTTP_NOT_MODIFIED)); $this->configurator->expects($this->once())->method('configure')->with($response, $this->time)->will($this->returnValue($configured_response)); try { $this->keeper->getModifiedResponse($request, 'foo', -1, $response); $this->assertTrue(false, 'Must throw exception'); } catch (NotModifiedException $e) { $this->assertEquals($configured_response, $e->getResponse()); $this->assertEquals(Response::HTTP_NOT_MODIFIED, $e->getCode()); $this->assertEquals(Response::$statusTexts[Response::HTTP_NOT_MODIFIED], $e->getMessage()); } }
/** * Test remove the time by slow driver is failed. */ public function testRemoveFromSlowFail() { $this->fast_driver->expects($this->once())->method('remove')->with('foo')->will($this->returnValue(true)); $this->slow_driver->expects($this->once())->method('remove')->with('foo')->will($this->returnValue(false)); $this->assertFalse($this->driver->remove('foo')); }
/** * Reset last update date. * * @return \DateTime */ private function reset() { $time = new \DateTime(); $this->driver->set(self::LAST_UPDATE_KEY, $time); return $time; }