MediaWiki  1.33.0
EasyDeflateTest.php
Go to the documentation of this file.
1 <?php
24 class EasyDeflateTest extends PHPUnit\Framework\TestCase {
25 
26  public function provideIsDeflated() {
27  return [
28  [ 'rawdeflate,S8vPT0osAgA=', true ],
29  [ 'abcdefghijklmnopqrstuvwxyz', false ],
30  ];
31  }
32 
36  public function testIsDeflated( $data, $expected ) {
37  $actual = EasyDeflate::isDeflated( $data );
38  $this->assertSame( $expected, $actual );
39  }
40 
41  public function provideInflate() {
42  return [
43  [ 'rawdeflate,S8vPT0osAgA=', true, 'foobar' ],
44  // Fails base64_decode
45  [ 'rawdeflate,🌻', false, 'easydeflate-invaliddeflate' ],
46  // Fails gzinflate
47  [ 'rawdeflate,S8vPT0dfdAgB=', false, 'easydeflate-invaliddeflate' ],
48  ];
49  }
50 
54  public function testInflate( $data, $ok, $value ) {
55  $actual = EasyDeflate::inflate( $data );
56  if ( $ok ) {
57  $this->assertTrue( $actual->isOK() );
58  $this->assertSame( $value, $actual->getValue() );
59  } else {
60  $this->assertFalse( $actual->isOK() );
61  $this->assertTrue( $actual->hasMessage( $value ) );
62  }
63  }
64 }
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
EasyDeflate\isDeflated
static isDeflated( $data)
Whether the content is deflated.
Definition: EasyDeflate.php:33
EasyDeflateTest
Copyright (C) 2018 Kunal Mehta legoktm@member.fsf.org
Definition: EasyDeflateTest.php:24
EasyDeflateTest\testInflate
testInflate( $data, $ok, $value)
provideInflate
Definition: EasyDeflateTest.php:54
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
$data
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
Definition: generatePhpCharToUpperMappings.php:13
EasyDeflateTest\testIsDeflated
testIsDeflated( $data, $expected)
provideIsDeflated
Definition: EasyDeflateTest.php:36
EasyDeflate\inflate
static inflate( $data)
For content that has been compressed with deflate in the client, try to uncompress it with inflate.
Definition: EasyDeflate.php:56
$value
$value
Definition: styleTest.css.php:49
EasyDeflateTest\provideIsDeflated
provideIsDeflated()
Definition: EasyDeflateTest.php:26
EasyDeflateTest\provideInflate
provideInflate()
Definition: EasyDeflateTest.php:41
true
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1985