Skip to content

Conversation

@Trusted97
Copy link
Owner

@Trusted97 Trusted97 commented Nov 27, 2025

Summary by CodeRabbit

  • Tests
    • Large test revamp: many new unit and integration tests for forms, DTOs and build workflows; several controller/manager tests reworked, renamed and finalised; some legacy tests removed.
  • Chores
    • Configuration DTO fields made public and additional DTO setters added.
  • Style
    • Minor PHPDoc/formatting tweaks, typed property and attribute modernisation in tests; one coding-style rule removed.

✏️ Tip: You can customize this high-level summary in your review settings.

@Trusted97 Trusted97 self-assigned this Nov 27, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2025

Walkthrough

Added many PHPUnit tests (integration, form, and DTO unit tests), modernized existing tests (final classes, typed properties, DataProvider attributes), introduced setters on DTOs, changed many Configuration properties from private to public, removed an old Satis test file, and applied minor doc and php-cs-fixer config edits.

Changes

Cohort / File(s) Summary
Doc formatting
src/Validator/Constraints/Repository.php
Removed an empty line inside a PHPDoc block (documentation-only change).
PHP CS Fixer config
.php-cs-fixer.dist.php
Removed the php_unit_strict rule from the ruleset.
DTO source changes
src/DTO/Abandoned.php, src/DTO/PackageStability.php, src/DTO/Configuration.php
Added setters: Abandoned::setPackage(), Abandoned::setReplacement(), PackageStability::setPackage(), PackageStability::setStability(). Changed many Configuration properties from private to public (visibility changes).
Integration tests (new)
tests/Integration/BuildCommandTest.php
New KernelTestCase integration tests for the Satis BuildCommand: missing config, minimal config, and default form config scenarios using vfsStream.
Tests removed
tests/Composer/Satis/Command/BuildCommandTest.php, tests/app/ApplicationKernelTest.php
Deleted legacy test files (old Satis BuildCommand test removed; old app/ApplicationKernelTest deleted).
Application test (added)
tests/Application/ApplicationKernelTest.php
New WebTestCase asserting HTTP 200 and specific page title when public/index.html is missing.
Controller tests modernized
tests/Controller/AdminControllerTest.php, tests/Controller/SecurityControllerTest.php
Converted classes to final, renamed test methods, reworked admin CRUD flow and login flow, added helper assertRepositoryInConfig().
Manager & Persister tests updated
tests/Manager/ManagerConfigValidatorTest.php, tests/Persister/FilePersisterTest.php
Converted to final, tightened property types/visibility, migrated DataProvider docblocks to PHP 8 attribute, updated FilePersister constructor usage (added third argument), modernized assertions.
Form tests added
tests/Form/AbandonedTypeTest.php, tests/Form/ArchiveTypeTest.php, tests/Form/DeleteFormTypeTest.php, tests/Form/LoginFormTest.php, tests/Form/PackageConstraintTypeTest.php, tests/Form/PackageStabilityTypeTest.php
New PHPUnit form tests validating fields, submission behavior, CSRF token IDs, placeholders, and DTO mapping.
DTO tests added
tests/DTO/*
tests/DTO/AbandonedTest.php, tests/DTO/ArchiveTest.php, tests/DTO/ConfigurationTest.php, tests/DTO/PackageConstraintTest.php, tests/DTO/PackageStabilityTest.php, tests/DTO/RepositoryTest.php
New unit tests covering defaults, getters/setters, and behavior for DTO classes.
Traits & test utilities
tests/Traits/SchemaValidatorTrait.php, tests/Traits/VfsTrait.php
Simplified schema retrieval call, replaced Validator::check() with Validator::validate(), and changed $vfsRoot to typed nullable vfsStreamDirectory.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Areas requiring extra attention:

  • Public visibility changes in src/DTO/Configuration.php (encapsulation and potential external mutation).
  • Call sites and tests expecting the old FilePersister::__construct() signature must be updated to provide the new third argument.
  • Integration BuildCommand tests vs. removed Satis test: confirm coverage parity and proper vfsStream lifecycle.
  • PHPUnit DataProvider attribute usage and CI PHP/PHPUnit compatibility.
  • DTO setters that ignore null inputs — ensure serializer/normalizer interactions remain correct.

Poem

🐇 I hopped through tests both old and new,
Finalized classes, typed roots too.
DTOs gained setters, configs opened wide,
Build tests marched in with vfs by their side.
A rabbit's small cheer — code springs forward with pride.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'refactor: phpunit test' is vague and generic, using non-descriptive terms that don't convey meaningful information about the substantial changes across the changeset. Replace with a more specific title that highlights the main refactoring objective, such as 'refactor: restructure PHPUnit tests with improved patterns and DTOs' or 'refactor: modernize test suite with typed properties and explicit flows'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor-phpunit-test

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e04f665 and 600c1f1.

📒 Files selected for processing (1)
  • tests/Application/ApplicationKernelTest.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/Application/ApplicationKernelTest.php

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
tests/Integration/BuildCommandTest.php (3)

93-93: Unused kernel boot result.

self::bootKernel()->getContainer() is called but the container is not used. If the kernel is not needed for this test, consider removing this line. If it is needed for side effects (e.g., loading services), the intent should be clarified with a comment.

-        self::bootKernel()->getContainer();
+        // Boot kernel not needed for this test as we manually construct dependencies

Or if the kernel is required:

-        self::bootKernel()->getContainer();
+        self::bootKernel(); // Required for ... (add reason)

113-120: Consider cleaner debugging approach.

The echo statements help debug failures but bypass PHPUnit's output handling. Consider including the debug information in the assertion message or re-throwing with additional context:

         try {
             $exitCode = $application->run($input, $output);
-            self::assertSame(0, $exitCode, 'Expected exit code 0 for default form config build.');
+            self::assertSame(
+                0,
+                $exitCode,
+                \sprintf(
+                    "Expected exit code 0 for default form config build.\nConfig: %s\nOutput: %s",
+                    $configFile->getContent(),
+                    $output->fetch()
+                )
+            );
         } catch (AssertionFailedError $error) {
-            echo $configFile->getContent();
-            echo $output->fetch();
             throw $error;
         }

154-172: Duplicated serializer creation logic.

The createSerializer() method duplicates code from FilePersisterTest::testJsonPersisterNormalizationWorks() (lines 93-110). Consider extracting this to a shared trait or factory to reduce duplication and ensure consistent serializer configuration across tests.

tests/Controller/SecurityControllerTest.php (1)

37-39: Redundant redirection assertions.

assertInstanceOf(RedirectResponse::class) already implies isRedirection() is true. The second assertion is redundant.

         $response = $client->getResponse();
         self::assertInstanceOf(RedirectResponse::class, $response, 'Invalid login submission must redirect.');
-        self::assertTrue($response->isRedirection(), 'Response must be a redirection.');
         self::assertStringEndsWith('/login', $response->getTargetUrl(), 'Failed login must redirect back to /login.');

Same applies to lines 48-49.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2db3cd0 and 0c51df2.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • src/Validator/Constraints/Repository.php (0 hunks)
  • tests/Application/ApplicationKernelTest.php (1 hunks)
  • tests/Composer/Satis/Command/BuildCommandTest.php (0 hunks)
  • tests/Controller/AdminControllerTest.php (2 hunks)
  • tests/Controller/SecurityControllerTest.php (1 hunks)
  • tests/Integration/BuildCommandTest.php (1 hunks)
  • tests/Manager/ManagerConfigValidatorTest.php (1 hunks)
  • tests/Persister/FilePersisterTest.php (3 hunks)
  • tests/Traits/SchemaValidatorTrait.php (1 hunks)
  • tests/Traits/VfsTrait.php (1 hunks)
  • tests/app/ApplicationKernelTest.php (0 hunks)
💤 Files with no reviewable changes (3)
  • tests/app/ApplicationKernelTest.php
  • tests/Composer/Satis/Command/BuildCommandTest.php
  • src/Validator/Constraints/Repository.php
🧰 Additional context used
🧬 Code graph analysis (2)
tests/Integration/BuildCommandTest.php (5)
src/DTO/Archive.php (2)
  • Archive (12-154)
  • setFormat (58-63)
src/DTO/Configuration.php (2)
  • Configuration (8-388)
  • setArchive (240-243)
src/Persister/ConfigurationNormalizer.php (1)
  • ConfigurationNormalizer (16-158)
src/Persister/FilePersister.php (1)
  • FilePersister (9-102)
src/Persister/JsonPersister.php (1)
  • JsonPersister (17-158)
tests/Persister/FilePersisterTest.php (4)
src/Persister/FilePersister.php (1)
  • FilePersister (9-102)
src/Persister/JsonPersister.php (1)
  • JsonPersister (17-158)
src/DTO/Configuration.php (5)
  • Configuration (8-388)
  • getRequire (218-221)
  • setRepositories (205-213)
  • setRequire (226-232)
  • addMinimumStabilityPerPackage (271-274)
src/DTO/PackageConstraint.php (2)
  • setConstraint (32-37)
  • PackageConstraint (5-38)
🔇 Additional comments (18)
tests/Traits/SchemaValidatorTrait.php (2)

12-12: LGTM: Clean refactor to inline expression.

The simplified one-liner removes the unnecessary intermediate variable while maintaining the same functionality.


18-18: The API method change is verified and correct.

The JsonSchema library's Validator::validate() is the current and correct method to use. The web search confirms that there is no public Validator::check() method in recent releases of the justinrainbow/json-schema library. The code in SchemaValidatorTrait.php line 18 is already using the proper API with the correct signature: $validator->validate($content, $schema), followed by isValid() and getErrors() checks that match the documented behavior. No changes are needed.

tests/Traits/VfsTrait.php (1)

10-10: LGTM!

Good modernization to use PHP 7.4+ typed property declaration. The nullable type is appropriate since vfsTearDown() sets the property to null.

tests/Persister/FilePersisterTest.php (3)

28-33: LGTM!

Good refactoring to use final class declaration and tightening property visibility to private with explicit nullable type. Test properties should be private as they're internal to the test class.


54-83: LGTM!

Well-structured test with clear naming, descriptive assertion messages, and proper schema validation. The flow tests both initial flush and truncation scenarios comprehensively.


85-152: LGTM!

Comprehensive normalization test that validates the full load-modify-flush-reload cycle. Good use of PHP 8 named arguments for the ObjectNormalizer constructor, improving readability.

tests/Manager/ManagerConfigValidatorTest.php (2)

18-24: LGTM!

Good modernization with final class declaration and PHPUnit 10's #[DataProvider] attribute. The typed vfsStreamFile property is appropriately initialized in setUp().


46-67: Test logic appears disconnected from the mocked persister.

The test copies a fixture into vfs, creates a mocked JsonPersister that returns a fresh Configuration, then calls $manager->addAll([]). However:

  1. The mock's load() returns an empty Configuration, not the fixture's content
  2. The mock's flush() doesn't write to the vfs file
  3. The schema validation (lines 59-60) validates the original fixture content, not the output of addAll([])

If the intent is purely to validate that fixture files are valid Satis schemas, the mock interactions are unnecessary. If testing RepositoryManager behavior, the mock prevents actual persistence.

Consider clarifying the test's purpose:

  • If testing fixture validity: remove the mock and just validate the fixtures directly
  • If testing RepositoryManager: use a real persister or configure the mock to capture and validate flushed content
tests/Integration/BuildCommandTest.php (3)

30-44: LGTM!

Good test setup with vfsStream for filesystem isolation. The nullable typed property with explicit initialization in setUp() and cleanup in tearDown() follows the pattern established in VfsTrait.


46-61: LGTM!

Clear negative test case that validates proper error handling when the config file is missing.


63-86: LGTM!

Thorough integration test that validates the complete build output including index.html, packages.json, and the include directory with contents.

tests/Application/ApplicationKernelTest.php (1)

19-43: Real filesystem manipulation in test may cause issues.

This test renames the actual public/index.html file, which differs from other tests that use vfsStream for isolation. While the finally block provides cleanup, consider these risks:

  1. If the test process is killed (SIGKILL), the file won't be restored
  2. Parallel test execution could conflict if multiple tests touch the same file
  3. CI environments may have the file in unexpected states

Consider whether this test could use vfsStream for full isolation, or add a safeguard in tearDown() to ensure restoration even if an unexpected error occurs. Alternatively, document why real filesystem access is necessary here.

tests/Controller/SecurityControllerTest.php (2)

10-12: LGTM!

Good refactoring to final class and more descriptive method name. The test now clearly communicates it tests the complete admin login flow.


16-55: LGTM!

Well-organized test with clear phase comments and comprehensive coverage of the authentication flow. The descriptive assertion messages will help diagnose failures quickly.

tests/Controller/AdminControllerTest.php (4)

11-11: LGTM!

Appropriate use of final class declaration for the test class.


27-38: LGTM!

Good smoke test verifying the admin index page loads successfully and contains the expected navigation links.


40-92: LGTM!

Comprehensive CRUD workflow test with clear phase comments. Good use of disableReboot() to maintain client state across operations, and the helper method provides clean validation of persisted state.


94-115: LGTM!

Clean helper method for validating repository persistence. The use of assertObjectHasProperty aligns with PHPUnit 10+ best practices.

Note: The helper validates the first repository. This works for the current test flow but would need adjustment if testing multiple repositories.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (9)
tests/Form/DeleteFormTypeTest.php (1)

20-56: CSRF option and required-entity tests correctly mirror DeleteFormType behavior

The three tests accurately cover:

  • CSRF being enabled and the csrf_token_id format when getId() returns a value.
  • The fallback csrf_token_id prefix when no getId() exists.
  • The requirement of the entity option via MissingOptionsException.

As an optional improvement, you could add a fourth test for an entity that has getId() but returns null, to explicitly cover that branch of the normalizer as well.

tests/Form/LoginFormTest.php (1)

33-47: Valid data submission test looks good.

The test correctly verifies form synchronization and data binding for the username and password fields.

Minor observation: Line 38 includes 'login' => true in the submitted data. Since login is a SubmitType field, including data for it is unusual (submit buttons don't typically hold data values). While Symfony handles this gracefully, you might consider omitting it for clarity.

Consider adding test coverage for validation scenarios (e.g., missing required fields, invalid formats) if validation constraints are defined on the form or data class.

src/DTO/PackageStability.php (1)

21-26: Consider documenting or reconsidering the silent null-ignore pattern.

The setter accepts ?string but silently ignores null values. While this may be intentional for form-data mapping (where empty submissions could pass null), it can lead to confusion—callers might expect setPackage(null) to either throw or actually set the value.

If this is intentional for form compatibility, a brief PHPDoc explaining the behavior would help:

+    /**
+     * Sets the package name. Null values are ignored to preserve existing data.
+     */
     public function setPackage(?string $package): void

