@@ -15,7 +15,7 @@ class CachePluginSpec extends ObjectBehavior
15
15
{
16
16
function let (CacheItemPoolInterface $ pool , StreamFactory $ streamFactory )
17
17
{
18
- $ this ->beConstructedWith ($ pool , $ streamFactory , ['default_ttl ' =>60 ]);
18
+ $ this ->beConstructedWith ($ pool , $ streamFactory , ['default_ttl ' =>60 , ' cache_lifetime ' => 1000 ]);
19
19
}
20
20
21
21
function it_is_initializable (CacheItemPoolInterface $ pool )
@@ -41,18 +41,25 @@ function it_caches_responses(CacheItemPoolInterface $pool, CacheItemInterface $i
41
41
$ response ->getBody ()->willReturn ($ stream );
42
42
$ response ->getHeader ('Cache-Control ' )->willReturn (array ());
43
43
$ response ->getHeader ('Expires ' )->willReturn (array ());
44
+ $ response ->getHeader ('ETag ' )->willReturn (array ());
44
45
45
46
$ pool ->getItem ('e3b717d5883a45ef9493d009741f7c64 ' )->shouldBeCalled ()->willReturn ($ item );
46
47
$ item ->isHit ()->willReturn (false );
47
- $ item ->set ([ ' response ' => $ response , ' body ' => $ httpBody ] )->willReturn ($ item )->shouldBeCalled ();
48
- $ item ->expiresAfter (60 )->willReturn ($ item )->shouldBeCalled ();
48
+ $ item ->set ()->willReturn ($ item )->shouldBeCalled ();
49
+ $ item ->expiresAfter (1060 )->willReturn ($ item )->shouldBeCalled ();
49
50
$ pool ->save ($ item )->shouldBeCalled ();
50
51
51
52
$ next = function (RequestInterface $ request ) use ($ response ) {
52
53
return new FulfilledPromise ($ response ->getWrappedObject ());
53
54
};
54
55
55
56
$ this ->handleRequest ($ request , $ next , function () {});
57
+ $ item ->get ()->shouldHaveKeyWithValue ('response ' , $ response );
58
+ $ item ->get ()->shouldHaveKeyWithValue ('body ' , $ httpBody );
59
+ $ item ->get ()->shouldHaveKey ('expiresAt ' );
60
+ $ item ->get ()->shouldHaveKey ('createdAt ' );
61
+ $ item ->get ()->shouldHaveKey ('etag ' );
62
+
56
63
}
57
64
58
65
function it_doesnt_store_failed_responses (CacheItemPoolInterface $ pool , CacheItemInterface $ item , RequestInterface $ request , ResponseInterface $ response )
0 commit comments