mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-26 15:25:18 +02:00
Removed Asset view function
This commit is contained in:
@@ -16,7 +16,6 @@ return [
|
||||
/** Path definitions and helpers */
|
||||
'base_path' => dirname(__DIR__, 2),
|
||||
'app_path' => dirname(__DIR__),
|
||||
'asset_path' => string('{app_path}/assets'),
|
||||
'cache_path' => string('{app_path}/cache'),
|
||||
'config_path' => string('{app_path}/config'),
|
||||
'source_path' => string('{app_path}/src'),
|
||||
@@ -49,7 +48,6 @@ return [
|
||||
/** Array of view functions */
|
||||
'view_functions' => [
|
||||
ViewFunctions\Analytics::class,
|
||||
ViewFunctions\Asset::class,
|
||||
ViewFunctions\Breadcrumbs::class,
|
||||
ViewFunctions\Config::class,
|
||||
ViewFunctions\FileUrl::class,
|
||||
|
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\ViewFunctions;
|
||||
|
||||
use App\Config;
|
||||
use Tightenco\Collect\Support\Collection;
|
||||
|
||||
class Asset extends ViewFunction
|
||||
{
|
||||
protected string $name = 'asset';
|
||||
|
||||
/** Create a new Asset object. */
|
||||
public function __construct(
|
||||
private Config $config
|
||||
) {}
|
||||
|
||||
/** Return the path to an asset. */
|
||||
public function __invoke(string $path): string
|
||||
{
|
||||
$path = '/' . ltrim($path, '/');
|
||||
|
||||
return 'app/assets/' . ltrim($path, '/');
|
||||
}
|
||||
}
|
@@ -40,7 +40,6 @@ class TestCase extends BaseTestCase
|
||||
$this->cache = new ArrayAdapter($this->config->get('cache_lifetime'));
|
||||
|
||||
$this->container->set('base_path', $this->testFilesPath);
|
||||
$this->container->set('asset_path', $this->filePath('app/assets'));
|
||||
$this->container->set('cache_path', $this->filePath('app/cache'));
|
||||
}
|
||||
|
||||
|
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\ViewFunctions;
|
||||
|
||||
use App\ViewFunctions\Asset;
|
||||
use Tests\TestCase;
|
||||
|
||||
/** @covers \App\ViewFunctions\Asset */
|
||||
class AssetTest extends TestCase
|
||||
{
|
||||
public function test_it_can_return_an_asset_path(): void
|
||||
{
|
||||
$this->container->set('base_path', $this->filePath('.'));
|
||||
$asset = new Asset($this->config);
|
||||
|
||||
$this->assertEquals('app/assets/app.css?id=417c7a9bc03852aafb27', $asset('app.css'));
|
||||
$this->assertEquals('app/assets/app.js?id=6753a7269276c7b52692', $asset('app.js'));
|
||||
$this->assertEquals('app/assets/images/icon.png', $asset('images/icon.png'));
|
||||
}
|
||||
|
||||
public function test_it_can_return_an_asset_path_without_a_mix_manifest_file(): void
|
||||
{
|
||||
$this->container->set('asset_path', $this->filePath('.'));
|
||||
|
||||
$asset = new Asset($this->config);
|
||||
|
||||
$this->assertEquals('app/assets/app.css', $asset('app.css'));
|
||||
$this->assertEquals('app/assets/app.js', $asset('app.js'));
|
||||
$this->assertEquals('app/assets/images/icon.png', $asset('images/icon.png'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user