| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace Wikimedia\Tests; |
| 22 |
|
| 23 |
use Deflate; |
| 24 |
use MediaWikiTestCaseTrait; |
| 25 |
use PHPUnit\Framework\TestCase; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
class DeflateTest extends TestCase { |
| 31 |
use MediaWikiTestCaseTrait; |
| 32 |
|
| 33 |
public static function provideIsDeflated() { |
| 34 |
return [ |
| 35 |
|
| 36 |
[ 'rawdeflate,S8vPT0osAgA=', true ], |
| 37 |
[ 'abcdefghijklmnopqrstuvwxyz', false ], |
| 38 |
]; |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public function testIsDeflated( $data, $expected ) { |
| 45 |
$actual = Deflate::isDeflated( $data ); |
| 46 |
$this->assertSame( $expected, $actual ); |
| 47 |
} |
| 48 |
|
| 49 |
public static function provideInflate() { |
| 50 |
return [ |
| 51 |
[ 'rawdeflate,S8vPT0osAgA=', true, 'foobar' ], |
| 52 |
|
| 53 |
[ 'rawdeflate,🌻', false, 'deflate-invaliddeflate' ], |
| 54 |
|
| 55 |
[ 'rawdeflate,S8vPT0dfdAgB=', false, 'deflate-invaliddeflate' ], |
| 56 |
]; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public function testInflate( $data, $ok, $value ) { |
| 63 |
$actual = Deflate::inflate( $data ); |
| 64 |
if ( $ok ) { |
| 65 |
$this->assertStatusOK( $actual ); |
| 66 |
$this->assertStatusValue( $value, $actual ); |
| 67 |
} else { |
| 68 |
$this->assertStatusError( $value, $actual ); |
| 69 |
} |
| 70 |
} |
| 71 |
} |