Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/cms/classes/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,7 @@ protected function themeCombineAssets(array $url): string
$asset = $source . DIRECTORY_SEPARATOR . $file;
if (File::exists($asset)) {
$assets[] = $asset;
break 2;
break;
}
}

Expand Down
30 changes: 30 additions & 0 deletions modules/cms/tests/classes/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,34 @@ public function testMacro()
$response
);
}

public function testThemeCombineAssets(): void
{
$theme = Theme::load('test');
$controller = new Controller($theme);

// Generate a url
$url = $controller->themeUrl(['assets/css/style1.css', 'assets/css/style2.css']);
$this->assertIsString($url);

// Grab the cache key from the url
$cacheKey = 'combiner.' . str_before(basename($url), '-');

// Load the cached config
$combinerConfig = \Cache::get($cacheKey);
$this->assertIsString($combinerConfig);

// Decode the config
$combinerConfig = unserialize(base64_decode($combinerConfig));

// Assert the result is an array and includes files
$this->assertIsArray($combinerConfig);
$this->assertArrayHasKey('files', $combinerConfig);
$this->assertCount(2, $combinerConfig['files']);

// Check our input file names against our output file names
$files = array_map('basename', $combinerConfig['files']);
$this->assertTrue(in_array('style1.css', $files));
$this->assertTrue(in_array('style2.css', $files));
}
}