MediaWiki REL1_33
RedisBagOStuffTest.php
Go to the documentation of this file.
1<?php
2
4
8class RedisBagOStuffTest extends PHPUnit\Framework\TestCase {
9
10 use MediaWikiCoversValidator;
11
13 private $cache;
14
15 protected function setUp() {
16 parent::setUp();
17 $cache = $this->getMockBuilder( RedisBagOStuff::class )
18 ->disableOriginalConstructor()
19 ->getMock();
20 $this->cache = TestingAccessWrapper::newFromObject( $cache );
21 }
22
27 public function testUnserialize( $expected, $input, $message ) {
28 $actual = $this->cache->unserialize( $input );
29 $this->assertSame( $expected, $actual, $message );
30 }
31
32 public function unserializeProvider() {
33 return [
34 [
35 -1,
36 '-1',
37 'String representation of \'-1\'',
38 ],
39 [
40 0,
41 '0',
42 'String representation of \'0\'',
43 ],
44 [
45 1,
46 '1',
47 'String representation of \'1\'',
48 ],
49 [
50 -1.0,
51 'd:-1;',
52 'Serialized negative double',
53 ],
54 [
55 'foo',
56 's:3:"foo";',
57 'Serialized string',
58 ]
59 ];
60 }
61
66 public function testSerialize( $expected, $input, $message ) {
67 $actual = $this->cache->serialize( $input );
68 $this->assertSame( $expected, $actual, $message );
69 }
70
71 public function serializeProvider() {
72 return [
73 [
74 -1,
75 -1,
76 '-1 as integer',
77 ],
78 [
79 0,
80 0,
81 '0 as integer',
82 ],
83 [
84 1,
85 1,
86 '1 as integer',
87 ],
88 [
89 'd:-1;',
90 -1.0,
91 'Negative double',
92 ],
93 [
94 's:3:"2.1";',
95 '2.1',
96 'Decimal string',
97 ],
98 [
99 's:1:"1";',
100 '1',
101 'String representation of 1',
102 ],
103 [
104 's:3:"foo";',
105 'foo',
106 'String',
107 ],
108 ];
109 }
110}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
testSerialize( $expected, $input, $message)
RedisBagOStuff::serialize serializeProvider.
testUnserialize( $expected, $input, $message)
RedisBagOStuff::unserialize unserializeProvider.
Redis-based caching module for redis server >= 2.6.12 and phpredis >= 2.2.4.
you have access to all of the normal MediaWiki so you can get a DB use the cache
if(is_array($mode)) switch( $mode) $input