jenkins-bot has submitted this change and it was merged.
Change subject: Don't create Language objects during ResourceLoader tests
......................................................................
Don't create Language objects during ResourceLoader tests
Mock calls to ResourceLoaderContext::getDirection(), which creates
Language objects to get the directionality of a language.
Change-Id: Ibe6da3013e658aa7cf596c1da2f8ca1314b7cdd3
---
M tests/phpunit/LessFileCompilationTest.php
M tests/phpunit/ResourceLoaderTestCase.php
M tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
M tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
M tests/phpunit/includes/resourceloader/ResourceLoaderStartupModuleTest.php
M tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
6 files changed, 23 insertions(+), 12 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/phpunit/LessFileCompilationTest.php
b/tests/phpunit/LessFileCompilationTest.php
index 71e0f4b..df4690a 100644
--- a/tests/phpunit/LessFileCompilationTest.php
+++ b/tests/phpunit/LessFileCompilationTest.php
@@ -38,7 +38,7 @@
"$thisString must refer to a readable file"
);
- $rlContext = static::getResourceLoaderContext();
+ $rlContext = $this->getResourceLoaderContext();
// Bleh
$method = new ReflectionMethod( $this->module,
'getLessCompiler' );
diff --git a/tests/phpunit/ResourceLoaderTestCase.php
b/tests/phpunit/ResourceLoaderTestCase.php
index f5f302e..055beb0 100644
--- a/tests/phpunit/ResourceLoaderTestCase.php
+++ b/tests/phpunit/ResourceLoaderTestCase.php
@@ -1,7 +1,12 @@
<?php
abstract class ResourceLoaderTestCase extends MediaWikiTestCase {
- protected static function getResourceLoaderContext( $lang = 'en' ) {
+ /**
+ * @param string $lang
+ * @param string $dir
+ * @return ResourceLoaderContext
+ */
+ protected function getResourceLoaderContext( $lang = 'en', $dir = 'ltr'
) {
$resourceLoader = new ResourceLoader();
$request = new FauxRequest( array(
'lang' => $lang,
@@ -10,7 +15,14 @@
'skin' => 'vector',
'target' => 'test',
) );
- return new ResourceLoaderContext( $resourceLoader, $request );
+ $ctx = $this->getMockBuilder( 'ResourceLoaderContext' )
+ ->setConstructorArgs( array( $resourceLoader, $request
) )
+ ->setMethods( array( 'getDirection' ) )
+ ->getMock();
+ $ctx->expects( $this->any() )->method( 'getDirection' )->will(
+ $this->returnValue( $dir )
+ );
+ return $ctx;
}
protected function setUp() {
diff --git
a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
index 95da847..9afc54d 100644
--- a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
+++ b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
@@ -148,8 +148,7 @@
*/
public function testGetModifiedTime( $module, $expected ) {
$rl = new ResourceLoaderFileModule( $module );
- $ts = $rl->getModifiedTime( new ResourceLoaderContext(
- new ResourceLoader, new FauxRequest() ) );
+ $ts = $rl->getModifiedTime( $this->getResourceLoaderContext() );
$this->assertEquals( $ts, $expected );
}
}
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
b/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
index b25e9b0..6d1ed4e 100644
--- a/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
+++ b/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
@@ -7,7 +7,7 @@
* @covers ResourceLoaderFileModule::getDefinitionSummary
*/
public function testDefinitionSummary() {
- $context = self::getResourceLoaderContext();
+ $context = $this->getResourceLoaderContext();
$baseParams = array(
'scripts' => array( 'foo.js', 'bar.js' ),
diff --git
a/tests/phpunit/includes/resourceloader/ResourceLoaderStartupModuleTest.php
b/tests/phpunit/includes/resourceloader/ResourceLoaderStartupModuleTest.php
index 3fddc1e..69854d5 100644
--- a/tests/phpunit/includes/resourceloader/ResourceLoaderStartupModuleTest.php
+++ b/tests/phpunit/includes/resourceloader/ResourceLoaderStartupModuleTest.php
@@ -300,7 +300,7 @@
$this->setMwGlobals( 'wgResourceLoaderSources',
$case['sources'] );
}
- $context = self::getResourceLoaderContext();
+ $context = $this->getResourceLoaderContext();
$rl = $context->getResourceLoader();
$rl->register( $case['modules'] );
@@ -337,7 +337,7 @@
public function testRegistrationsMinified( $modules ) {
$this->setMwGlobals( 'wgResourceLoaderDebug', false );
- $context = self::getResourceLoaderContext();
+ $context = $this->getResourceLoaderContext();
$rl = $context->getResourceLoader();
$rl->register( $modules );
$module = new ResourceLoaderStartUpModule();
@@ -357,7 +357,7 @@
* @dataProvider provideRegistrations
*/
public function testRegistrationsUnminified( $modules ) {
- $context = self::getResourceLoaderContext();
+ $context = $this->getResourceLoaderContext();
$rl = $context->getResourceLoader();
$rl->register( $modules );
$module = new ResourceLoaderStartUpModule();
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
index 5cdfa77..4fc7378 100644
--- a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
+++ b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
@@ -79,7 +79,7 @@
* @covers ResourceLoaderFileModule::compileLessFile
*/
public function testLessFileCompilation() {
- $context = self::getResourceLoaderContext();
+ $context = $this->getResourceLoaderContext();
$basePath = __DIR__ . '/../../data/less/module';
$module = new ResourceLoaderFileModule( array(
'localBasePath' => $basePath,
@@ -113,8 +113,8 @@
'styles' => array( 'expected.css' ),
) );
- $contextLtr = self::getResourceLoaderContext( 'en' );
- $contextRtl = self::getResourceLoaderContext( 'he' );
+ $contextLtr = $this->getResourceLoaderContext( 'en', 'ltr' );
+ $contextRtl = $this->getResourceLoaderContext( 'he', 'rtl' );
// Since we want to compare the effect of @noflip+@embed
against the effect of just @embed, and
// the @noflip annotations are always preserved, we need to
strip them first.
--
To view, visit https://gerrit.wikimedia.org/r/181009
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibe6da3013e658aa7cf596c1da2f8ca1314b7cdd3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits