Mwjames has submitted this change and it was merged.

Change subject: Nicified some tests
......................................................................


Nicified some tests

- Add README.md
- Add compliance for coverage reports on PHPunit 4.0.*
- Moved test util classes into Skins\Chameleon\Tests\Util

Change-Id: I3c3d7f3d97f737ab7e6ecf0eaa64288a70ff2f94
---
M Chameleon.php
A README.md
M src/Hooks/SetupAfterCache.php
M tests/bootstrap.php
M tests/phpunit/ChameleonTemplateTest.php
M tests/phpunit/Components/MainContentTest.php
M tests/phpunit/Components/NavbarHorizontalTest.php
M tests/phpunit/Hooks/SetupAfterCacheTest.php
R tests/phpunit/Util/DocumentElementFinder.php
R tests/phpunit/Util/Fixture/externalmodule.less
R tests/phpunit/Util/XmlFileProvider.php
M tests/phpunit/XmlLayoutFileValidityTest.php
12 files changed, 87 insertions(+), 41 deletions(-)

Approvals:
  Mwjames: Verified; Looks good to me, approved



diff --git a/Chameleon.php b/Chameleon.php
index d209a22..86ccf55 100644
--- a/Chameleon.php
+++ b/Chameleon.php
@@ -31,8 +31,9 @@
  *
  * @file
  * @ingroup       Skins
+ *
+ * @codeCoverageIgnore
  */
