MediaWiki REL1_32
EasyDeflateTest.php
Go to the documentation of this file.
1<?php
24class 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}
Copyright (C) 2018 Kunal Mehta legoktm@member.fsf.org
testIsDeflated( $data, $expected)
provideIsDeflated
testInflate( $data, $ok, $value)
provideInflate
static inflate( $data)
For content that has been compressed with deflate in the client, try to uncompress it with inflate.
static isDeflated( $data)
Whether the content is deflated.
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:2055
processing should stop and the error should be shown to the user * false
Definition hooks.txt:187