1
0
Fork 0
mirror of https://github.com/archtechx/laravel-seo.git synced 2025-12-12 01:44:03 +00:00

Refactor to command (#13)

* wip

* wip

* wip
This commit is contained in:
Lars Klopstra 2021-11-15 18:07:09 +01:00 committed by GitHub
parent 5ca343a116
commit 7b24a50bd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 113 additions and 34 deletions

View file

@ -1,14 +1,43 @@
<?php
use ArchTech\SEO\Commands\GenerateFaviconsCommand;
use function Pest\Laravel\artisan;
use function PHPUnit\Framework\assertFileDoesNotExist;
use function PHPUnit\Framework\assertFileExists;
test("it should throw an exception if the given source icon doesn't exist", function () {
seo()->favicon('i-dont-exist.png');
})->throws(Exception::class, 'Given icon path `i-dont-exist.png` does not exist.');
// Clean up generated files
beforeEach(function () {
$files = [
'favicon.ico',
'favicon.png',
];
foreach ($files as $file) {
@unlink(public_path($file));
}
});
test('it should generate two favicons', function () {
seo()->favicon(__DIR__ . '/../stubs/logo.png');
seo()->favicon();
$from = __DIR__ . '/../stubs/logo.png';
artisan(GenerateFaviconsCommand::class, [
'from' => $from,
])->assertSuccessful();
assertFileExists(public_path('favicon.ico'));
assertFileExists(public_path('favicon.png'));
});
test('it should fail because the from path is incorrect', function () {
seo()->favicon();
artisan(GenerateFaviconsCommand::class, [
'from' => 'i/dont/exist.png',
])->assertFailed();
assertFileDoesNotExist(public_path('favicon.ico'));
assertFileDoesNotExist(public_path('favicon.png'));
});