Removed Asset view function

This commit is contained in:
Chris Kankiewicz
2025-03-16 21:43:27 -07:00
parent 03a84d9081
commit 112e629fad
4 changed files with 0 additions and 58 deletions

View File

@@ -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,

View File

@@ -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, '/');
}
}

View File

@@ -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'));
}

View File

@@ -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'));
}
}