Skip to content

Commit 66532db

Browse files
committed
Complete coverage
1 parent 0e2d2b2 commit 66532db

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/Asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function config(): AssetsConfig
6161
self::$config = config(AssetsConfig::class);
6262

6363
// Standardize formats
64-
self::$config->url = rtrim(self::$config->url, '/') . '/';
64+
self::$config->uri = rtrim(self::$config->uri, '/') . '/';
6565
self::$config->directory = rtrim(self::$config->directory, '/') . '/';
6666
}
6767

tests/AssetTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,21 @@ public function testIsHead()
2323
$this->assertFalse($asset->isHead());
2424
}
2525

26+
public function testUsesConfig()
27+
{
28+
$config = new AssetsConfig();
29+
Asset::useConfig($config);
30+
31+
$result = Asset::config();
32+
33+
$this->assertSame($config, $result);
34+
$this->assertNotSame(config(AssetsConfig::class), $result);
35+
}
36+
2637
public function testLoadsConfig()
2738
{
39+
Asset::useConfig(null);
40+
2841
$config = Asset::config();
2942

3043
$this->assertSame(config(AssetsConfig::class), $config);

tests/BundleTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use Tatter\Assets\Bundle;
55
use Tatter\Assets\Config\Assets as AssetsConfig;
66
use Tests\Support\AssetsTestCase;
7+
use Tests\Support\Bundles\FruitSalad;
78

89
final class BundleTest extends AssetsTestCase
910
{
@@ -20,6 +21,31 @@ public function testConstructorPaths()
2021
$this->assertEquals(Asset::createFromPath('apple.css'), $assets[0]);
2122
}
2223

24+
public function testConstructorBundles()
25+
{
26+
$bundle = new class extends Bundle {
27+
protected $bundles = [FruitSalad::class];
28+
};
29+
30+
$assets = $bundle->getAssets();
31+
32+
$this->assertCount(2, $assets);
33+
$this->assertEquals(Asset::createFromPath('apple.css'), $assets[0]);
34+
$this->assertEquals(Asset::createFromPath('banana.js'), $assets[1]);
35+
}
36+
public function testConstructorStrings()
37+
{
38+
$bundle = new class extends Bundle {
39+
protected $strings = ['foobar'];
40+
};
41+
42+
$assets = $bundle->getAssets();
43+
44+
$this->assertCount(1, $assets);
45+
$this->assertInstanceOf(Asset::class, $assets[0]);
46+
$this->assertSame('foobar', (string) $assets[0]);
47+
}
48+
2349
public function testStringable()
2450
{
2551
$asset = new class extends Bundle {

0 commit comments

Comments
 (0)