Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dafde68

Browse filesBrowse files
minor #58453 [HttpFoundation] ensure session storages are opened in tests before destroying them (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [HttpFoundation] ensure session storages are opened in tests before destroying them | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT The tests currently only pass by luck as the condition in https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php#L129 does not evaluate to `true` (because headers are already sent). Commits ------- 37ee990 ensure session storages are opened in tests before destroying them
2 parents 908a91f + 37ee990 commit dafde68
Copy full SHA for dafde68

File tree

Expand file treeCollapse file tree

6 files changed

+12
-0
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+12
-0
lines changed

‎src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/AbstractRedisSessionHandlerTestCase.php
+1Lines changed: 1 addition & 0 deletions
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'));

‎src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php
+1Lines changed: 1 addition & 0 deletions
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')

‎src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php
+2Lines changed: 2 additions & 0 deletions
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())

‎src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
+2Lines changed: 2 additions & 0 deletions
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

‎src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
+1Lines changed: 1 addition & 0 deletions
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');

‎src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php
+5Lines changed: 5 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.