@@ -62,7 +62,43 @@ public function testPutCreatesMissingDirectories()
62
62
$ this ->assertTrue ($ result );
63
63
}
64
64
65
- public function testExpiredItemsReturnNull ()
65
+ public function testPutWillConsiderZeroAsEternalTime ()
66
+ {
67
+ $ files = $ this ->mockFilesystem ();
68
+
69
+ $ hash = sha1 ('O--L / key ' );
70
+ $ filePath = __DIR__ .'/ ' .substr ($ hash , 0 , 2 ).'/ ' .substr ($ hash , 2 , 2 ).'/ ' .$ hash ;
71
+ $ ten9s = '9999999999 ' ; // The "forever" time value.
72
+ $ fileContents = $ ten9s .serialize ('gold ' );
73
+ $ exclusiveLock = true ;
74
+
75
+ $ files ->expects ($ this ->once ())->method ('put ' )->with (
76
+ $ this ->equalTo ($ filePath ),
77
+ $ this ->equalTo ($ fileContents ),
78
+ $ this ->equalTo ($ exclusiveLock ) // Ensure we do lock the file while putting.
79
+ )->willReturn (strlen ($ fileContents ));
80
+
81
+ (new FileStore ($ files , __DIR__ ))->put ('O--L / key ' , 'gold ' , 0 );
82
+ }
83
+
84
+ public function testPutWillConsiderBigValuesAsEternalTime ()
85
+ {
86
+ $ files = $ this ->mockFilesystem ();
87
+
88
+ $ hash = sha1 ('O--L / key ' );
89
+ $ filePath = __DIR__ .'/ ' .substr ($ hash , 0 , 2 ).'/ ' .substr ($ hash , 2 , 2 ).'/ ' .$ hash ;
90
+ $ ten9s = '9999999999 ' ; // The "forever" time value.
91
+ $ fileContents = $ ten9s .serialize ('gold ' );
92
+
93
+ $ files ->expects ($ this ->once ())->method ('put ' )->with (
94
+ $ this ->equalTo ($ filePath ),
95
+ $ this ->equalTo ($ fileContents ),
96
+ );
97
+
98
+ (new FileStore ($ files , __DIR__ ))->put ('O--L / key ' , 'gold ' , (int ) $ ten9s + 1 );
99
+ }
100
+
101
+ public function testExpiredItemsReturnNullAndGetDeleted ()
66
102
{
67
103
$ files = $ this ->mockFilesystem ();
68
104
$ contents = '0000000000 ' ;
0 commit comments