wiki.techinc.nl/tests/phpunit/includes/resourceloader/ResourceLoaderLessVarFileModuleTest.php
Kunal Mehta d5bbd8cc62 Fix improper parameters to ReflectionMethod::invoke
The first argument to the function is supposed to be an object, or null if
the method is static.

Otherwise on PHP 7.2 the tests fail with:
 ReflectionMethod::invoke() expects parameter 1 to be object, string given

Change-Id: I7002be5809f9dfbee0788907fe85139d05c0e1fc
2018-05-17 22:30:58 -07:00

43 lines
1 KiB
PHP

<?php
/**
* @group ResourceLoader
*/
class ResourceLoaderLessVarFileModuleTest extends ResourceLoaderTestCase {
public static function providerWrapAndEscapeMessage() {
return [
[
"Foo", '"Foo"',
],
[
"Foo bananas", '"Foo bananas"',
],
[
"Who's that test? Who's that test? It's Jess!",
'"Who\\\'s that test? Who\\\'s that test? It\\\'s Jess!"',
],
[
'Hello "he" said',
'"Hello \"he\" said"',
],
[
'boo";-o-link:javascript:alert(1);color:red;content:"',
'"boo\";-o-link:javascript:alert(1);color:red;content:\""',
],
[
'"jon\'s"',
'"\"jon\\\'s\""'
]
];
}
/**
* @dataProvider providerWrapAndEscapeMessage
* @covers ResourceLoaderLessVarFileModule::wrapAndEscapeMessage
*/
public function testEscapeMessage( $msg, $expected ) {
$method = new ReflectionMethod( ResourceLoaderLessVarFileModule::class, 'wrapAndEscapeMessage' );
$method->setAccessible( true );
$this->assertEquals( $expected, $method->invoke( null, $msg ) );
}
}