@@ -47,6 +47,13 @@ class DbTableGatewayTest extends \PHPUnit_Framework_TestCase
4747 */
4848 protected $ usedSaveHandlers = [];
4949
50+ /**
51+ * Test data container.
52+ *
53+ * @var array
54+ */
55+ private $ testArray ;
56+
5057 /**
5158 * Setup performed prior to each test method
5259 *
@@ -123,10 +130,48 @@ public function testReadWriteTwice()
123130 $ this ->assertEquals ($ this ->testArray , unserialize ($ saveHandler ->read ($ id )));
124131 }
125132
133+ public function testReadShouldAlwaysReturnString ()
134+ {
135+ $ this ->usedSaveHandlers [] = $ saveHandler = new DbTableGateway ($ this ->tableGateway , $ this ->options );
136+ $ saveHandler ->open ('savepath ' , 'sessionname ' );
137+
138+ $ id = '242 ' ;
139+
140+ $ data = $ saveHandler ->read ($ id );
141+
142+ $ this ->assertTrue (is_string ($ data ));
143+ }
144+
145+ public function testDestroyReturnsTrueEvenWhenSessionDoesNotExist ()
146+ {
147+ $ this ->usedSaveHandlers [] = $ saveHandler = new DbTableGateway ($ this ->tableGateway , $ this ->options );
148+ $ saveHandler ->open ('savepath ' , 'sessionname ' );
149+
150+ $ id = '242 ' ;
151+
152+ $ result = $ saveHandler ->destroy ($ id );
153+
154+ $ this ->assertTrue ($ result );
155+ }
156+
157+ public function testDestroyReturnsTrueWhenSessionIsDeleted ()
158+ {
159+ $ this ->usedSaveHandlers [] = $ saveHandler = new DbTableGateway ($ this ->tableGateway , $ this ->options );
160+ $ saveHandler ->open ('savepath ' , 'sessionname ' );
161+
162+ $ id = '242 ' ;
163+
164+ $ this ->assertTrue ($ saveHandler ->write ($ id , serialize ($ this ->testArray )));
165+
166+ $ result = $ saveHandler ->destroy ($ id );
167+
168+ $ this ->assertTrue ($ result );
169+ }
170+
126171 /**
127172 * Sets up the database connection and creates the table for session data
128173 *
129- * @param Zend\Session\SaveHandler\DbTableGatewayOptions $options
174+ * @param \ Zend\Session\SaveHandler\DbTableGatewayOptions $options
130175 * @return void
131176 */
132177 protected function setupDb (DbTableGatewayOptions $ options )
0 commit comments