Merge "Add small script for common job queue admin tasks"
[mediawiki.git] / tests / phpunit / includes / objectcache / RedisBagOStuffTest.php
blob705a34a68db69f9f9addf69f66451bd7b3acd985
1 <?php
2 /**
3 * @group BagOStuff
4 */
5 class RedisBagOStuffTest extends PHPUnit_Framework_TestCase {
6 /** @var RedisBagOStuff */
7 private $cache;
9 protected function setUp() {
10 parent::setUp();
11 $cache = $this->getMockBuilder( 'RedisBagOStuff' )
12 ->disableOriginalConstructor()
13 ->getMock();
14 $this->cache = TestingAccessWrapper::newFromObject( $cache );
17 /**
18 * @covers RedisBagOStuff::unserialize
19 * @dataProvider unserializeProvider
21 public function testUnserialize( $expected, $input, $message ) {
22 $actual = $this->cache->unserialize( $input );
23 $this->assertSame( $expected, $actual, $message );
26 public function unserializeProvider() {
27 return [
29 -1,
30 '-1',
31 'String representation of \'-1\'',
35 '0',
36 'String representation of \'0\'',
40 '1',
41 'String representation of \'1\'',
44 -1.0,
45 'd:-1;',
46 'Serialized negative double',
49 'foo',
50 's:3:"foo";',
51 'Serialized string',
56 /**
57 * @covers RedisBagOStuff::serialize
58 * @dataProvider serializeProvider
60 public function testSerialize( $expected, $input, $message ) {
61 $actual = $this->cache->serialize( $input );
62 $this->assertSame( $expected, $actual, $message );
65 public function serializeProvider() {
66 return [
68 -1,
69 -1,
70 '-1 as integer',
75 '0 as integer',
80 '1 as integer',
83 'd:-1;',
84 -1.0,
85 'Negative double',
88 's:3:"2.1";',
89 '2.1',
90 'Decimal string',
93 's:1:"1";',
94 '1',
95 'String representation of 1',
98 's:3:"foo";',
99 'foo',
100 'String',