mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 18:34:04 +00:00
Add ViteBundlerTest
This commit is contained in:
parent
bb4bd80efe
commit
778022b42a
2 changed files with 46 additions and 3 deletions
|
|
@ -4,16 +4,18 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Features;
|
namespace Stancl\Tenancy\Features;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Foundation\Vite as FoundationVite;
|
use Illuminate\Foundation\Vite as FoundationVite;
|
||||||
use Illuminate\Support\Facades\App;
|
|
||||||
use Stancl\Tenancy\Contracts\Feature;
|
use Stancl\Tenancy\Contracts\Feature;
|
||||||
use Stancl\Tenancy\Tenancy;
|
use Stancl\Tenancy\Tenancy;
|
||||||
use Stancl\Tenancy\Vite;
|
use Stancl\Tenancy\Vite as StanclVite;
|
||||||
|
|
||||||
class ViteBundler implements Feature
|
class ViteBundler implements Feature
|
||||||
{
|
{
|
||||||
|
public function __construct(protected Application $app) { }
|
||||||
|
|
||||||
public function bootstrap(Tenancy $tenancy): void
|
public function bootstrap(Tenancy $tenancy): void
|
||||||
{
|
{
|
||||||
App::singleton(FoundationVite::class, Vite::class);
|
$this->app->singleton(FoundationVite::class, StanclVite::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
41
tests/Features/ViteBundlerTest.php
Normal file
41
tests/Features/ViteBundlerTest.php
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Vite as FoundationVite;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Stancl\Tenancy\Features\ViteBundler;
|
||||||
|
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||||
|
use Stancl\Tenancy\Vite as StanclVite;
|
||||||
|
|
||||||
|
|
||||||
|
test('replaces the vite helper instance with custom class', function () {
|
||||||
|
$concreteBindings = App::getBindings()[FoundationVite::class]['concrete'];
|
||||||
|
|
||||||
|
expect($concreteBindings(App::getInstance()))
|
||||||
|
->toBeInstanceOf(FoundationVite::class);
|
||||||
|
|
||||||
|
expect($concreteBindings(App::getInstance()))
|
||||||
|
->not->toBeInstanceOf(StanclVite::class);
|
||||||
|
|
||||||
|
config([
|
||||||
|
'tenancy.features' => [ViteBundler::class],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$tenant = Tenant::create();
|
||||||
|
|
||||||
|
tenancy()->initialize($tenant);
|
||||||
|
|
||||||
|
$concreteBindings = App::getBindings()[FoundationVite::class]['concrete'];
|
||||||
|
|
||||||
|
expect($concreteBindings)
|
||||||
|
->toBeCallable();
|
||||||
|
|
||||||
|
expect($concreteBindings(App::getInstance()))
|
||||||
|
->toBeInstanceOf(FoundationVite::class);
|
||||||
|
|
||||||
|
expect($concreteBindings(App::getInstance()))
|
||||||
|
->toBeInstanceOf(StanclVite::class);
|
||||||
|
|
||||||
|
tenancy()->end();
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue