Skip to content

Commit 7fbb79d

Browse files
Added Laravel Boost integration for development
1 parent 02aaf6f commit 7fbb79d

File tree

8 files changed

+717
-4
lines changed

8 files changed

+717
-4
lines changed

.ai/guidelines/pest/core.blade.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
## Pest
2+
3+
### Testing
4+
- If you need to verify a feature is working, write or update a Unit / Feature test.
5+
6+
### Pest Tests
7+
- All tests must be written using Pest. Use `php artisan make:test --pest <name>`.
8+
- You must not remove any tests or test files from the tests directory without approval. These are not temporary or helper files - these are core to the application.
9+
- Tests should test all of the happy paths, failure paths, and weird paths.
10+
- Tests live in the `tests/Feature` and `tests/Unit` directories.
11+
- Pest tests look and behave like this:
12+
<code-snippet name="Basic Pest Test Example" lang="php">
13+
it('is true', function () {
14+
expect(true)->toBeTrue();
15+
});
16+
</code-snippet>
17+
18+
### Running Tests
19+
20+
After you have made all changes to the code, be sure to perform the following steps in the order shown:
21+
22+
1. Delete the file `vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log`.
23+
2. Run the console command `php vendor/bin/pest`.
24+
3. Run the console command `composer style:snippets`.
25+
4. Run the console command `composer reset:snippets`.
26+
27+
If the tests fail, carefully review the output log as well as the contents of the created file `vendor/orchestra/testbench-core/laravel/storage/logs/laravel.log`.
28+
29+
Once you understand the problem, fix it.
30+
- Run the minimal number of tests using an appropriate filter before finalizing code edits.
31+
- To run all tests: `php vendor/bin/pest`.
32+
- To run all tests in a file: `php vendor/bin/pest tests/Feature/ExampleTest.php`.
33+
- To filter on a particular test name: `php vendor/bin/pest --filter=testName` (recommended after making a change to a related file).
34+
- When the tests relating to your changes are passing, ask the user if they would like to run the entire test suite to ensure everything is still passing.
35+
36+
### Pest Assertions
37+
- When asserting status codes on a response, use the specific method like `assertForbidden` and `assertNotFound` instead of using `assertStatus(403)` or similar, e.g.:
38+
<code-snippet name="Pest Example Asserting postJson Response" lang="php">
39+
it('returns all', function () {
40+
$response = $this->postJson('/api/docs', []);
41+
42+
$response->assertSuccessful();
43+
});
44+
</code-snippet>
45+
46+
### Mocking
47+
- Mocking can be very helpful when appropriate.
48+
- When mocking, you can use the `Pest\Laravel\mock` Pest function, but always import it via `use function Pest\Laravel\mock;` before using it. Alternatively, you can use `$this->mock()` if existing tests do.
49+
- You can also create partial mocks using the same import or self method.
50+
51+
### Datasets
52+
- Use datasets in Pest to simplify tests which have a lot of duplicated data. This is often the case when testing validation rules, so consider going with this solution when writing tests for validation rules.
53+
54+
<code-snippet name="Pest Dataset Example" lang="php">
55+
it('has emails', function (string $email) {
56+
expect($email)->not->toBeEmpty();
57+
})->with([
58+
'james' => '[email protected]',
59+
'taylor' => '[email protected]',
60+
]);
61+
</code-snippet>

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
* text=auto
22

3+
.ai/ export-ignore
4+
.junie/ export-ignore
5+
36
docs/ export-ignore
47

58
.github/ export-ignore

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
.idea/
2+
.cursor/
3+
.vscode/
4+
5+
!.junie/guidelines.md
6+
.junie/
7+
28
_site/
39
build/
410
node_modules/

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"require-dev": {
2424
"dragon-code/codestyler": "^6.3",
2525
"dragon-code/laravel-deploy-operations": "^7.1",
26+
"laravel/boost": "^1.1",
2627
"mockery/mockery": "^1.6",
2728
"orchestra/testbench": "^9.0 || ^10.0",
2829
"pestphp/pest": "^3.0 || ^4.0",
@@ -60,14 +61,16 @@
6061
},
6162
"scripts": {
6263
"post-update-cmd": [
63-
"vendor/bin/codestyle pint 8.2 --ansi",
64-
"vendor/bin/codestyle editorconfig --ansi",
65-
"composer normalize --ansi"
64+
"@php vendor/bin/codestyle pint 8.2 --ansi",
65+
"@php vendor/bin/codestyle editorconfig --ansi",
66+
"composer normalize --ansi",
67+
"@ai"
6668
],
6769
"post-autoload-dump": [
6870
"@clear",
6971
"@prepare"
7072
],
73+
"ai": "@php vendor/bin/testbench boost:guidelines -n",
7174
"build": "@php vendor/bin/testbench workbench:build --ansi",
7275
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
7376
"migrate": "@php vendor/bin/testbench migrate:fresh --seed --ansi",

testbench.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ laravel: '@testbench'
22

33
providers:
44
- Workbench\App\Providers\WorkbenchServiceProvider
5+
- Workbench\App\Providers\BoostServiceProvider
56
- DragonCode\LaravelFeed\LaravelFeedServiceProvider
67
- Spatie\LaravelData\LaravelDataServiceProvider
78
- DragonCode\LaravelDeployOperations\ServiceProvider
@@ -16,7 +17,7 @@ workbench:
1617
web: true
1718
api: false
1819
config: true
19-
commands: false
20+
commands: true
2021
factories: true
2122
views: false
2223
build:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Workbench\App\Boost;
6+
7+
use Laravel\Boost\Install\GuidelineComposer as BaseComposer;
8+
9+
class GuidelineComposer extends BaseComposer
10+
{
11+
protected string $userGuidelineDir = '/../../../../.ai/guidelines';
12+
}

0 commit comments

Comments
 (0)