@@ -41,7 +41,7 @@ protected function setUp()
41
41
'data_field ' => 'data ' ,
42
42
'time_field ' => 'time ' ,
43
43
'database ' => 'sf2-test ' ,
44
- 'collection ' => 'session-test ' ,
44
+ 'collection ' => 'session-test '
45
45
);
46
46
47
47
$ this ->storage = new MongoDbSessionHandler ($ this ->mongo , $ this ->options );
@@ -100,45 +100,6 @@ public function testWrite()
100
100
$ that ->assertInstanceOf ('MongoDate ' , $ data [$ this ->options ['time_field ' ]]);
101
101
}
102
102
103
- public function testWriteWhenUsingExpiresField ()
104
- {
105
- $ this ->options = array (
106
- 'id_field ' => '_id ' ,
107
- 'data_field ' => 'data ' ,
108
- 'time_field ' => 'time ' ,
109
- 'database ' => 'sf2-test ' ,
110
- 'collection ' => 'session-test ' ,
111
- 'expiry_field ' => 'expiresAt '
112
- );
113
-
114
- $ this ->storage = new MongoDbSessionHandler ($ this ->mongo , $ this ->options );
115
-
116
- $ collection = $ this ->createMongoCollectionMock ();
117
-
118
- $ this ->mongo ->expects ($ this ->once ())
119
- ->method ('selectCollection ' )
120
- ->with ($ this ->options ['database ' ], $ this ->options ['collection ' ])
121
- ->will ($ this ->returnValue ($ collection ));
122
-
123
- $ that = $ this ;
124
- $ data = array ();
125
-
126
- $ collection ->expects ($ this ->once ())
127
- ->method ('update ' )
128
- ->will ($ this ->returnCallback (function ($ criteria , $ updateData , $ options ) use ($ that , &$ data ) {
129
- $ that ->assertEquals (array ($ that ->options ['id_field ' ] => 'foo ' ), $ criteria );
130
- $ that ->assertEquals (array ('upsert ' => true , 'multiple ' => false ), $ options );
131
-
132
- $ data = $ updateData ['$set ' ];
133
- }));
134
-
135
- $ this ->assertTrue ($ this ->storage ->write ('foo ' , 'bar ' ));
136
-
137
- $ this ->assertEquals ('bar ' , $ data [$ this ->options ['data_field ' ]]->bin );
138
- $ that ->assertInstanceOf ('MongoDate ' , $ data [$ this ->options ['time_field ' ]]);
139
- $ that ->assertInstanceOf ('MongoDate ' , $ data [$ this ->options ['expiry_field ' ]]);
140
- }
141
-
142
103
public function testReplaceSessionData ()
143
104
{
144
105
$ collection = $ this ->createMongoCollectionMock ();
@@ -193,36 +154,10 @@ public function testGc()
193
154
->method ('remove ' )
194
155
->will ($ this ->returnCallback (function ($ criteria ) use ($ that ) {
195
156
$ that ->assertInstanceOf ('MongoDate ' , $ criteria [$ that ->options ['time_field ' ]]['$lt ' ]);
196
- $ that ->assertGreaterThanOrEqual (time () - 1 , $ criteria [$ that ->options ['time_field ' ]]['$lt ' ]->sec );
157
+ $ that ->assertGreaterThanOrEqual (time () - - 1 , $ criteria [$ that ->options ['time_field ' ]]['$lt ' ]->sec );
197
158
}));
198
159
199
- $ this ->assertTrue ($ this ->storage ->gc (1 ));
200
- }
201
-
202
- public function testGcWhenUsingExpiresField ()
203
- {
204
- $ this ->options = array (
205
- 'id_field ' => '_id ' ,
206
- 'data_field ' => 'data ' ,
207
- 'time_field ' => 'time ' ,
208
- 'database ' => 'sf2-test ' ,
209
- 'collection ' => 'session-test ' ,
210
- 'expiry_field ' => 'expiresAt '
211
- );
212
-
213
- $ this ->storage = new MongoDbSessionHandler ($ this ->mongo , $ this ->options );
214
-
215
- $ collection = $ this ->createMongoCollectionMock ();
216
-
217
- $ this ->mongo ->expects ($ this ->never ())
218
- ->method ('selectCollection ' );
219
-
220
- $ that = $ this ;
221
-
222
- $ collection ->expects ($ this ->never ())
223
- ->method ('remove ' );
224
-
225
- $ this ->assertTrue ($ this ->storage ->gc (1 ));
160
+ $ this ->assertTrue ($ this ->storage ->gc (-1 ));
226
161
}
227
162
228
163
private function createMongoCollectionMock ()
0 commit comments