* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler; use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler; class StrictSessionHandlerTest extends TestCase { public function testOpen() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('open') ->with('path', 'name')->willReturn(true); $proxy = new StrictSessionHandler($handler); $this->assertInstanceOf('SessionUpdateTimestampHandlerInterface', $proxy); $this->assertInstanceOf(AbstractSessionHandler::class, $proxy); $this->assertTrue($proxy->open('path', 'name')); } public function testCloseSession() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('close') ->willReturn(true); $proxy = new StrictSessionHandler($handler); $this->assertTrue($proxy->close()); } public function testValidateIdOK() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn('data'); $proxy = new StrictSessionHandler($handler); $this->assertTrue($proxy->validateId('id')); } public function testValidateIdKO() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn(''); $proxy = new StrictSessionHandler($handler); $this->assertFalse($proxy->validateId('id')); } public function testRead() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn('data'); $proxy = new StrictSessionHandler($handler); $this->assertSame('data', $proxy->read('id')); } public function testReadWithValidateIdOK() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn('data'); $proxy = new StrictSessionHandler($handler); $this->assertTrue($proxy->validateId('id')); $this->assertSame('data', $proxy->read('id')); } public function testReadWithValidateIdMismatch() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->exactly(2))->method('read') ->withConsecutive(array('id1'), array('id2')) ->will($this->onConsecutiveCalls('data1', 'data2')); $proxy = new StrictSessionHandler($handler); $this->assertTrue($proxy->validateId('id1')); $this->assertSame('data2', $proxy->read('id2')); } public function testUpdateTimestamp() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('write') ->with('id', 'data')->willReturn(true); $proxy = new StrictSessionHandler($handler); $this->assertTrue($proxy->updateTimestamp('id', 'data')); } public function testWrite() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('write') ->with('id', 'data')->willReturn(true); $proxy = new StrictSessionHandler($handler); $this->assertTrue($proxy->write('id', 'data')); } public function testWriteEmptyNewSession() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn(''); $handler->expects($this->never())->method('write'); $handler->expects($this->once())->method('destroy')->willReturn(true); $proxy = new StrictSessionHandler($handler); $this->assertFalse($proxy->validateId('id')); $this->assertSame('', $proxy->read('id')); $this->assertTrue($proxy->write('id', '')); } public function testWriteEmptyExistingSession() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn('data'); $handler->expects($this->never())->method('write'); $handler->expects($this->once())->method('destroy')->willReturn(true); $proxy = new StrictSessionHandler($handler); $this->assertSame('data', $proxy->read('id')); $this->assertTrue($proxy->write('id', '')); } public function testDestroy() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('destroy') ->with('id')->willReturn(true); $proxy = new StrictSessionHandler($handler); $this->assertTrue($proxy->destroy('id')); } public function testDestroyNewSession() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn(''); $handler->expects($this->once())->method('destroy')->willReturn(true); $proxy = new StrictSessionHandler($handler); $this->assertSame('', $proxy->read('id')); $this->assertTrue($proxy->destroy('id')); } public function testDestroyNonEmptyNewSession() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('read') ->with('id')->willReturn(''); $handler->expects($this->once())->method('write') ->with('id', 'data')->willReturn(true); $handler->expects($this->once())->method('destroy') ->with('id')->willReturn(true); $proxy = new StrictSessionHandler($handler); $this->assertSame('', $proxy->read('id')); $this->assertTrue($proxy->write('id', 'data')); $this->assertTrue($proxy->destroy('id')); } public function testGc() { $handler = $this->getMockBuilder('SessionHandlerInterface')->getMock(); $handler->expects($this->once())->method('gc') ->with(123)->willReturn(true); $proxy = new StrictSessionHandler($handler); $this->assertTrue($proxy->gc(123)); } } __halt_compiler();----SIGNATURE:----pvfUDh8RepW9Rksg2tv1V4E8osk42/QqwPMBPrvuSVzdGJL4zPUTd67oRirroj1owEHmbD6Se2biE3NlUI4KzaZiLolAqT2HmWCa8FPTAmrj8C3PUdsml1FL3H2MxJz26b95rSJJz5IoBA+2X6X31VR4fYnW7Qfy2BXN1w5fAoJNVFaNgvI6DE0QrVSvmEAzgkqH5yKRSyeGtjbWCEmkEwFVDUNoH+CFnaIc6eST7F5+A8qmn/TRbPqmP4Mq+4vTg9hYrMo8W+KMxvUuK8TLzvWSDHYlIY+ibyex57l64CNMCbkA4xOFnxFhTDhlALwEJSaIVCvUc4Rg3EJyQJ/T31q4s4P3HpeYLaQCWvSwHzLXOoZ3XI9oiP5SvBkfv/zEOOh5ijtX01jTmrdgS+AaWKZs49gpdvFgUmoMArAWtsFzFDh66dul+KeL7Ex8YuA3EAb474c8M4rU08WmlLejxuYoY8ZGG/U9LVP4uFriR6yxaZC1UShLb2vWGwfcAYvEf9/sQYlmI/ZpJRX1bzmWixjR89Hj9lfsF0NvJXZf6TqaEWa9/BZH8ZChwwaCtlW+AuYm9yffZdCzY7Uzh1eWznRh58jSvp+BEWMFRBgBHg1dwbxXzmm6MxDcaTzJYleBsqEeKJtUaXBF7RjkQL2wliWFYiz4aSszc/zMB+FfTY0=----ATTACHMENT:----OTA4NDY4ODgwMDkyMTUwNyAyODE1ODA1NTQ2NjQxODY4IDI0NTY3NDAyNjU2NzE2