Alternatively, if strict typing is preferred, match Abandoned::setPackage(string $package) for consistency across DTOs.

tests/Form/PackageStabilityTypeTest.php (1)

51-59: Consider adding specific error message assertions for robustness.

The test checks error count, which could pass with different validation errors. For more robust testing, consider asserting on the specific error messages:

     $this->assertFalse($form->isValid());
     $errors = $form->getErrors(true);
     $this->assertCount(2, $errors);
+    // Optionally verify specific constraint violations
+    $messages = array_map(fn($e) => $e->getMessage(), iterator_to_array($errors));
+    $this->assertContains('This value should not be blank.', $messages);

This is optional—the current test is functional.

src/DTO/Configuration.php (2)

12-96: Reconsider exposing properties publicly while retaining getters/setters.

Making these properties public creates redundancy with the existing getter/setter methods and breaks the encapsulation pattern. This dual-access approach can lead to:

  • Inconsistent usage patterns across the codebase (direct access vs. methods)
  • Difficulty enforcing validation or business logic in setters
  • Tighter coupling between tests and implementation details

If the goal is to simplify testing, consider these alternatives:

  1. Keep properties private and continue using public methods in tests (recommended for maintainability)
  2. If direct property access is required for serialization frameworks, document this intent and consider whether getters/setters are still needed
  3. Use PHP 8.1+ readonly properties where applicable to maintain some encapsulation guarantees

