Skip to content

Commit 58c223c

Browse files
committed
Fix tests under 3.7, 3.8
1 parent 2f755ee commit 58c223c

File tree

11 files changed

+27
-36
lines changed

11 files changed

+27
-36
lines changed

src/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Plugin extends BasePlugin
1313
/**
1414
* Add middleware
1515
*
16-
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The queue
16+
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The queue
1717
* @return \Cake\Http\MiddlewareQueue
1818
*/
1919
public function middleware($middlewareQueue)

src/View/Helper/AssetCompressHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ protected function _getRoute(AssetTarget $file, $base)
350350
$query = [];
351351

352352
if ($file->isThemed()) {
353-
$query['theme'] = $this->theme;
353+
$query['theme'] = $this->getView()->getTheme();
354354
}
355355

356356
$base = rtrim($base, '/') . '/';

tests/TestCase/AssetScannerTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function setUp()
2323

2424
public function testFindResolveThemePaths()
2525
{
26-
Plugin::load('Blue');
26+
$this->loadPlugins(['Blue']);
2727
$paths = [
2828
$this->_testFiles . 'css' . DS
2929
];
@@ -38,8 +38,7 @@ public function testFindResolveThemePaths()
3838

3939
public function testFindResolvePluginPaths()
4040
{
41-
Plugin::load('TestAsset');
42-
41+
$this->loadPlugins(['TestAsset']);
4342
$paths = [
4443
$this->_testFiles . 'css' . DS
4544
];

tests/TestCase/Config/ConfigFinderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function setUp()
2323
$this->_testFiles = APP;
2424
$this->testConfig = $this->_testFiles . 'config' . DS . 'config.ini';
2525

26-
Plugin::load('TestAssetIni');
26+
$this->loadPlugins(['TestAssetIni']);
2727
}
2828

2929
/**
@@ -34,7 +34,7 @@ public function setUp()
3434
public function tearDown()
3535
{
3636
parent::tearDown();
37-
Plugin::unload('TestAssetIni');
37+
$this->removePlugins(['TestAssetIni']);
3838
}
3939

4040
public function testPluginIni()

tests/TestCase/FactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function testAssetCollection()
9393
*/
9494
public function testAssetCollectionThemed()
9595
{
96-
Plugin::load('Red');
96+
$this->loadPlugins(['Red']);
9797
$config = AssetConfig::buildFromIniFile($this->themedFile, [
9898
'TEST_FILES' => APP,
9999
'WEBROOT' => TMP
@@ -120,7 +120,7 @@ public function testAssetCollectionThemed()
120120
*/
121121
public function testAssetCollectionPlugins()
122122
{
123-
Plugin::load('TestAsset');
123+
$this->loadPlugins(['TestAsset']);
124124
$config = AssetConfig::buildFromIniFile($this->pluginFile, [
125125
'TEST_FILES' => APP,
126126
'WEBROOT' => TMP

tests/TestCase/Filter/ImportInlineTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ImportInlineTest extends TestCase
1111
public function setUp()
1212
{
1313
parent::setUp();
14-
Plugin::load('Red');
14+
$this->loadPlugins(['Red']);
1515
$this->filter = new ImportInline();
1616
$settings = [
1717
'paths' => [

tests/TestCase/Filter/SprocketsTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public function setUp()
2727

2828
public function testThemeAndPluginInclusion()
2929
{
30-
Plugin::load('TestAsset');
31-
Plugin::load('Red');
30+
$this->loadPlugins(['TestAsset', 'Red']);
3231

3332
$settings = [
3433
'paths' => [],

tests/TestCase/Middleware/AssetCompressMiddlewareTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function setUp()
2929
'WEBROOT' => WWW_ROOT,
3030
'TEST_FILES' => APP
3131
];
32-
Plugin::load('TestAssetIni');
32+
$this->loadPlugins(['TestAssetIni']);
3333

3434
$config = new AssetConfig([], $map);
3535
$config->load($this->testConfig);
@@ -52,8 +52,7 @@ public function setUp()
5252
public function tearDown()
5353
{
5454
parent::tearDown();
55-
Plugin::unload('TestAssetIni');
56-
Plugin::unload('Blue');
55+
$this->removePlugins(['Blue', 'TestAssetIni']);
5756
}
5857

5958
/**
@@ -83,7 +82,7 @@ public function testBuildFile()
8382
*/
8483
public function testPluginIniBuildFile()
8584
{
86-
Plugin::load('TestAssetIni');
85+
$this->loadPlugins(['TestAssetIni']);
8786

8887
$uri = $this->request->getUri()->withPath('/cache_js/TestAssetIni.libs.js');
8988
$request = $this->request->withUri($uri);
@@ -133,7 +132,7 @@ public function testProductionMode()
133132

134133
public function testBuildThemedAsset()
135134
{
136-
Plugin::load('Blue');
135+
$this->loadPlugins(['Blue']);
137136

138137
$configFile = APP . 'config' . DS . 'themed.ini';
139138
$map = [

tests/TestCase/Shell/AssetCompressShellTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public function testBuildFiles()
7575
*/
7676
public function testBuildFilesWithTheme()
7777
{
78-
Plugin::load('Red');
79-
Plugin::load('Blue');
78+
$this->loadPlugins(['Red']);
79+
$this->loadPlugins(['Blue']);
8080
$config = AssetConfig::buildFromIniFile(
8181
$this->testConfig . 'themed.ini',
8282
['TEST_FILES' => APP, 'WEBROOT' => TMP]
@@ -127,8 +127,8 @@ public function testClear()
127127
*/
128128
public function testClearFilesWithTheme()
129129
{
130-
Plugin::load('Red');
131-
Plugin::load('Blue');
130+
$this->loadPlugins(['Red']);
131+
$this->loadPlugins(['Blue']);
132132
$files = [
133133
TMP . 'cache_css/Blue-themed.css',
134134
TMP . 'cache_css/Red-themed.css',

tests/TestCase/View/Helper/AssetCompressHelperTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function setUp()
2929
$request = new Request();
3030

3131
$view = new View($controller);
32-
$view->request = $request;
32+
$view->setRequest($request);
3333
$this->Helper = new AssetCompressHelper($view, ['noconfig' => true]);
3434
$config = AssetConfig::buildFromIniFile($testFile, [
3535
'TEST_FILES' => APP,
@@ -117,7 +117,7 @@ public function testBaseUrl()
117117
*/
118118
public function testDefinedBuildWithThemeNoBuiltAsset()
119119
{
120-
$this->Helper->theme = 'blue';
120+
$this->Helper->getView()->setTheme('Blue');
121121
$config = $this->Helper->assetConfig();
122122
$config->addTarget('themed.js', [
123123
'theme' => true,
@@ -126,7 +126,7 @@ public function testDefinedBuildWithThemeNoBuiltAsset()
126126
$result = $this->Helper->script('themed.js');
127127
$expected = [
128128
['script' => [
129-
'src' => '/cache_js/themed.js?theme=blue'
129+
'src' => '/cache_js/themed.js?theme=Blue'
130130
]]
131131
];
132132
$this->assertHtml($expected, $result);
@@ -195,7 +195,7 @@ public function testUrlGenerationProductionModePluginIni()
195195
*/
196196
public function testRawAssetsPlugin()
197197
{
198-
Plugin::load('TestAsset');
198+
$this->loadPlugins(['TestAsset']);
199199

200200
$config = AssetConfig::buildFromIniFile($this->_testFiles . 'config/plugins.ini');
201201
$config->paths('css', null, [
@@ -249,10 +249,10 @@ public function testCompiledBuildWithThemes()
249249
'theme' => true
250250
]);
251251

252-
$this->Helper->theme = 'blue';
252+
$this->Helper->getView()->setTheme('Blue');
253253
$result = $this->Helper->script('asset_test.js');
254254
$result = str_replace('/', DS, $result);
255-
$this->assertContains('blue-asset_test.js', $result);
255+
$this->assertContains('Blue-asset_test.js', $result);
256256
}
257257

258258
/**
@@ -484,7 +484,7 @@ public function testInlineScript()
484484
*/
485485
public function testNoConflictWithPluginName()
486486
{
487-
Plugin::load('Blue');
487+
$this->loadPlugins(['Blue']);
488488

489489
$result = $this->Helper->script('blue-app.js', ['raw' => true]);
490490
$expected = [

0 commit comments

Comments
 (0)