summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Bootstrap/tests/phpunit/ResourceLoaderBootstrapModuleTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/Bootstrap/tests/phpunit/ResourceLoaderBootstrapModuleTest.php')
-rw-r--r--www/wiki/extensions/Bootstrap/tests/phpunit/ResourceLoaderBootstrapModuleTest.php91
1 files changed, 91 insertions, 0 deletions
diff --git a/www/wiki/extensions/Bootstrap/tests/phpunit/ResourceLoaderBootstrapModuleTest.php b/www/wiki/extensions/Bootstrap/tests/phpunit/ResourceLoaderBootstrapModuleTest.php
new file mode 100644
index 00000000..542a9349
--- /dev/null
+++ b/www/wiki/extensions/Bootstrap/tests/phpunit/ResourceLoaderBootstrapModuleTest.php
@@ -0,0 +1,91 @@
+<?php
+
+namespace Bootstrap\Tests;
+
+use Bootstrap\ResourceLoaderBootstrapModule;
+
+use HashBagOStuff;
+
+/**
+ * @uses \Bootstrap\ResourceLoaderBootstrapModule
+ *
+ * @ingroup Test
+ *
+ * @group extension-bootstrap
+ * @group mediawiki-databaseless
+ *
+ * @license GNU GPL v3+
+ * @since 1.0
+ *
+ * @author mwjames
+ */
+class ResourceLoaderBootstrapModuleTest extends \PHPUnit_Framework_TestCase {
+
+ public function testCanConstruct() {
+
+ $this->assertInstanceOf(
+ '\Bootstrap\ResourceLoaderBootstrapModule',
+ new ResourceLoaderBootstrapModule()
+ );
+ }
+
+ public function testGetStyles() {
+
+ $resourceLoaderContext = $this->getMockBuilder( '\ResourceLoaderContext' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $instance = new ResourceLoaderBootstrapModule;
+ $instance->setCache( new HashBagOStuff );
+
+ $this->assertArrayHasKey( 'all', $instance->getStyles( $resourceLoaderContext ) );
+ }
+
+ public function testGetStylesFromPresetCache() {
+
+ $resourceLoaderContext = $this->getMockBuilder( '\ResourceLoaderContext' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $cache = new HashBagOStuff;
+
+ $cache->set(
+ wfMemcKey( 'ext', 'bootstrap', $resourceLoaderContext->getHash() ),
+ array(
+ 'storetime' => time(),
+ 'styles' => 'foo'
+ )
+ );
+
+ $instance = new ResourceLoaderBootstrapModule;
+ $instance->setCache( $cache );
+
+ $styles = $instance->getStyles( $resourceLoaderContext );
+
+ $this->assertArrayHasKey( 'all', $styles );
+ $this->assertEquals( 'foo', $styles['all'] );
+ }
+
+ public function testGetStylesTryCatchExceptionIsThrownByLessParser() {
+
+ $resourceLoaderContext = $this->getMockBuilder( '\ResourceLoaderContext' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $options = array(
+ 'external styles' => array( 'Foo' => 'bar' )
+ );
+
+ $instance = new ResourceLoaderBootstrapModule( $options );
+ $instance->setCache( new HashBagOStuff );
+
+ $result = $instance->getStyles( $resourceLoaderContext );
+
+ $this->assertContains( 'LESS compile error', $result['all'] );
+ }
+
+ public function testSupportsURLLoading() {
+ $instance = new ResourceLoaderBootstrapModule();
+ $this->assertFalse( $instance->supportsURLLoading() );
+ }
+}