MediaWiki  1.29.1
MWMessagePackTest.php
Go to the documentation of this file.
1 <?php
6 class MWMessagePackTest extends PHPUnit_Framework_TestCase {
7 
16  public static function providePacks() {
17  $tests = [
18  [ 'nil', null, 'c0' ],
19  [ 'bool', true, 'c3' ],
20  [ 'bool', false, 'c2' ],
21  [ 'positive fixnum', 0, '00' ],
22  [ 'positive fixnum', 1, '01' ],
23  [ 'positive fixnum', 5, '05' ],
24  [ 'positive fixnum', 35, '23' ],
25  [ 'uint 8', 128, 'cc80' ],
26  [ 'uint 16', 1000, 'cd03e8' ],
27  [ 'uint 32', 100000, 'ce000186a0' ],
28  [ 'negative fixnum', -1, 'ff' ],
29  [ 'negative fixnum', -2, 'fe' ],
30  [ 'int 8', -128, 'd080' ],
31  [ 'int 8', -35, 'd0dd' ],
32  [ 'int 16', -1000, 'd1fc18' ],
33  [ 'int 32', -100000, 'd2fffe7960' ],
34  [ 'double', 0.1, 'cb3fb999999999999a' ],
35  [ 'double', 1.1, 'cb3ff199999999999a' ],
36  [ 'double', 123.456, 'cb405edd2f1a9fbe77' ],
37  [ 'fix raw', '', 'a0' ],
38  [ 'fix raw', 'foobar', 'a6666f6f626172' ],
39  [
40  'raw 16',
41  'Lorem ipsum dolor sit amet amet.',
42  'da00204c6f72656d20697073756d20646f6c6f722073697420616d657420616d65742e'
43  ],
44  [
45  'fix array',
46  [ 'abc', 'def', 'ghi' ],
47  '93a3616263a3646566a3676869'
48  ],
49  [
50  'fix map',
51  [ 'one' => 1, 'two' => 2 ],
52  '82a36f6e6501a374776f02'
53  ],
54  ];
55 
56  if ( PHP_INT_SIZE > 4 ) {
57  $tests[] = [ 'uint 64', 10000000000, 'cf00000002540be400' ];
58  $tests[] = [ 'int 64', -10000000000, 'd3fffffffdabf41c00' ];
59  $tests[] = [ 'int 64', -223372036854775807, 'd3fce66c50e2840001' ];
60  $tests[] = [ 'int 64', -9223372036854775807, 'd38000000000000001' ];
61  }
62 
63  return $tests;
64  }
65 
71  public function testPack( $type, $value, $expected ) {
72  $actual = bin2hex( MWMessagePack::pack( $value ) );
73  $this->assertEquals( $expected, $actual, $type );
74  }
75 }
MWMessagePackTest
PHP Unit tests for MWMessagePack MWMessagePack.
Definition: MWMessagePackTest.php:6
$type
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2536
php
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:35
$value
$value
Definition: styleTest.css.php:45
MWMessagePack\pack
static pack( $value)
Encode a value using MessagePack.
Definition: MWMessagePack.php:50
MWMessagePackTest\providePacks
static providePacks()
Provides test cases for MWMessagePackTest::testMessagePack.
Definition: MWMessagePackTest.php:16
MWMessagePackTest\testPack
testPack( $type, $value, $expected)
Verify that values are serialized correctly.
Definition: MWMessagePackTest.php:71