MediaWiki REL1_33
RedisBagOStuffTest.php
Go to the documentation of this file.
1<?php
2
3use Wikimedia\TestingAccessWrapper;
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}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
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