public function testManualAssetPaths()
{
$result = Media::asset('/path/file', 'js', array('base' => '/base'));
$expected = '/base/path/file.js';
$this->assertEqual($expected, $result);
$resources = Libraries::get(true, 'resources');
$cssPath = "{$resources}/media_test/webroot/css";
$this->skipIf(!is_writable($resources), "Cannot write test app to resources directory.");
if (!is_dir($cssPath)) {
mkdir($cssPath, 0777, true);
}
Libraries::add('media_test', array('path' => "{$resources}/media_test"));
$result = Media::asset('/foo/bar', 'js', array('base' => '/base', 'check' => true));
$this->assertFalse($result);
file_put_contents("{$cssPath}/debug.css", "html, body { background-color: black; }");
$result = Media::asset('/css/debug', 'css', array('library' => 'media_test', 'base' => '/base', 'check' => true));
$expected = '/base/css/debug.css';
$this->assertEqual($expected, $result);
$result = Media::asset('/css/debug.css', 'css', array('library' => 'media_test', 'base' => '/base', 'check' => true));
$expected = '/base/css/debug.css';
$this->assertEqual($expected, $result);
$result = Media::asset('/css/debug.css?foo', 'css', array('library' => 'media_test', 'base' => '/base', 'check' => true));
$expected = '/base/css/debug.css?foo';
$this->assertEqual($expected, $result);
Libraries::remove('media_test');
unlink("{$cssPath}/debug.css");
foreach (array($cssPath, dirname($cssPath)) as $path) {
rmdir($path);
}
}