Skip to content

Commit e641edd

Browse files
committedOct 4, 2024
ensure session storages are opened in tests before destroying them
1 parent a5509aa commit e641edd

6 files changed

+12
-0
lines changed
 

‎Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function testUseSessionGcMaxLifetimeAsTimeToLive()
106106

107107
public function testDestroySession()
108108
{
109+
$this->storage->open('', '');
109110
$this->redisClient->set(self::PREFIX.'id', 'foo');
110111

111112
$this->assertTrue((bool) $this->redisClient->exists(self::PREFIX.'id'));

‎Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public function testWriteSessionWithLargeTTL()
119119

120120
public function testDestroySession()
121121
{
122+
$this->storage->open('', '');
122123
$this->memcached
123124
->expects($this->once())
124125
->method('delete')

‎Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public function testClose()
5151

5252
public function testDestroy()
5353
{
54+
$this->dualHandler->open('/path/to/save/location', 'xyz');
55+
5456
$sessionId = 'xyz';
5557

5658
$this->currentHandler->expects($this->once())

‎Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ public function testDestroy()
174174
->method('deleteOne')
175175
->with([$this->options['id_field'] => 'foo']);
176176

177+
$this->storage->open('test', 'test');
178+
177179
$this->assertTrue($this->storage->destroy('foo'));
178180
}
179181

‎Tests/Session/Storage/Handler/PdoSessionHandlerTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ public function testWrongUsageStillWorks()
225225
{
226226
// wrong method sequence that should no happen, but still works
227227
$storage = new PdoSessionHandler($this->getMemorySqlitePdo());
228+
$storage->open('', 'sid');
228229
$storage->write('id', 'data');
229230
$storage->write('other_id', 'other_data');
230231
$storage->destroy('inexistent');

‎Tests/Session/Storage/Handler/StrictSessionHandlerTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public function testWriteEmptyNewSession()
130130
$handler->expects($this->never())->method('write');
131131
$handler->expects($this->once())->method('destroy')->willReturn(true);
132132
$proxy = new StrictSessionHandler($handler);
133+
$proxy->open('path', 'name');
133134

134135
$this->assertFalse($proxy->validateId('id'));
135136
$this->assertSame('', $proxy->read('id'));
@@ -144,6 +145,7 @@ public function testWriteEmptyExistingSession()
144145
$handler->expects($this->never())->method('write');
145146
$handler->expects($this->once())->method('destroy')->willReturn(true);
146147
$proxy = new StrictSessionHandler($handler);
148+
$proxy->open('path', 'name');
147149

148150
$this->assertSame('data', $proxy->read('id'));
149151
$this->assertTrue($proxy->write('id', ''));
@@ -155,6 +157,7 @@ public function testDestroy()
155157
$handler->expects($this->once())->method('destroy')
156158
->with('id')->willReturn(true);
157159
$proxy = new StrictSessionHandler($handler);
160+
$proxy->open('path', 'name');
158161

159162
$this->assertTrue($proxy->destroy('id'));
160163
}
@@ -166,6 +169,7 @@ public function testDestroyNewSession()
166169
->with('id')->willReturn('');
167170
$handler->expects($this->once())->method('destroy')->willReturn(true);
168171
$proxy = new StrictSessionHandler($handler);
172+
$proxy->open('path', 'name');
169173

170174
$this->assertSame('', $proxy->read('id'));
171175
$this->assertTrue($proxy->destroy('id'));
@@ -181,6 +185,7 @@ public function testDestroyNonEmptyNewSession()
181185
$handler->expects($this->once())->method('destroy')
182186
->with('id')->willReturn(true);
183187
$proxy = new StrictSessionHandler($handler);
188+
$proxy->open('path', 'name');
184189

185190
$this->assertSame('', $proxy->read('id'));
186191
$this->assertTrue($proxy->write('id', 'data'));

0 commit comments

Comments
 (0)
Please sign in to comment.