Fix test infrastructure: CreatesApplication trait, incomplete tests, and comprehensive test fixes with DTO guideline compliance#295
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughThe pull request adds test setup traits, activates previously incomplete tests, introduces convenience HTTP methods and new invoice format enums, refactors format handlers for null-safety, updates test DTO construction patterns, and switches the test database from MariaDB to in-memory SQLite. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Comment |
Co-authored-by: nielsdrost7 <47660417+nielsdrost7@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot did you go over all my exceptions and then the conclusion was those 2 missing files? |
|
@copilot Phase 1: Test Resolution Checklist
Phase 2: Implementation PlanStep 1: Infrastructure (The "No-Errors" Foundation)The log shows widespread
Step 2: Code Restoration & API ParitySeveral tests fail with
Step 3: Silence Remaining NoiseFor tests that cannot be easily fixed due to missing complex logic:
Phase 3: GitHub Copilot Repair PromptCopy and paste the following into GitHub Copilot Chat (or use it to generate a fix for each file): PROMPT START I am repairing my Laravel test suite. I have 155 failures/errors. Please generate the code to fix these specific issues so that the tests pass or are marked as incomplete/skipped instead of throwing exceptions. 1. Infrastructure Fix (phpunit.xml or .env.testing)
2. Modules/Invoices/Http/Clients/ApiClient.php
3. Modules/Invoices/Peppol/Enums/PeppolDocumentFormat.php
4. Modules/ReportBuilder/Tests/Unit/BlockDTOTest.php
5. Modules/Invoices/Peppol/FormatHandlers/ (OioublHandler & EhfHandler)
6. Graceful Handling
I want the test run to result in "OK" (even with warnings/incomplete), but zero "Failures" and zero "Errors". |
... These tests are marked with All 31 tests have
The Should I remove the |
nielsdrost7
left a comment
There was a problem hiding this comment.
@copilot
Should I remove the markTestIncomplete() calls so the tests actually run, or are they intentionally incomplete?
Yes, remove and test if they run if possible.
Tests that "have not been implemented yet" need to get implemented
…est setup Co-authored-by: nielsdrost7 <47660417+nielsdrost7@users.noreply.github.com>
... Removed DateFieldAutoPopulationTest (10 tests):
CompanyObserverTest (1 test):
NumberGeneratorTemplateTest, NumberingCompanyIsolationTest, NumberingServiceTest:
The tests will now execute their logic instead of being marked as incomplete. The CI should run these tests on the next push. |
nielsdrost7
left a comment
There was a problem hiding this comment.
@copilot
Infrastructure Fix: Switch from MariaDB to SQLite (In-Memory) for Unit Tests.
Missing Class Fix: Restore ReportTemplateService, PeppolBisHandler, DetailItemsHandler, and FooterNotesHandler.
API Client Fix: Implement missing get(), put(), patch(), and delete() methods in ApiClient.
Enum Logic Fix: Resolve UnhandledMatchError for PEPPOL_BIS_30 in PeppolDocumentFormat.
Assertion Fix: Update PeppolDocumentFormat labels and countries to match expected test strings.
Constructor Fix: Add missing arguments to GridPositionDTO calls.
Null Safety Fix: Add null-safe operators for $invoice->customer in Peppol Handlers.
Visibility Fix: Resolve Undefined variable $dto and $config in BlockDTOTest
…O, and null safety Co-authored-by: nielsdrost7 <47660417+nielsdrost7@users.noreply.github.com>
Implemented all requested fixes in commit af4128d: Infrastructure: Switched phpunit.xml from MariaDB to SQLite ( API Client: Added Enum Fixes:
DTO Fixes:
Null Safety: Added null-safe operators ( All changes follow SOLID principles and maintain backward compatibility. Tests should now pass without the previously reported errors. |
…handlers Co-authored-by: nielsdrost7 <47660417+nielsdrost7@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes critical test infrastructure issues that prevented tests from running, enables 11 previously incomplete tests, and adds comprehensive null safety improvements across the Peppol invoice handling system. The changes address bootstrap failures in abstract test cases, switch to SQLite for faster unit testing, enhance the API client with convenience methods, fix enum handling for new Peppol formats, resolve test data initialization issues, and add null-safe operators throughout Peppol format handlers.
Key Changes:
- Added
CreatesApplicationtrait toAbstractAdminPanelTestCaseandAbstractCompanyPanelTestCaseto fix Laravel application bootstrap failures - Enabled 11 previously incomplete tests (10 in DateFieldAutoPopulationTest, 1 in CompanyObserverTest)
- Enhanced test infrastructure with SQLite in-memory database, API client HTTP method shortcuts, enum case additions, DTO constructor fixes, and comprehensive null safety across Peppol handlers
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
Modules/Core/Tests/AbstractAdminPanelTestCase.php |
Added CreatesApplication trait to enable Laravel application bootstrapping |
Modules/Core/Tests/AbstractCompanyPanelTestCase.php |
Added CreatesApplication trait to enable Laravel application bootstrapping |
phpunit.xml |
Switched from MariaDB to SQLite in-memory database for faster test execution |
Modules/Core/Tests/Unit/DateFieldAutoPopulationTest.php |
Removed 10 markTestIncomplete() calls and fixed duplicate setUp() instantiation |
Modules/Core/Tests/Unit/Observers/CompanyObserverTest.php |
Removed markTestIncomplete() to enable test execution |
Modules/ReportBuilder/Tests/Unit/BlockDTOTest.php |
Fixed 10 test methods with undefined variables and updated GridPositionDTO instantiation to use constructor |
Modules/Invoices/Http/Clients/ApiClient.php |
Added convenience methods (get(), put(), patch(), delete()) for common HTTP verbs |
Modules/Invoices/Peppol/Enums/PeppolDocumentFormat.php |
Added label() and description() cases for PEPPOL_BIS_30, EHF_30, and FACTURX; updated formatsForCountry() |
Modules/Invoices/Peppol/FormatHandlers/BaseFormatHandler.php |
Added null-safe operators for $invoice->customer property access (2 locations) |
Modules/Invoices/Peppol/FormatHandlers/PeppolBisHandler.php |
Added null-safe operators for $invoice->customer property access (7 locations) |
Modules/Invoices/Peppol/FormatHandlers/OioublHandler.php |
Added null-safe operator for $invoice->customer->peppol_id check |
Modules/Invoices/Peppol/FormatHandlers/EhfHandler.php |
Added null-safe operators for $invoice->customer property access (6 locations) |
Modules/Invoices/Peppol/FormatHandlers/FatturaPaHandler.php |
Added null-safe operators for $invoice->customer property access (3 locations) |
Modules/Invoices/Peppol/FormatHandlers/UblHandler.php |
Added null-safe operator for $invoice->customer->peppol_id check |
|
@copilot apply changes based on the comments in this thread |
… with static factory method Co-authored-by: nielsdrost7 <47660417+nielsdrost7@users.noreply.github.com>
Applied all code review changes in commit da970a3: GridPositionDTO refactored to follow DTO guidelines:
Updated production code (4 files):
Updated tests (BlockDTOTest - 4 methods):
All code now follows the project's DTO guidelines consistently. |
Refactor request method to accept RequestMethod type and remove individual HTTP method wrappers.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
GridPositionDTO::create()for convenient instantiation with validation💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Summary by CodeRabbit
New Features
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.