Skip to content

Commit

Permalink
Update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
nasrulhazim committed Feb 25, 2023
1 parent d4f2203 commit a6fcb87
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Fix PHP code style issues

on: [push]
on:
push:
paths:
- '**.php'

jobs:
php-code-styling:
Expand All @@ -13,7 +16,7 @@ jobs:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
uses: aglipanci/laravel-pint-action@1.0.0
uses: aglipanci/laravel-pint-action@2.1.0

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
"require": {
"php": "^8.1",
"bekwoh/laravel-contract": "^1.0",
"illuminate/contracts": "^9.0",
"spatie/laravel-package-tools": "^1.13.0"
"illuminate/contracts": "^9.0|^10.0",
"spatie/laravel-package-tools": "^1.14.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^6.0",
"nunomaduro/collision": "^7.0",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^7.0",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.1",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.5 | ^10.0"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 5 additions & 1 deletion src/Commands/LaravelActionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ protected function getModelNamespace()

public function throwExceptionIfMissingModel()
{
if (empty($this->option('model')) && ! $this->option('menu') && ! $this->option('api')) {
if (! $this->option('create-update')) {
return;
}

if (empty($this->option('model'))) {
throw new RuntimeException('Missing model option.');
}
}
Expand Down
26 changes: 25 additions & 1 deletion tests/LaravelActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,34 @@
$this->assertTrue(in_array('make:action', $commands));
});

it('can make an action', function () {
it('can make an action with model option', function () {
Artisan::call('make:action CreateOrUpdateUser --model=User');
$this->assertTrue(
file_exists(base_path('app/Actions/CreateOrUpdateUser.php'))
);
unlink(base_path('app/Actions/CreateOrUpdateUser.php'));
});

it('can make an action without model option', function () {
Artisan::call('make:action CreateNewInvoice');
$this->assertTrue(
file_exists(base_path('app/Actions/CreateNewInvoice.php'))
);
unlink(base_path('app/Actions/CreateNewInvoice.php'));
});

it('can make an API action', function () {
Artisan::call('make:action StoreInvoiceDetails --api');
$this->assertTrue(
file_exists(base_path('app/Actions/Api/StoreInvoiceDetails.php'))
);
unlink(base_path('app/Actions/Api/StoreInvoiceDetails.php'));
});

it('can make a menu action', function () {
Artisan::call('make:action Sidebar --menu');
$this->assertTrue(
file_exists(base_path('app/Actions/Builder/Menu/Sidebar.php'))
);
unlink(base_path('app/Actions/Builder/Menu/Sidebar.php'));
});

0 comments on commit a6fcb87

Please sign in to comment.