コード例 #1
0
 public function testCachesResponsesWhenCacheable()
 {
     $cache = new ArrayCache();
     $plugin = new CachePlugin($cache);
     $request = new Request('GET', 'http://foo.com');
     $response = new Response(200, array(), 'Foo');
     $plugin->onRequestBeforeSend(new Event(array('request' => $request)));
     $plugin->onRequestSent(new Event(array('request' => $request, 'response' => $response)));
     $data = $this->readAttribute($cache, 'data');
     $this->assertNotEmpty($data);
 }
コード例 #2
0
 public function testCachesResponsesWhenCacheable()
 {
     $cache = new ArrayCache();
     $adapter = new DoctrineCacheAdapter($cache);
     $plugin = new CachePlugin(array('adapter' => $adapter));
     $request = new Request('GET', 'http://foo.com');
     $response = new Response(200, array(), 'Foo');
     $plugin->onRequestBeforeSend(new Event(array('request' => $request)));
     $plugin->onRequestSent(new Event(array('request' => $request, 'response' => $response)));
     $data = $this->readAttribute($cache, 'data');
     $this->assertNotEmpty($data);
     $data = end($data);
     $this->assertEquals(200, $data[0]);
     $this->assertInternalType('array', $data[1]);
     $this->assertEquals('Foo', $data[2]);
 }