@@ -50,24 +50,26 @@ public function setUp()
50
50
$ this ->filesystem = new Filesystem ($ this ->adapter );
51
51
}
52
52
53
- protected function getTableContents ()
53
+ protected function getTableContents ($ stripTimestampFromReturnedRows = true )
54
54
{
55
55
$ statement = $ this ->pdo ->prepare ("SELECT * FROM files " );
56
56
$ statement ->execute ();
57
57
$ result = $ statement ->fetchAll (PDO ::FETCH_ASSOC );
58
58
59
- return array_map (function ($ v ) {
59
+ return array_map (function ($ v ) use ( $ stripTimestampFromReturnedRows ) {
60
60
unset($ v ['id ' ]);
61
- unset($ v ['timestamp ' ]);
61
+ if ($ stripTimestampFromReturnedRows ) {
62
+ unset($ v ['timestamp ' ]);
63
+ }
62
64
$ v ['size ' ] = (int ) $ v ['size ' ];
63
65
64
66
return $ v ;
65
67
}, $ result );
66
68
}
67
69
68
- protected function assertTableContains ($ expected )
70
+ protected function assertTableContains ($ expected, $ stripTimestampFromReturnedRows = true )
69
71
{
70
- $ this ->assertEquals ($ expected , $ this ->getTableContents ());
72
+ $ this ->assertEquals ($ expected , $ this ->getTableContents ($ stripTimestampFromReturnedRows ));
71
73
}
72
74
73
75
protected function filterContents ($ contents )
@@ -124,6 +126,25 @@ public function testBasicWrite()
124
126
]);
125
127
}
126
128
129
+ public function testWriteWithSpecificTimestamp ()
130
+ {
131
+ $ timestamp = \mktime (0 , 0 , 0 , 1 , 1 , 2000 );
132
+ $ config = array ('timestamp ' => $ timestamp );
133
+
134
+ $ this ->assertTrue ($ this ->filesystem ->createDir ('foo ' , $ config ));
135
+
136
+ $ path1 = 'foo/bar.txt ' ;
137
+ $ contents1 = 'ala ma kota ' ;
138
+ $ this ->assertTrue ($ this ->filesystem ->write ($ path1 , $ contents1 , $ config ));
139
+
140
+ $ this ->assertTableContains ([
141
+ ['path ' => 'foo ' , 'contents ' => null , 'type ' => 'dir ' , 'size ' => 0 , 'mimetype ' => null , 'timestamp ' => $ timestamp ],
142
+ ['path ' => $ path1 , 'contents ' => $ contents1 , 'type ' => 'file ' , 'size ' => strlen ($ contents1 ), 'mimetype ' => 'text/plain ' , 'timestamp ' => $ timestamp ]
143
+ ],
144
+ false
145
+ );
146
+ }
147
+
127
148
public function testListContents ()
128
149
{
129
150
$ this ->testBasicWrite ();
0 commit comments