blob: 542a93497eac078b01058cec4d43b929a4fac937 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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() );
}
}
|