api/symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.yaml

71 lines
3.8 KiB
YAML
Raw Normal View History

2024-09-26 09:03:21 +00:00
name: MemcachedSessionHandlerTest
class_comment: '# * @requires extension memcached
# *
# * @group time-sensitive'
dependencies:
- name: MockObject
type: class
source: PHPUnit\Framework\MockObject\MockObject
- name: TestCase
type: class
source: PHPUnit\Framework\TestCase
- name: MemcachedSessionHandler
type: class
source: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler
properties: []
methods:
- name: testSupportedOptions
visibility: public
parameters:
- name: options
- name: supported
comment: "# * @requires extension memcached\n# *\n# * @group time-sensitive\n# */\n\
# class MemcachedSessionHandlerTest extends TestCase\n# {\n# private const PREFIX\
\ = 'prefix_';\n# private const TTL = 1000;\n# \n# protected MemcachedSessionHandler\
\ $storage;\n# protected MockObject&\\Memcached $memcached;\n# \n# protected function\
\ setUp(): void\n# {\n# parent::setUp();\n# \n# if (version_compare(phpversion('memcached'),\
\ '2.2.0', '>=') && version_compare(phpversion('memcached'), '3.0.0b1', '<'))\
\ {\n# $this->markTestSkipped('Tests can only be run with memcached extension\
\ 2.1.0 or lower, or 3.0.0b1 or higher');\n# }\n# \n# $r = new \\ReflectionClass(\\\
Memcached::class);\n# $methodsToMock = array_map(fn ($m) => $m->name, $r->getMethods(\\\
ReflectionMethod::IS_PUBLIC));\n# $methodsToMock = array_diff($methodsToMock,\
\ ['getDelayed', 'getDelayedByKey']);\n# \n# $this->memcached = $this->getMockBuilder(\\\
Memcached::class)\n# ->disableOriginalConstructor()\n# ->onlyMethods($methodsToMock)\n\
# ->getMock();\n# \n# $this->storage = new MemcachedSessionHandler(\n# $this->memcached,\n\
# ['prefix' => self::PREFIX, 'expiretime' => self::TTL]\n# );\n# }\n# \n# public\
\ function testOpenSession()\n# {\n# $this->assertTrue($this->storage->open('',\
\ ''));\n# }\n# \n# public function testCloseSession()\n# {\n# $this->memcached\n\
# ->expects($this->once())\n# ->method('quit')\n# ->willReturn(true)\n# ;\n# \n\
# $this->assertTrue($this->storage->close());\n# }\n# \n# public function testReadSession()\n\
# {\n# $this->memcached\n# ->expects($this->once())\n# ->method('get')\n# ->with(self::PREFIX.'id')\n\
# ;\n# \n# $this->assertEquals('', $this->storage->read('id'));\n# }\n# \n# public\
\ function testWriteSession()\n# {\n# $this->memcached\n# ->expects($this->once())\n\
# ->method('set')\n# ->with(self::PREFIX.'id', 'data', $this->equalTo(self::TTL,\
\ 2))\n# ->willReturn(true)\n# ;\n# \n# $this->assertTrue($this->storage->write('id',\
\ 'data'));\n# }\n# \n# public function testWriteSessionWithLargeTTL()\n# {\n\
# $this->memcached\n# ->expects($this->once())\n# ->method('set')\n# ->with(self::PREFIX.'id',\
\ 'data', $this->equalTo(time() + self::TTL + 60 * 60 * 24 * 30, 2))\n# ->willReturn(true)\n\
# ;\n# \n# $storage = new MemcachedSessionHandler(\n# $this->memcached,\n# ['prefix'\
\ => self::PREFIX, 'expiretime' => self::TTL + 60 * 60 * 24 * 30]\n# );\n# \n\
# $this->assertTrue($storage->write('id', 'data'));\n# }\n# \n# public function\
\ testDestroySession()\n# {\n# $this->memcached\n# ->expects($this->once())\n\
# ->method('delete')\n# ->with(self::PREFIX.'id')\n# ->willReturn(true)\n# ;\n\
# \n# $this->assertTrue($this->storage->destroy('id'));\n# }\n# \n# public function\
\ testGcSession()\n# {\n# $this->assertIsInt($this->storage->gc(123));\n# }\n\
# \n# /**\n# * @dataProvider getOptionFixtures"
- name: getOptionFixtures
visibility: public
parameters: []
comment: null
- name: testGetConnection
visibility: public
parameters: []
comment: null
traits:
- PHPUnit\Framework\MockObject\MockObject
- PHPUnit\Framework\TestCase
- Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler
interfaces: []