Skip to content

Commit

Permalink
add generateIf tests
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Nov 22, 2024
1 parent 48afb16 commit 0c3cbf3
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions tests/Feature/LaravelStubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,42 @@
assertFileDoesNotExist(__DIR__ . '/../App/test.stub');
});

test('generate stub successfully with `$this->generateUnless()` method', function () {
test('generate stub successfully with `generateIf` method', function () {
$stub = __DIR__ . '/test.stub';

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

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

test('generate stub unsuccessfully with `generateIf` method', function () {
$stub = __DIR__ . '/test.stub';

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

\PHPUnit\Framework\assertFalse($generate);
});

test('generate stub successfully with `generateUnless` method', function () {
$stub = __DIR__ . '/test.stub';

$generate = LaravelStub::from($stub)
Expand All @@ -211,7 +246,7 @@
assertFileDoesNotExist(__DIR__ . '/../App/test.stub');
});

test('generate stub unsuccessfully with `$this->generateUnless()` method', function () {
test('generate stub unsuccessfully with `generateUnless` method', function () {
$stub = __DIR__ . '/test.stub';

$generate = LaravelStub::from($stub)
Expand Down

0 comments on commit 0c3cbf3

Please sign in to comment.