49-49: Clarify the visibility inconsistency.

These three properties (stripHosts, providersHistorySize, comment) remain private while most others were made public. The selection criteria isn't clear—all three have getter/setter methods similar to the properties that were made public.

Please ensure this inconsistency is intentional and consider documenting the rationale if these properties require different visibility for specific reasons (e.g., validation requirements, internal-only state).

Also applies to: 69-69, 93-93

tests/Form/PackageConstraintTypeTest.php (3)

33-49: Consider asserting form validity in the “valid data” path

You already assert synchronization; adding an explicit $this->assertTrue($form->isValid()); would also lock in that the NotBlank constraints accept this data, not just that mapping works.


51-59: Make error assertions slightly more explicit

Counting two errors works, but it’s a bit brittle if constraint configuration changes (e.g., message nesting or extra constraints). You might instead/assert‑also check that each child field has at least one error, e.g. via $form->get('package')->getErrors() and $form->get('constraint')->getErrors().


61-71: Clarify intent of the second empty‑submission test

This test nicely covers the “no fields submitted” case and the configured default object. To make its purpose crystal clear relative to testSubmitEmptyDataIsInvalid(), consider documenting (or asserting) whether you expect this default object to ever be used in valid flows, or if it’s purely a data‑mapping fallback for invalid empty submissions.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c51df2 and 3c55743.

