@@ -64,6 +64,38 @@ public function testLastModifiedWithCacheHit()
64
64
$ this ->assertEquals (304 , $ res ->getStatusCode ());
65
65
}
66
66
67
+ public function testLastModifiedWithCacheHitAndNewerDate ()
68
+ {
69
+ $ now = time ();
70
+ $ lastModified = gmdate ('D, d M Y H:i:s T ' , $ now + 86400 );
71
+ $ ifModifiedSince = gmdate ('D, d M Y H:i:s T ' , $ now + 172800 ); // <-- Newer date
72
+ $ cache = new Cache ('public ' , 86400 );
73
+ $ req = $ this ->requestFactory ()->withHeader ('If-Modified-Since ' , $ ifModifiedSince );
74
+ $ res = new Response ();
75
+ $ next = function (Request $ req , Response $ res ) use ($ lastModified ) {
76
+ return $ res ->withHeader ('Last-Modified ' , $ lastModified );
77
+ };
78
+ $ res = $ cache ($ req , $ res , $ next );
79
+
80
+ $ this ->assertEquals (304 , $ res ->getStatusCode ());
81
+ }
82
+
83
+ public function testLastModifiedWithCacheHitAndOlderDate ()
84
+ {
85
+ $ now = time ();
86
+ $ lastModified = gmdate ('D, d M Y H:i:s T ' , $ now + 86400 );
87
+ $ ifModifiedSince = gmdate ('D, d M Y H:i:s T ' , $ now ); // <-- Older date
88
+ $ cache = new Cache ('public ' , 86400 );
89
+ $ req = $ this ->requestFactory ()->withHeader ('If-Modified-Since ' , $ ifModifiedSince );
90
+ $ res = new Response ();
91
+ $ next = function (Request $ req , Response $ res ) use ($ lastModified ) {
92
+ return $ res ->withHeader ('Last-Modified ' , $ lastModified );
93
+ };
94
+ $ res = $ cache ($ req , $ res , $ next );
95
+
96
+ $ this ->assertEquals (200 , $ res ->getStatusCode ());
97
+ }
98
+
67
99
public function testLastModifiedWithCacheMiss ()
68
100
{
69
101
$ now = time ();
0 commit comments