-
Notifications
You must be signed in to change notification settings - Fork 0
Test review testing rules workflow #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "permissions": { | ||
| "allow": [], | ||
| "deny": ["Shell(git push)", "Shell(gh pr create)", "Write(**)"] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Refactor following our minimalist code philosophy then organize and catalog like a librarian and obsess over code consistency. Let's take this code from an A+ to an A++ 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Analyze and meticulously catalog all the changes in this branch, including all the changes that haven't been committed yet. Report back on where the changes fall short of our development, architecture and testing rules. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| --- | ||
| globs: app/**/*.php,tests/**/*.php | ||
| --- | ||
|
|
||
| ## Testing Rules | ||
|
|
||
| **Philosophy:** "A test that never fails is not a test, it's a lie." | ||
|
|
||
| **Framework:** Pest exclusively with `it()` syntax, 60%+ coverage | ||
|
|
||
| ### Running Tests | ||
|
|
||
| - `composer pest` - run entire test suite in parallel, with coverage | ||
| - `vendor/bin/pest $TEST_FILE` - run specific test file | ||
|
|
||
| ### Test Minimalism | ||
|
|
||
| **Target:** Keep test files under 1.8x the size of source code they test. | ||
|
|
||
| **Rules:** | ||
|
|
||
| - Test core business logic only, skip framework testing | ||
| - Use dataset-driven testing: `->with([])` for multiple scenarios | ||
| - Eliminate test overlap: no two tests covering same functionality | ||
| - Consolidate assertions: `expect($x)->toBe(1)->and($y)->toBe(2)` | ||
| - Mock external dependencies only | ||
| - No performance tests unless performance is the primary concern | ||
| - Don't sacrifice readability for ratio targets | ||
|
|
||
| **Don't consolidate when:** | ||
|
|
||
| - Different public methods | ||
| - Exception vs normal flow tests | ||
| - Different setup requirements | ||
| - Distinct business logic | ||
|
|
||
| ### AAA Pattern (MANDATORY) | ||
|
|
||
| ```php | ||
| it('does something specific', function () { | ||
| // ARRANGE | ||
| $service = new Service(mock(Dependency::class)); | ||
|
|
||
| // ACT | ||
| $result = $service->performAction(); | ||
|
|
||
| // ASSERT | ||
| expect($result)->toBe('expected'); | ||
|
|
||
| // CLEANUP (when needed) | ||
| $this->resetTimeState(); | ||
| unlink($tempFile); | ||
| }); | ||
| ``` | ||
|
|
||
| **Exception tests:** Use `// ACT & ASSERT` when act triggers assertion. | ||
|
|
||
| **Organization:** Use `describe()` blocks, `beforeEach()` setup, extract helpers/traits for DRY tests. | ||
|
|
||
| ### Testing Patterns | ||
|
|
||
| **❌ FORBIDDEN:** | ||
|
|
||
| ```php | ||
| expect($x)->toBeInstanceOf(Class::class); // Type-only testing | ||
| expect($x)->toBeArray(); // Generic assertions | ||
| expect($x)->not->toBeNull(); // Meaningless | ||
| expect(true)->toBeTrue(); // Literally meaningless | ||
| sleep(...); // Use time mocking | ||
| ``` | ||
|
|
||
| **✅ REQUIRED:** | ||
|
|
||
| ```php | ||
| expect($config->getValue('host'))->toBe('example.com'); | ||
| expect($this->validator->isValid($input))->toBe($expected); | ||
| $mock->shouldReceive('method')->with('param')->andReturn('result'); | ||
| ``` | ||
|
|
||
| ### Test Types | ||
|
|
||
| **Unit Tests:** | ||
|
|
||
| - Mock all external dependencies (filesystem, HTTP, processes) | ||
| - Test single units in isolation | ||
| - Complete in milliseconds | ||
|
|
||
| **Integration Tests:** | ||
|
|
||
| - Real file operations and external processes | ||
| - CLI commands and full workflows | ||
|
|
||
| **Layer Strategy:** | ||
|
|
||
| - CLI Commands → Integration tests | ||
| - Business Services → Unit tests (mocked dependencies) | ||
| - Utilities/Helpers → Unit tests | ||
|
|
||
| ### Static Analysis | ||
|
|
||
| - Ignore PHPStan issues in tests - focus on test functionality over compliance | ||
| - Avoid excessive phpdoc just to appease types |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contradiction: tests discouraged here but required elsewhere
“Don’t worry about tests” conflicts with tests/coverage requirements in 02-tests.mdc and composer scripts. Align these rules.
🤖 Prompt for AI Agents