14 use PHPUnit\Framework\TestCase;
32 protected function setUp()
34 if (defined(
'HHVM_VERSION')) {
35 $this->markTestSkipped(
'PHPUnit_MockObject cannot mock the Memcache class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289');
39 $this->memcache = $this->getMockBuilder(
'Memcache')->getMock();
42 array(
'prefix' => self::PREFIX,
'expiretime' => self::TTL)
48 $this->memcache =
null;
49 $this->storage =
null;
55 $this->assertTrue($this->storage->open(
'',
''));
60 $this->assertTrue($this->storage->close());
66 ->expects($this->once())
68 ->with(self::PREFIX.
'id')
71 $this->assertEquals(
'', $this->storage->read(
'id'));
77 ->expects($this->once())
79 ->with(self::PREFIX.
'id',
'data', 0, $this->equalTo(time() + self::TTL, 2))
80 ->will($this->returnValue(
true))
83 $this->assertTrue($this->storage->write(
'id',
'data'));
89 ->expects($this->once())
91 ->with(self::PREFIX.
'id')
92 ->will($this->returnValue(
true))
95 $this->assertTrue($this->storage->destroy(
'id'));
100 $this->assertTrue($this->storage->gc(123));
110 $this->assertTrue($supported);
111 }
catch (\InvalidArgumentException $e) {
112 $this->assertFalse($supported);
119 array(array(
'prefix' =>
'session'),
true),
120 array(array(
'expiretime' => 100),
true),
121 array(array(
'prefix' =>
'session',
'expiretime' => 200),
true),
122 array(array(
'expiretime' => 100,
'foo' =>
'bar'),
false),
128 $method = new \ReflectionMethod($this->storage,
'getMemcache');
129 $method->setAccessible(
true);
131 $this->assertInstanceOf(
'\Memcache', $method->invoke($this->storage));