Skip to content

Commit

Permalink
add test for moveStub method
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Apr 6, 2024
1 parent 9b5f693 commit 56d742d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/Feature/LaravelStubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,33 @@
->replace('TRAIT', 'HasFactory')
->name('new-test')
->ext('php')
->moveStub()
->generate();

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

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

$generate = LaravelStub::from($stub)
->to(__DIR__ . '/../App')
->replaces([
'CLASS' => 'Milwad',
'NAMESPACE' => 'App\Models'
])
->replace('TRAIT', 'HasFactory')
->name('new-test')
->ext('php')
->generate();

assertTrue($generate);
assertFileExists(__DIR__ . '/../App/new-test.php');
assertFileExists(__DIR__ . '/../Feature/test.stub');
});

test('throw exception when stub path is invalid', function () {
LaravelStub::from('test.stub')
->to(__DIR__ . '/../App')
Expand Down

0 comments on commit 56d742d

Please sign in to comment.