diff --git a/src/Stylist/Html/ThemeHtmlBuilder.php b/src/Stylist/Html/ThemeHtmlBuilder.php index 0d8bb21..edf1d70 100644 --- a/src/Stylist/Html/ThemeHtmlBuilder.php +++ b/src/Stylist/Html/ThemeHtmlBuilder.php @@ -91,7 +91,7 @@ public function image($url, $alt = null, $attributes = array(), $secure = null) */ public function url($file = '') { - return url($this->assetUrl($file)); + return asset($this->assetUrl($file)); } /** diff --git a/tests/Html/ThemeHtmlBuilderTest.php b/tests/Html/ThemeHtmlBuilderTest.php index 5432c32..3e4a0fe 100644 --- a/tests/Html/ThemeHtmlBuilderTest.php +++ b/tests/Html/ThemeHtmlBuilderTest.php @@ -50,4 +50,28 @@ public function testAssetUrlResponse() $this->assertEquals(url('themes/parent-theme/'), $this->builder->url()); $this->assertEquals(url('themes/parent-theme/favicon.ico'), $this->builder->url('favicon.ico')); } + + public function testSubfolderAssets() + { + // set subfolder + config(['app.url' => 'http://localhost/subfolder']); + config(['app.asset_url' => 'http://localhost/subfolder']); + $this->app['url']->forceRootUrl('/subfolder'); + + // check script in subfolder + $script = $this->builder->script('js/app.js'); + $this->assertContains('/subfolder/themes/parent-theme/js/app.js', (string) $script); + + // check style in subfolder + $style = $this->builder->style('css/app.css'); + $this->assertContains('/subfolder/themes/parent-theme/css/app.css', (string) $style); + + // check asset url in subfolder + $url = $this->builder->url('css/app.css'); + $this->assertContains('/subfolder/themes/parent-theme/css/app.css', (string) $url); + + // check link in subfolder + $link = $this->builder->linkAsset('css/app.css'); + $this->assertContains('/subfolder/themes/parent-theme/css/app.css', (string) $link); + } }