From 56d742d3c0ba7dccb54b3466ff2562c8cf86f342 Mon Sep 17 00:00:00 2001 From: Milwad Date: Sat, 6 Apr 2024 19:37:28 +0330 Subject: [PATCH] add test for `moveStub` method --- tests/Feature/LaravelStubTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Feature/LaravelStubTest.php b/tests/Feature/LaravelStubTest.php index 561ecc2..531ed8b 100644 --- a/tests/Feature/LaravelStubTest.php +++ b/tests/Feature/LaravelStubTest.php @@ -18,6 +18,7 @@ ->replace('TRAIT', 'HasFactory') ->name('new-test') ->ext('php') + ->moveStub() ->generate(); assertTrue($generate); @@ -25,6 +26,25 @@ 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')