-
 call_user_func( function () {
 
        if ( !defined( 'MEDIAWIKI' ) ) {
@@ -88,7 +89,6 @@
        foreach ( $chameleonComponents as $component ) {
                $GLOBALS[ 'wgAutoloadClasses' ][ 
'Skins\\Chameleon\\Components\\' . $component ] = __DIR__ . '/src/Components/' 
. $component . '.php';
        }
-
 
        $GLOBALS[ 'wgAutoloadClasses' ][ 'SkinChameleon' ] = dirname( __FILE__ 
) . '/src/SkinChameleon.php'; // register skin class (must be 'Skin' . SkinName)
        $GLOBALS[ 'wgAutoloadClasses' ][ 'Skins\Chameleon\ChameleonTemplate' ] 
= dirname( __FILE__ ) . '/src/ChameleonTemplate.php';
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..2d1669c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,33 @@
+# Chameleon skin
+[![Latest Stable 
Version](https://poser.pugx.org/mediawiki/chameleon-skin/version.png)](https://packagist.org/packages/mediawiki/chameleon-skin)
+[![Packagist download 
count](https://poser.pugx.org/mediawiki/chameleon-skin/d/total.png)](https://packagist.org/packages/mediawiki/chameleon-skin)
+[![Dependency 
Status](https://www.versioneye.com/php/mediawiki:chameleon-skin/badge.png)](https://www.versioneye.com/php/mediawiki:chameleon-skin)
+
+The [Chameleon skin][mw-chameleon-skin] uses Twitter's Bootstrap to provide a 
customizable mediawiki skin.
+
+## Requirements
+
+- PHP 5.3.2 or later
+- MediaWiki 1.22 or later
+- [Bootstrap extension][mw-bootstrap] 1.0 or later
+
+## Installation
+
+The recommended way to install this skin is by using [Composer][composer]. 
Just add the following to the MediaWiki `composer.json` file and run the `php 
composer.phar install/update` command.
+
+```json
+{
+       "require": {
+               "mediawiki/chameleon-skin": "~1.0"
+       }
+}
+```
+
+## Tests
+
+The extension provides unit tests that covers core-functionality normally run 
by a continues integration platform. Tests can also be executed manually using 
the [PHPUnit][mw-testing] configuration file found in the root directory.
+
+[mw-chameleon-skin]: https://www.mediawiki.org/wiki/Skin:Chameleon
+[mw-bootstrap]: https://www.mediawiki.org/wiki/Extension:Bootstrap
+[mw-testing]: https://www.mediawiki.org/wiki/Manual:PHP_unit_testing
+[composer]: https://getcomposer.org/
diff --git a/src/Hooks/SetupAfterCache.php b/src/Hooks/SetupAfterCache.php
index 64c6024..8b4ed0d 100644
--- a/src/Hooks/SetupAfterCache.php
+++ b/src/Hooks/SetupAfterCache.php
@@ -2,7 +2,7 @@
 
 namespace Skins\Chameleon\Hooks;
 
-use bootstrap\BootstrapManager;
+use Bootstrap\BootstrapManager;
 use RuntimeException;
 
 /**
@@ -86,13 +86,13 @@
                return array( $localFile, $remotePath );
        }
 
-       protected function isReadableFile( $path ) {
+       protected function isReadableFile( $file ) {
 
-               if ( is_readable( $path ) ) {
-                       return $path;
+               if ( is_readable( $file ) ) {
+                       return $file;
                }
 
-               throw new RuntimeException( "Expected an accessible {$path} 
file" );
+               throw new RuntimeException( "Expected an accessible {$file} 
file" );
        }
 
 }
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index c357f93..60435e4 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -8,20 +8,20 @@
        die( 'MediaWiki is not available for the test environment' );
 }
 
-function registerAutoLoader( $path, $message ) {
-       print( $message );
+function registerAutoloaderPath( $identifier, $path ) {
+       print( "\nUsing the {$identifier} vendor autoloader ...\n\n" );
        return require $path;
 }
 
-function useTestAutoLoader() {
+function runTestAutoLoader( $autoLoader = null ) {
 
        $mwVendorPath = __DIR__ . '/../../../vendor/autoload.php';
        $localVendorPath = __DIR__ . '/../vendor/autoload.php';
 
        if ( is_readable( $localVendorPath ) ) {
-               $autoLoader = registerAutoLoader( $localVendorPath, "\Using the 
local vendor class loader ...\n" );
+               $autoLoader = registerAutoloaderPath( 'local', $localVendorPath 
);
        } elseif ( is_readable( $mwVendorPath ) ) {
-               $autoLoader = registerAutoLoader( $mwVendorPath, "\nUsing the 
MediaWiki vendor class loader ...\n" );
+               $autoLoader = registerAutoloaderPath( 'MediaWiki', 
$mwVendorPath  );
        }
 
        if ( !$autoLoader instanceof \Composer\Autoload\ClassLoader ) {
@@ -33,6 +33,6 @@
        return true;
 }
 
-if ( !useTestAutoLoader() ) {
+if ( !runTestAutoLoader() ) {
        die( 'Required test class loader was not accessible' );
 }
diff --git a/tests/phpunit/ChameleonTemplateTest.php 
b/tests/phpunit/ChameleonTemplateTest.php
index acd4126..b0153d9 100644
--- a/tests/phpunit/ChameleonTemplateTest.php
+++ b/tests/phpunit/ChameleonTemplateTest.php
@@ -5,14 +5,14 @@
 use Skins\Chameleon\ChameleonTemplate;
 
 /**
- * @covers \Skins\Chameleon\ChameleonTemplate
+ * @uses \Skins\Chameleon\ChameleonTemplate
  *
  * @ingroup Test
  *
  * @group skins-chameleon
  * @group mediawiki-databaseless
  *
- * @licence GNU GPL v3+
+ * @license GNU GPL v3+
  * @since 1.0
  *
  * @author mwjames
@@ -24,13 +24,15 @@
        protected $egChameleonLayoutFile = null;
 
        protected function setUp() {
-               $this->egChameleonLayoutFile = 
$GLOBALS['egChameleonLayoutFile'];
                parent::setUp();
+
+               $this->egChameleonLayoutFile = 
$GLOBALS['egChameleonLayoutFile'];
        }
 
        protected function tearDown() {
-               parent::tearDown();
                $GLOBALS['egChameleonLayoutFile'] = 
$this->egChameleonLayoutFile;
+
+               parent::tearDown();
        }
 
        public function testCanConstruct() {
diff --git a/tests/phpunit/Components/MainContentTest.php 
b/tests/phpunit/Components/MainContentTest.php
index bf78542..6210b33 100644
--- a/tests/phpunit/Components/MainContentTest.php
+++ b/tests/phpunit/Components/MainContentTest.php
@@ -5,14 +5,14 @@
 use Skins\Chameleon\Components\MainContent;
 
 /**
- * @covers \Skins\Chameleon\Components\MainContent
+ * @uses \Skins\Chameleon\Components\MainContent
  *
  * @ingroup Test
  *
  * @group skins-chameleon
  * @group mediawiki-databaseless
  *
- * @licence GNU GPL v3+
+ * @license GNU GPL v3+
  * @since 1.0
  *
  * @author mwjames
diff --git a/tests/phpunit/Components/NavbarHorizontalTest.php 
b/tests/phpunit/Components/NavbarHorizontalTest.php
index 9c8cc18..1a323a7 100644
--- a/tests/phpunit/Components/NavbarHorizontalTest.php
+++ b/tests/phpunit/Components/NavbarHorizontalTest.php
@@ -2,21 +2,22 @@
 
 namespace Skins\Chameleon\Tests\Components;
 
+use Skins\Chameleon\Tests\Util\XmlFileProvider;
+use Skins\Chameleon\Tests\Util\DocumentElementFinder;
+
 use Skins\Chameleon\Components\NavbarHorizontal;
-use Skins\Chameleon\Tests\XmlFileProvider;
-use Skins\Chameleon\Tests\DocumentElementFinder;
 
 use Title;
 
 /**
- * @covers \Skins\Chameleon\Components\NavbarHorizontal
+ * @uses \Skins\Chameleon\Components\NavbarHorizontal
  *
  * @ingroup Test
  *
  * @group skins-chameleon
  * @group mediawiki-databaseless
  *
- * @licence GNU GPL v3+
+ * @license GNU GPL v3+
  * @since 1.0
  *
  * @author mwjames
diff --git a/tests/phpunit/Hooks/SetupAfterCacheTest.php 
b/tests/phpunit/Hooks/SetupAfterCacheTest.php
index d745e57..04c5cd2 100644
--- a/tests/phpunit/Hooks/SetupAfterCacheTest.php
+++ b/tests/phpunit/Hooks/SetupAfterCacheTest.php
@@ -5,23 +5,31 @@
 use Skins\Chameleon\Hooks\SetupAfterCache;
 
 /**
- * @covers \Skins\Chameleon\Hooks\SetupAfterCache
+ * @uses \Skins\Chameleon\Hooks\SetupAfterCache
  *
  * @ingroup Test
  *
  * @group skins-chameleon
  * @group mediawiki-databaseless
  *
- * @licence GNU GPL v3+
+ * @license GNU GPL v3+
  * @since 1.0
  *
  * @author mwjames
  */
 class SetupAfterCacheTest extends \PHPUnit_Framework_TestCase {
 
+       protected $dummyExternalModule = null;
+
+       protected function setUp() {
+               parent::setUp();
+
+               $this->dummyExternalModule = __DIR__ . '/../Util/Fixture/' . 
'externalmodule.less';
+       }
+
        public function testCanConstruct() {
 
-               $bootstrapManager = $this->getMockBuilder( 
'\bootstrap\BootstrapManager' )
+               $bootstrapManager = $this->getMockBuilder( 
'\Bootstrap\BootstrapManager' )
                        ->disableOriginalConstructor()
                        ->getMock();
 
@@ -35,7 +43,7 @@
 
        public function 
testProcessWithValidExternalModuleWithoutLessVariables() {
 
-               $bootstrapManager = $this->getMockBuilder( 
'\bootstrap\BootstrapManager' )
+               $bootstrapManager = $this->getMockBuilder( 
'\Bootstrap\BootstrapManager' )
                        ->disableOriginalConstructor()
                        ->getMock();
 
@@ -45,21 +53,21 @@
                $bootstrapManager->expects( $this->at( 2 ) )
                        ->method( 'addExternalModule' )
                        ->with(
-                               $this->equalTo( __DIR__ . '/../Fixture/' . 
'externalmodule.less' ),
+                               $this->equalTo( $this->dummyExternalModule ),
                                $this->equalTo( '' ) );
 
                $bootstrapManager->expects( $this->at( 3 ) )
                        ->method( 'addExternalModule' )
                        ->with(
-                               $this->equalTo( __DIR__ . '/../Fixture/' . 
'externalmodule.less' ),
+                               $this->equalTo( $this->dummyExternalModule  ),
                                $this->equalTo( 'someRemoteWeDontCheck' ) );
 
                $bootstrapManager->expects( $this->never() )
                        ->method( 'setLessVariable' );
 
                $mixedExternalStyleModules = array(
-                       __DIR__ . '/../Fixture/' . 'externalmodule.less',
-                       __DIR__ . '/../Fixture/' . 'externalmodule.less' => 
'someRemoteWeDontCheck'
+                       $this->dummyExternalModule ,
+                       $this->dummyExternalModule  => 'someRemoteWeDontCheck'
                );
 
                $configuration = array(
@@ -78,9 +86,7 @@
 
        public function testProcessWithInvalidExternalModuleThrowsException() {
 
-               $this->setExpectedException( 'RuntimeException' );
-
-               $bootstrapManager = $this->getMockBuilder( 
'\bootstrap\BootstrapManager' )
+               $bootstrapManager = $this->getMockBuilder( 
'\Bootstrap\BootstrapManager' )
                        ->disableOriginalConstructor()
                        ->getMock();
 
@@ -89,7 +95,7 @@
                        ->will( $this->returnValue( true ) );
 
                $externalStyleModules = array(
-                       __DIR__ . '/../Fixture/' . 
'externalmoduleDoesNotExist.less'
+                       __DIR__ . '/../Util/Fixture/' . 
'externalmoduleDoesNotExist.less'
                );
 
                $configuration = array(
@@ -103,12 +109,14 @@
                        $configuration
                );
 
+               $this->setExpectedException( 'RuntimeException' );
+
                $instance->process();
        }
 
        public function testProcessWithLessVariables() {
 
-               $bootstrapManager = $this->getMockBuilder( 
'\bootstrap\BootstrapManager' )
+               $bootstrapManager = $this->getMockBuilder( 
'\Bootstrap\BootstrapManager' )
                        ->disableOriginalConstructor()
                        ->getMock();
 
diff --git a/tests/phpunit/DocumentElementFinder.php 
b/tests/phpunit/Util/DocumentElementFinder.php
similarity index 94%
rename from tests/phpunit/DocumentElementFinder.php
rename to tests/phpunit/Util/DocumentElementFinder.php
index c959092..da98bd6 100644
--- a/tests/phpunit/DocumentElementFinder.php
+++ b/tests/phpunit/Util/DocumentElementFinder.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Skins\Chameleon\Tests;
+namespace Skins\Chameleon\Tests\Util;
 
 use DOMDocument;
 use DOMElement;
@@ -13,7 +13,7 @@
  * @group skins-chameleon
  * @group mediawiki-databaseless
  *
- * @licence GNU GPL v3+
+ * @license GNU GPL v3+
  * @since 1.0
  *
  * @author mwjames
diff --git a/tests/phpunit/Fixture/externalmodule.less 
b/tests/phpunit/Util/Fixture/externalmodule.less
similarity index 100%
rename from tests/phpunit/Fixture/externalmodule.less
rename to tests/phpunit/Util/Fixture/externalmodule.less
diff --git a/tests/phpunit/XmlFileProvider.php 
b/tests/phpunit/Util/XmlFileProvider.php
similarity index 94%
rename from tests/phpunit/XmlFileProvider.php
rename to tests/phpunit/Util/XmlFileProvider.php
index 2a69681..9fefbdb 100644
--- a/tests/phpunit/XmlFileProvider.php
+++ b/tests/phpunit/Util/XmlFileProvider.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Skins\Chameleon\Tests;
+namespace Skins\Chameleon\Tests\Util;
 
 use RuntimeException;
 
@@ -10,7 +10,7 @@
  * @group skins-chameleon
  * @group mediawiki-databaseless
  *
- * @licence GNU GPL v3+
+ * @license GNU GPL v3+
  * @since 1.0
  *
  * @author mwjames
diff --git a/tests/phpunit/XmlLayoutFileValidityTest.php 
b/tests/phpunit/XmlLayoutFileValidityTest.php
index 267538d..7cbaae3 100644
--- a/tests/phpunit/XmlLayoutFileValidityTest.php
+++ b/tests/phpunit/XmlLayoutFileValidityTest.php
@@ -2,6 +2,8 @@
 
 namespace Skins\Chameleon\Tests;
 
+use Skins\Chameleon\Tests\Util\XmlFileProvider;
+
 use DOMDocument;
 use RuntimeException;
 
@@ -11,7 +13,7 @@
  * @group skins-chameleon
  * @group mediawiki-databaseless
  *
- * @licence GNU GPL v3+
+ * @license GNU GPL v3+
  * @since 1.0
  *
  * @author mwjames

-- 
To view, visit https://gerrit.wikimedia.org/r/131014
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3c3d7f3d97f737ab7e6ecf0eaa64288a70ff2f94
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/skins/chameleon
Gerrit-Branch: master
Gerrit-Owner: Mwjames <jamesin.hongkon...@gmail.com>
Gerrit-Reviewer: Mwjames <jamesin.hongkon...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to