📒 Files selected for processing (11)
  • .php-cs-fixer.dist.php (0 hunks)
  • src/DTO/Abandoned.php (1 hunks)
  • src/DTO/Configuration.php (2 hunks)
  • src/DTO/PackageStability.php (1 hunks)
  • tests/Form/AbandonedTypeTest.php (1 hunks)
  • tests/Form/ArchiveTypeTest.php (1 hunks)
  • tests/Form/DeleteFormTypeTest.php (1 hunks)
  • tests/Form/LoginFormTest.php (1 hunks)
  • tests/Form/PackageConstraintTypeTest.php (1 hunks)
  • tests/Form/PackageStabilityTypeTest.php (1 hunks)
  • tests/Integration/BuildCommandTest.php (1 hunks)
💤 Files with no reviewable changes (1)
  • .php-cs-fixer.dist.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/Integration/BuildCommandTest.php
🧰 Additional context used
🧬 Code graph analysis (8)
src/DTO/Abandoned.php (1)
src/DTO/PackageStability.php (1)
  • setPackage (21-26)
tests/Form/ArchiveTypeTest.php (1)
src/DTO/Archive.php (11)
  • Archive (12-154)
  • getDirectory (41-44)
  • getFormat (53-56)
  • getAbsoluteDirectory (65-68)
  • getPrefixUrl (105-108)
  • isSkipDev (75-78)
  • isChecksum (115-118)
  • isIgnoreFilters (125-128)
  • isOverrideDistType (135-138)
  • isRearchive (145-148)
  • getWhitelist (85-88)
