diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:32:59 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:32:59 -0400 |
commit | 6dc1997577fab2c366781fd7048144935afa0012 (patch) | |
tree | 8918d28c7ab4342f0738985e37af1dfc42d0e93a /tests/phpunit/includes/libs/JavaScriptMinifierTest.php | |
parent | 150f94f051128f367bc89f6b7e5f57eb2a69fc62 (diff) | |
parent | fa89acd685cb09cdbe1c64cbb721ec64975bbbc1 (diff) |
Merge commit 'fa89acd'
# Conflicts:
# .gitignore
# extensions/ArchInterWiki.sql
Diffstat (limited to 'tests/phpunit/includes/libs/JavaScriptMinifierTest.php')
-rw-r--r-- | tests/phpunit/includes/libs/JavaScriptMinifierTest.php | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/phpunit/includes/libs/JavaScriptMinifierTest.php b/tests/phpunit/includes/libs/JavaScriptMinifierTest.php index 149a28c1..d23534ed 100644 --- a/tests/phpunit/includes/libs/JavaScriptMinifierTest.php +++ b/tests/phpunit/includes/libs/JavaScriptMinifierTest.php @@ -140,6 +140,13 @@ class JavaScriptMinifierTest extends PHPUnit_Framework_TestCase { array( "5..toString();", "5..toString();" ), array( "5...toString();", false ), array( "5.\n.toString();", '5..toString();' ), + + // Boolean minification (!0 / !1) + array( "var a = { b: true };", "var a={b:!0};" ), + array( "var a = { true: 12 };", "var a={true:12};", false ), + array( "a.true = 12;", "a.true=12;", false ), + array( "a.foo = true;", "a.foo=!0;" ), + array( "a.foo = false;", "a.foo=!1;" ), ); } @@ -147,15 +154,17 @@ class JavaScriptMinifierTest extends PHPUnit_Framework_TestCase { * @dataProvider provideCases * @covers JavaScriptMinifier::minify */ - public function testJavaScriptMinifierOutput( $code, $expectedOutput ) { + public function testJavaScriptMinifierOutput( $code, $expectedOutput, $expectedValid = true ) { $minified = JavaScriptMinifier::minify( $code ); // JSMin+'s parser will throw an exception if output is not valid JS. // suppression of warnings needed for stupid crap - wfSuppressWarnings(); - $parser = new JSParser(); - wfRestoreWarnings(); - $parser->parse( $minified, 'minify-test.js', 1 ); + if ( $expectedValid ) { + MediaWiki\suppressWarnings(); + $parser = new JSParser(); + MediaWiki\restoreWarnings(); + $parser->parse( $minified, 'minify-test.js', 1 ); + } $this->assertEquals( $expectedOutput, |