diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 3714c41e0..1679aae3b 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -134,6 +134,10 @@ php artisan queue:work - Tests have inline comment blocks above sections (/* Arrange */, /* Act */, /* Assert */). - Tests must be meaningful - avoid simple "ok" checks; validate actual behavior and data. - Use data providers for testing multiple scenarios with the same logic. + - **NEVER extend `Tests\TestCase`** - all tests must extend one of the abstract test cases from `Modules/Core/Tests/`: + - `AbstractTestCase` - Basic test case with application bootstrap + - `AbstractAdminPanelTestCase` - For admin panel tests with RefreshDatabase + - `AbstractCompanyPanelTestCase` - For company panel tests with multi-tenancy ### Export System Rules diff --git a/.junie/guidelines.md b/.junie/guidelines.md index c73466b35..7bcd817a9 100644 --- a/.junie/guidelines.md +++ b/.junie/guidelines.md @@ -183,6 +183,10 @@ class InvoiceServiceTest extends AbstractCompanyPanelTestCase 4. **Happy Paths Last:** Place success scenarios at the end 5. **Reusable Setup:** Abstract test cases for fixtures, not inline 6. **Comment Blocks:** Use `/* Arrange */`, `/* Act */`, `/* Assert */` +7. **NEVER extend `Tests\TestCase`:** All tests must extend one of the abstract test cases from `Modules/Core/Tests/`: + - `AbstractTestCase` - Basic test case with application bootstrap + - `AbstractAdminPanelTestCase` - For admin panel tests with RefreshDatabase + - `AbstractCompanyPanelTestCase` - For company panel tests with multi-tenancy ### Export Testing ```php diff --git a/Modules/Core/Tests/Feature/NumberingPanelAccessTest.php b/Modules/Core/Tests/Feature/NumberingPanelAccessTest.php index 8d8bf5322..88ffa8ad2 100644 --- a/Modules/Core/Tests/Feature/NumberingPanelAccessTest.php +++ b/Modules/Core/Tests/Feature/NumberingPanelAccessTest.php @@ -6,10 +6,10 @@ use Modules\Core\Models\Numbering; use Modules\Core\Models\User; use Modules\Core\Services\NumberingService; +use Modules\Core\Tests\AbstractTestCase; use PHPUnit\Framework\Attributes\Test; -use Tests\TestCase; -class NumberingPanelAccessTest extends TestCase +class NumberingPanelAccessTest extends AbstractTestCase { private NumberingService $service; diff --git a/Modules/Core/Tests/Unit/NumberGenerator/NumberGeneratorTemplateTest.php b/Modules/Core/Tests/Unit/NumberGenerator/NumberGeneratorTemplateTest.php index 4714105c3..7abb9827b 100644 --- a/Modules/Core/Tests/Unit/NumberGenerator/NumberGeneratorTemplateTest.php +++ b/Modules/Core/Tests/Unit/NumberGenerator/NumberGeneratorTemplateTest.php @@ -7,12 +7,12 @@ use Modules\Core\Enums\NumberingType; use Modules\Core\Models\Company; use Modules\Core\Models\Numbering; +use Modules\Core\Tests\AbstractTestCase; use Modules\Projects\Support\ProjectNumberGenerator; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\Test; -use Tests\TestCase; -class NumberGeneratorTemplateTest extends TestCase +class NumberGeneratorTemplateTest extends AbstractTestCase { use RefreshDatabase; diff --git a/Modules/Core/Tests/Unit/Services/NumberingCompanyIsolationTest.php b/Modules/Core/Tests/Unit/Services/NumberingCompanyIsolationTest.php index 641b8091f..b80fe06ba 100644 --- a/Modules/Core/Tests/Unit/Services/NumberingCompanyIsolationTest.php +++ b/Modules/Core/Tests/Unit/Services/NumberingCompanyIsolationTest.php @@ -8,14 +8,14 @@ use Modules\Core\Models\Company; use Modules\Core\Models\Numbering; use Modules\Core\Services\NumberingService; +use Modules\Core\Tests\AbstractTestCase; use Modules\Expenses\Support\ExpenseNumberGenerator; use Modules\Projects\Models\Task; use Modules\Projects\Support\TaskNumberGenerator; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\Test; -use Tests\TestCase; -class NumberingCompanyIsolationTest extends TestCase +class NumberingCompanyIsolationTest extends AbstractTestCase { use RefreshDatabase; diff --git a/Modules/Invoices/Tests/Feature/InvoiceDuplicateNumberPreventionTest.php b/Modules/Invoices/Tests/Feature/InvoiceDuplicateNumberPreventionTest.php index 9461584cb..d186ab3aa 100644 --- a/Modules/Invoices/Tests/Feature/InvoiceDuplicateNumberPreventionTest.php +++ b/Modules/Invoices/Tests/Feature/InvoiceDuplicateNumberPreventionTest.php @@ -4,12 +4,12 @@ use Modules\Core\Models\Company; use Modules\Core\Models\Numbering; +use Modules\Core\Tests\AbstractTestCase; use Modules\Invoices\Models\Invoice; use PHPUnit\Framework\Attributes\Test; use RuntimeException; -use Tests\TestCase; -class InvoiceDuplicateNumberPreventionTest extends TestCase +class InvoiceDuplicateNumberPreventionTest extends AbstractTestCase { #[Test] public function it_prevents_duplicate_invoice_numbers_within_same_company(): void diff --git a/Modules/Invoices/Tests/Feature/InvoiceNumberingSchemeChangeTest.php b/Modules/Invoices/Tests/Feature/InvoiceNumberingSchemeChangeTest.php index 42a9bb6a0..9fc1eea37 100644 --- a/Modules/Invoices/Tests/Feature/InvoiceNumberingSchemeChangeTest.php +++ b/Modules/Invoices/Tests/Feature/InvoiceNumberingSchemeChangeTest.php @@ -4,12 +4,12 @@ use Illuminate\Foundation\Testing\RefreshDatabase; use Modules\Core\Models\Numbering; +use Modules\Core\Tests\AbstractTestCase; use Modules\Invoices\Models\Invoice; use Modules\Invoices\Support\InvoiceNumberGenerator; use PHPUnit\Framework\Attributes\Test; -use Tests\TestCase; -class InvoiceNumberingSchemeChangeTest extends TestCase +class InvoiceNumberingSchemeChangeTest extends AbstractTestCase { use RefreshDatabase; diff --git a/Modules/Quotes/Tests/Feature/QuoteDuplicateNumberPreventionTest.php b/Modules/Quotes/Tests/Feature/QuoteDuplicateNumberPreventionTest.php index b31202ff8..37f51b28f 100644 --- a/Modules/Quotes/Tests/Feature/QuoteDuplicateNumberPreventionTest.php +++ b/Modules/Quotes/Tests/Feature/QuoteDuplicateNumberPreventionTest.php @@ -4,12 +4,12 @@ use Modules\Core\Models\Company; use Modules\Core\Models\Numbering; +use Modules\Core\Tests\AbstractTestCase; use Modules\Quotes\Models\Quote; use PHPUnit\Framework\Attributes\Test; use RuntimeException; -use Tests\TestCase; -class QuoteDuplicateNumberPreventionTest extends TestCase +class QuoteDuplicateNumberPreventionTest extends AbstractTestCase { #[Test] public function it_prevents_duplicate_quote_numbers_within_same_company(): void