Skip to content

Commit

Permalink
Merge pull request #13 from savannabits/0.x-dev
Browse files Browse the repository at this point in the history
Bug Fixed: Was failing to recognize existing model when creating a si…
  • Loading branch information
coolsam726 authored Apr 7, 2024
2 parents 6813050 + c570d0b commit 4fa3df3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [debian-latest, windows-latest]
os: [ubuntu-latest, windows-latest]
php: [8.2, 8.3]
laravel: [11.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 11.*
testbench: 9.*
carbon: ^2.72
carbon: 2.72.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
4 changes: 2 additions & 2 deletions src/Commands/ControllerMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function buildParentReplacements(): array
{
$parentModelClass = $this->parseModel($this->option('parent'));

if (! class_exists($parentModelClass, false) &&
if (! class_exists($parentModelClass) &&
confirm("A {$parentModelClass} model does not exist. Do you want to generate it?", default: true)) {
$this->call('modular:make-model', ['name' => $parentModelClass, 'module' => $this->getModule()->name()]);
}
Expand All @@ -48,7 +48,7 @@ protected function buildModelReplacements(array $replace): array
{
$modelClass = $this->parseModel($this->option('model'));

if (! class_exists($modelClass, false) && confirm("A {$modelClass} model does not exist. Do you want to generate it?", default: true)) {
if (! class_exists($modelClass) && confirm("A {$modelClass} model does not exist. Do you want to generate it?", default: true)) {
$this->call('modular:make-model', ['name' => $modelClass, 'module' => $this->getModule()->name()]);
}

Expand Down
23 changes: 23 additions & 0 deletions tests/Installation/ModularConfigurationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

use function Pest\Laravel\artisan;

test('modular installs successfully', function () {
// Run modular:install, expect composer to have an entry for a local modules/* repository
artisan('modular:install', ['--no-interaction' => true])
->expectsQuestion('Would you like to star our repo on GitHub?', 'no')
->expectsOutputToContain('modular has been installed!');
});

test('composer has been configured with modules/* repository', function () {
// Run artisan modular:install command
$composerJson = json_decode(file_get_contents(base_path('composer.json')), true);
expect($composerJson['repositories'])->toBeArray()
->and($composerJson['repositories'])->toContain([
'type' => 'path',
'url' => 'modules/*',
'options' => [
'symlink' => true,
],
]);
});
1 change: 1 addition & 0 deletions tests/Installation/ModuleCreationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php

0 comments on commit 4fa3df3

Please sign in to comment.