b2in/tests/Feature/PublishFluxAssetsTest.php

30 lines
1 KiB
PHP

<?php
declare(strict_types=1);
use Illuminate\Support\Facades\File;
test('flux publish assets command copies javascript into public flux directory', function () {
$targetDir = public_path('flux');
if (File::isDirectory($targetDir)) {
File::deleteDirectory($targetDir);
}
$this->artisan('flux:publish-assets')
->assertSuccessful();
expect(is_file(public_path('flux/flux.js')))->toBeTrue();
expect(is_file(public_path('flux/flux.min.js')))->toBeTrue();
expect(filesize(public_path('flux/flux.min.js')))->toBeGreaterThan(1000);
File::deleteDirectory($targetDir);
});
test('composer install and update publish flux assets', function () {
$composer = json_decode((string) file_get_contents(base_path('composer.json')), true, flags: JSON_THROW_ON_ERROR);
$expectedCommand = '@php artisan flux:publish-assets --ansi --force';
expect($composer['scripts']['post-install-cmd'] ?? [])->toContain($expectedCommand);
expect($composer['scripts']['post-update-cmd'] ?? [])->toContain($expectedCommand);
});