tests/Form/LoginFormTest.php (2)
src/Form/LoginType.php (1)
  • LoginType (11-21)
tests/Form/PackageStabilityTypeTest.php (1)
  • setUp (17-23)
tests/Form/DeleteFormTypeTest.php (1)
src/Form/DeleteFormType.php (1)
  • DeleteFormType (12-38)
tests/Form/AbandonedTypeTest.php (2)
src/DTO/Abandoned.php (3)
  • Abandoned (5-36)
  • getPackage (17-20)
  • getReplacement (22-25)
src/Form/AbandonedType.php (1)
  • AbandonedType (12-52)
src/DTO/PackageStability.php (1)
src/DTO/Abandoned.php (1)
  • setPackage (27-30)
tests/Form/PackageStabilityTypeTest.php (2)
src/DTO/PackageStability.php (3)
  • PackageStability (5-39)
  • getPackage (16-19)
  • getStability (28-31)
src/Form/PackageStabilityType.php (1)
  • PackageStabilityType (13-58)
tests/Form/PackageConstraintTypeTest.php (2)
src/DTO/PackageConstraint.php (2)
  • PackageConstraint (5-38)
  • getConstraint (27-30)
src/Form/PackageConstraintType.php (1)
  • PackageConstraintType (12-55)
🔇 Additional comments (16)
tests/Form/DeleteFormTypeTest.php (1)

