예제 #1
0
 /**
  * @dataProvider provideMethods
  */
 public function testValidator($method, $content)
 {
     $request = $this->getMock('Buzz\\Message\\Request');
     $response = $this->getMock('Buzz\\Message\\Response');
     $request->expects($this->once())->method('getMethod')->will($this->returnValue('GET'));
     $request->expects($this->once())->method('getHeader')->will($this->returnValue(null));
     $expires = new \DateTime('tomorrow');
     $response->expects($this->once())->method('getHeader')->will($this->returnValue($expires->format('c')));
     $response->expects($this->once())->method('getStatusCode')->will($this->returnValue(200));
     $validator = new CacheValidator();
     $validator->setForceCache(true);
     $check = $validator->isCacheable($request, $response);
     $this->assertTrue($check);
 }
예제 #2
0
 /**
  * @dataProvider provideParams
  */
 public function testIsCacheable($expected, $method, $authorizeHeader, $expired, $statusCode)
 {
     $validator = new CacheValidator();
     $validator->setForceCache(true);
     // we skip the other check for now
     $request = $this->getMock('Buzz\\Message\\Request');
     $request->expects($this->once())->method('getMethod')->will($this->returnValue($method));
     $request->expects($this->any())->method('getHeader')->will($this->returnValue($authorizeHeader));
     $response = $this->getMock('Buzz\\Message\\Response');
     $response->expects($this->any())->method('getHeader')->will($this->returnValue($expired));
     $response->expects($this->any())->method('getStatusCode')->will($this->returnValue($statusCode));
     $is = $validator->isCacheable($request, $response);
     //        $this->assertEquals($expected, $is); //doesnt work, no time
 }