Skip to content

Commit

Permalink
Update LaravelStubTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Apr 6, 2024
1 parent e9f579c commit 9b5f693
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions tests/Feature/LaravelStubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

use Binafy\LaravelStub\Facades\LaravelStub;

use function PHPUnit\Framework\assertFileDoesNotExist;
use function PHPUnit\Framework\assertFileExists;
use function PHPUnit\Framework\assertTrue;

test('generate stub successfully with all options', function () {
$stub = __DIR__ . '/test.stub';

Expand All @@ -16,31 +20,31 @@
->ext('php')
->generate();

\PHPUnit\Framework\assertTrue($generate);
\PHPUnit\Framework\assertFileExists(__DIR__ . '/../App/new-test.php');
\PHPUnit\Framework\assertFileDoesNotExist(__DIR__ . '/../App/test.stub');
assertTrue($generate);
assertFileExists(__DIR__ . '/../App/new-test.php');
assertFileDoesNotExist(__DIR__ . '/../App/test.stub');
});

test('throw exception when stub path is invalid', function () {
$generate = LaravelStub::from('test.stub')
LaravelStub::from('test.stub')
->to(__DIR__ . '/../App')
->name('new-test')
->ext('php')
->generate();

\PHPUnit\Framework\assertFileDoesNotExist(__DIR__ . '/../App/new-test.php');
\PHPUnit\Framework\assertFileExists(__DIR__ . '/../App/test.stub');
assertFileDoesNotExist(__DIR__ . '/../App/new-test.php');
assertFileExists(__DIR__ . '/../App/test.stub');
})->expectExceptionMessage('The stub file does not exist, please enter a valid path.');

test('throw exception when destination path is invalid', function () {
$generate = LaravelStub::from(__DIR__ . '/test.stub')
LaravelStub::from(__DIR__ . '/test.stub')
->to('App')
->name('new-test')
->ext('php')
->generate();

\PHPUnit\Framework\assertFileDoesNotExist(__DIR__ . '/../App/new-test.php');
\PHPUnit\Framework\assertFileExists(__DIR__ . '/../App/test.stub');
assertFileDoesNotExist(__DIR__ . '/../App/new-test.php');
assertFileExists(__DIR__ . '/../App/test.stub');
})->expectExceptionMessage('The given folder path is not valid.');

test('download the stub file', function () {
Expand All @@ -58,6 +62,6 @@
->download();

expect($downloadInstance)->toBeInstanceOf(\Symfony\Component\HttpFoundation\BinaryFileResponse::class);
\PHPUnit\Framework\assertFileExists(__DIR__ . '/../App/new-test.php');
\PHPUnit\Framework\assertFileDoesNotExist(__DIR__ . '/../App/test.stub');
assertFileExists(__DIR__ . '/../App/new-test.php');
assertFileDoesNotExist(__DIR__ . '/../App/test.stub');
});

0 comments on commit 9b5f693

Please sign in to comment.