15-18: Form factory setup is appropriate and minimal

Using Forms::createFormFactory() in setUp() keeps the fixture simple and is sufficient for asserting configured options on DeleteFormType. No changes needed here.

tests/Form/LoginFormTest.php (3)

12-22: LGTM! Clean test setup.

The class structure follows modern PHPUnit best practices with a final class declaration and typed property. The setUp method correctly initializes the form factory with validator support, matching the pattern used in other form tests.


24-31: LGTM! Field presence verification is correct.

The test appropriately verifies that all three fields defined in LoginType (username, password, login) are present in the form.


49-57: LGTM! Empty data test is correct.

The test appropriately verifies that submitting empty data results in null values for the username and password fields while maintaining form synchronization.

src/DTO/Abandoned.php (1)

26-35: LGTM! Setters align with property types and constructor requirements.

The setPackage accepts a non-nullable string (matching the private string $package declaration), while setReplacement accepts ?string (matching private ?string $replacement). This differs from PackageStability::setPackage which uses a null-guard pattern, but that's appropriate given PackageStability allows nullable input while guarding against assignment, whereas here the constructor enforces string $package from the start.

tests/Form/PackageStabilityTypeTest.php (3)

13-23: Good test setup with validator extension.

The setUp() properly initializes the form factory with ValidatorExtension, enabling constraint validation in tests. This is the correct approach for testing Symfony forms with validation.


25-49: LGTM! Test methods cover field presence and valid data submission.

The tests verify form fields exist and that valid data is correctly mapped to the PackageStability DTO.


61-71: LGTM! Correctly tests the empty_data configuration.

The test verifies that submitting an empty array creates a default PackageStability object with empty strings, matching the form's empty_data option.

tests/Form/ArchiveTypeTest.php (2)

9-10: Note: No ValidatorExtension configured.

Unlike PackageStabilityTypeTest, this test extends TypeTestCase without adding ValidatorExtension. This is fine for testing data mapping, but if ArchiveType has validation constraints, you'll need to add validation tests with the extension. If validation is tested elsewhere or not required, this is acceptable.


11-67: LGTM! Comprehensive data mapping tests.

Both tests thoroughly cover the Archive DTO's properties:

  • testSubmitValidData: Verifies all 11 fields are correctly mapped from submitted data
  • testEmptyData: Confirms default values (empty strings, nulls, booleans, and arrays)
tests/Form/AbandonedTypeTest.php (4)

13-18: Good use of getExtensions() for test setup.

Using getExtensions() is the idiomatic TypeTestCase pattern for adding the ValidatorExtension. This is cleaner than using setUp() to manually build the factory.


20-41: LGTM! Comprehensive valid submission test.

The test covers form synchronization, submission state, validation, data mapping, and view structure verification.


43-56: LGTM! Correctly tests optional replacement field.

The test validates that an empty replacement is allowed (no NotBlank constraint), and the result is an empty string due to the form's empty_data configuration.


58-81: LGTM! Good validation and attribute tests.

  • testPackageCannotBeBlank: Properly verifies the NotBlank constraint on the package field
  • testFieldPlaceholders: Ensures form view attributes match expected placeholders
tests/Form/PackageConstraintTypeTest.php (2)

17-23: Form factory setup looks good

Reusing a single form factory with the validator extension in setUp() is a clean pattern and keeps the individual tests focused on behavior rather than wiring.


25-31: Field‑presence test is clear and sufficient

Checking that both package and constraint fields exist directly reflects the form definition and should catch accidental field removal/rename.

@Trusted97 Trusted97 merged commit 3a14a09 into main Nov 27, 2025
2 checks passed
@Trusted97 Trusted97 deleted the refactor-phpunit-test branch November 27, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants