rdbms: Rename "memCache" to "memStash" in LBFactory
[mediawiki.git] / tests / phpunit / includes / objectcache / RedisBagOStuffTest.php
blob34a72cec5dffb129f460a1a53974ef474c097a5c
1 <?php
3 use Wikimedia\TestingAccessWrapper;
5 /**
6 * @group BagOStuff
7 */
8 class RedisBagOStuffTest extends PHPUnit_Framework_TestCase {
9 /** @var RedisBagOStuff */
10 private $cache;
12 protected function setUp() {
13 parent::setUp();
14 $cache = $this->getMockBuilder( 'RedisBagOStuff' )
15 ->disableOriginalConstructor()
16 ->getMock();
17 $this->cache = TestingAccessWrapper::newFromObject( $cache );
20 /**
21 * @covers RedisBagOStuff::unserialize
22 * @dataProvider unserializeProvider
24 public function testUnserialize( $expected, $input, $message ) {
25 $actual = $this->cache->unserialize( $input );
26 $this->assertSame( $expected, $actual, $message );
29 public function unserializeProvider() {
30 return [
32 -1,
33 '-1',
34 'String representation of \'-1\'',
38 '0',
39 'String representation of \'0\'',
43 '1',
44 'String representation of \'1\'',
47 -1.0,
48 'd:-1;',
49 'Serialized negative double',
52 'foo',
53 's:3:"foo";',
54 'Serialized string',
59 /**
60 * @covers RedisBagOStuff::serialize
61 * @dataProvider serializeProvider
63 public function testSerialize( $expected, $input, $message ) {
64 $actual = $this->cache->serialize( $input );
65 $this->assertSame( $expected, $actual, $message );
68 public function serializeProvider() {
69 return [
71 -1,
72 -1,
73 '-1 as integer',
78 '0 as integer',
83 '1 as integer',
86 'd:-1;',
87 -1.0,
88 'Negative double',
91 's:3:"2.1";',
92 '2.1',
93 'Decimal string',
96 's:1:"1";',
97 '1',
98 'String representation of 1',
101 's:3:"foo";',
102 'foo',
103 'String',