Skip to content

Commit a6fcb87

Browse files
committed
Update unit test
1 parent d4f2203 commit a6fcb87

File tree

4 files changed

+42
-11
lines changed

4 files changed

+42
-11
lines changed

.github/workflows/fix-php-code-style-issues.yml .github/workflows/fix-styling.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Fix PHP code style issues
22

3-
on: [push]
3+
on:
4+
push:
5+
paths:
6+
- '**.php'
47

58
jobs:
69
php-code-styling:
@@ -13,7 +16,7 @@ jobs:
1316
ref: ${{ github.head_ref }}
1417

1518
- name: Fix PHP code style issues
16-
uses: aglipanci/laravel-pint-action@1.0.0
19+
uses: aglipanci/laravel-pint-action@2.1.0
1720

1821
- name: Commit changes
1922
uses: stefanzweifel/git-auto-commit-action@v4

composer.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@
1818
"require": {
1919
"php": "^8.1",
2020
"bekwoh/laravel-contract": "^1.0",
21-
"illuminate/contracts": "^9.0",
22-
"spatie/laravel-package-tools": "^1.13.0"
21+
"illuminate/contracts": "^9.0|^10.0",
22+
"spatie/laravel-package-tools": "^1.14.0"
2323
},
2424
"require-dev": {
2525
"laravel/pint": "^1.0",
26-
"nunomaduro/collision": "^6.0",
26+
"nunomaduro/collision": "^7.0",
2727
"nunomaduro/larastan": "^2.0.1",
28-
"orchestra/testbench": "^7.0",
29-
"pestphp/pest": "^1.21",
30-
"pestphp/pest-plugin-laravel": "^1.1",
28+
"orchestra/testbench": "^8.0",
29+
"pestphp/pest": "^2.0",
30+
"pestphp/pest-plugin-laravel": "^2.0",
3131
"phpstan/extension-installer": "^1.1",
3232
"phpstan/phpstan-deprecation-rules": "^1.0",
3333
"phpstan/phpstan-phpunit": "^1.0",
34-
"phpunit/phpunit": "^9.5"
34+
"phpunit/phpunit": "^9.5 | ^10.0"
3535
},
3636
"autoload": {
3737
"psr-4": {

src/Commands/LaravelActionCommand.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ protected function getModelNamespace()
129129

130130
public function throwExceptionIfMissingModel()
131131
{
132-
if (empty($this->option('model')) && ! $this->option('menu') && ! $this->option('api')) {
132+
if (! $this->option('create-update')) {
133+
return;
134+
}
135+
136+
if (empty($this->option('model'))) {
133137
throw new RuntimeException('Missing model option.');
134138
}
135139
}

tests/LaravelActionTest.php

+25-1
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,34 @@
88
$this->assertTrue(in_array('make:action', $commands));
99
});
1010

11-
it('can make an action', function () {
11+
it('can make an action with model option', function () {
1212
Artisan::call('make:action CreateOrUpdateUser --model=User');
1313
$this->assertTrue(
1414
file_exists(base_path('app/Actions/CreateOrUpdateUser.php'))
1515
);
1616
unlink(base_path('app/Actions/CreateOrUpdateUser.php'));
1717
});
18+
19+
it('can make an action without model option', function () {
20+
Artisan::call('make:action CreateNewInvoice');
21+
$this->assertTrue(
22+
file_exists(base_path('app/Actions/CreateNewInvoice.php'))
23+
);
24+
unlink(base_path('app/Actions/CreateNewInvoice.php'));
25+
});
26+
27+
it('can make an API action', function () {
28+
Artisan::call('make:action StoreInvoiceDetails --api');
29+
$this->assertTrue(
30+
file_exists(base_path('app/Actions/Api/StoreInvoiceDetails.php'))
31+
);
32+
unlink(base_path('app/Actions/Api/StoreInvoiceDetails.php'));
33+
});
34+
35+
it('can make a menu action', function () {
36+
Artisan::call('make:action Sidebar --menu');
37+
$this->assertTrue(
38+
file_exists(base_path('app/Actions/Builder/Menu/Sidebar.php'))
39+
);
40+
unlink(base_path('app/Actions/Builder/Menu/Sidebar.php'));
41+
});

0 commit comments

Comments
 (0)