Skip to content

Commit

Permalink
ensure session storages are opened in tests before destroying them
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Oct 4, 2024
1 parent a5509aa commit e641edd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public function testUseSessionGcMaxLifetimeAsTimeToLive()

public function testDestroySession()
{
$this->storage->open('', '');
$this->redisClient->set(self::PREFIX.'id', 'foo');

$this->assertTrue((bool) $this->redisClient->exists(self::PREFIX.'id'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public function testWriteSessionWithLargeTTL()

public function testDestroySession()
{
$this->storage->open('', '');
$this->memcached
->expects($this->once())
->method('delete')
Expand Down
2 changes: 2 additions & 0 deletions Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public function testClose()

public function testDestroy()
{
$this->dualHandler->open('/path/to/save/location', 'xyz');

$sessionId = 'xyz';

$this->currentHandler->expects($this->once())
Expand Down
2 changes: 2 additions & 0 deletions Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ public function testDestroy()
->method('deleteOne')
->with([$this->options['id_field'] => 'foo']);

$this->storage->open('test', 'test');

$this->assertTrue($this->storage->destroy('foo'));
}

Expand Down
1 change: 1 addition & 0 deletions Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public function testWrongUsageStillWorks()
{
// wrong method sequence that should no happen, but still works
$storage = new PdoSessionHandler($this->getMemorySqlitePdo());
$storage->open('', 'sid');
$storage->write('id', 'data');
$storage->write('other_id', 'other_data');
$storage->destroy('inexistent');
Expand Down
5 changes: 5 additions & 0 deletions Tests/Session/Storage/Handler/StrictSessionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public function testWriteEmptyNewSession()
$handler->expects($this->never())->method('write');
$handler->expects($this->once())->method('destroy')->willReturn(true);
$proxy = new StrictSessionHandler($handler);
$proxy->open('path', 'name');

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

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

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

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

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

0 comments on commit e641edd

Please sign in to comment.