-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Remove phpspec/prophecy-phpunit dependency #18438
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
Conversation
WalkthroughRemoved Changes
Sequence Diagram(s)(Skipped — changes are testing and dependency migrations without new runtime control flow.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)**/*.{php,yaml,yml,xml,twig}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.php📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧬 Code graph analysis (1)src/Sylius/Bundle/ApiBundle/tests/Converter/IriToIdentifierConverterTest.php (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (4)
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. Comment |
❌ Preview Environment deleted from BunnyshellAvailable commands:
|
6c03846 to
b37a8ab
Compare
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/CountryChoiceTypeTest.php(3 hunks)src/Sylius/Bundle/AdminBundle/tests/Notification/HubNotificationProviderTest.php(4 hunks)src/Sylius/Bundle/ApiBundle/tests/ApiPlatform/Routing/ApiLoaderTest.php(2 hunks)src/Sylius/Bundle/AttributeBundle/tests/Form/Type/AttributeType/SelectAttributeTypeTest.php(3 hunks)src/Sylius/Bundle/CoreBundle/tests/EventListener/MigrationSkipListenerTest.php(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{php,yaml,yml,xml,twig}
📄 CodeRabbit inference engine (AGENTS.md)
Use 4 spaces for indentation in PHP, YAML, XML, and Twig files
Files:
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/CountryChoiceTypeTest.phpsrc/Sylius/Bundle/ApiBundle/tests/ApiPlatform/Routing/ApiLoaderTest.phpsrc/Sylius/Bundle/AdminBundle/tests/Notification/HubNotificationProviderTest.phpsrc/Sylius/Bundle/AttributeBundle/tests/Form/Type/AttributeType/SelectAttributeTypeTest.phpsrc/Sylius/Bundle/CoreBundle/tests/EventListener/MigrationSkipListenerTest.php
**/*.php
📄 CodeRabbit inference engine (AGENTS.md)
**/*.php: Use modern PHP 8.2+ syntax and features
Declare strict_types=1 in all PHP files
Follow the Sylius Coding Standard
Do not use deprecated features from PHP, Symfony, or Sylius
Use final for all classes, except entities and repositories
Use readonly for immutable services and value objects
Add type declarations for all properties, arguments, and return values
Use camelCase for variables and method names
Use SCREAMING_SNAKE_CASE for constants
Use fast returns instead of unnecessary nesting
Use trailing commas in multi-line arrays and argument lists
Order array keys alphabetically where applicable
Use PHPDoc only when necessary (e.g., @var Collection)
Group class elements in order: constants, properties, constructor, public, protected, private methods
Group getter and setter methods for the same properties together
Suffix interfaces with Interface and traits with Trait
Use use statements for all non-global classes
Sort use imports alphabetically and group by type (classes, functions, constants)
Files:
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/CountryChoiceTypeTest.phpsrc/Sylius/Bundle/ApiBundle/tests/ApiPlatform/Routing/ApiLoaderTest.phpsrc/Sylius/Bundle/AdminBundle/tests/Notification/HubNotificationProviderTest.phpsrc/Sylius/Bundle/AttributeBundle/tests/Form/Type/AttributeType/SelectAttributeTypeTest.phpsrc/Sylius/Bundle/CoreBundle/tests/EventListener/MigrationSkipListenerTest.php
🧬 Code graph analysis (5)
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/CountryChoiceTypeTest.php (3)
src/Sylius/Bundle/AdminBundle/tests/Notification/HubNotificationProviderTest.php (4)
setUp(51-74)Test(76-126)Test(128-190)Test(192-261)src/Sylius/Bundle/ApiBundle/tests/ApiPlatform/Routing/ApiLoaderTest.php (6)
setUp(30-41)Test(43-47)Test(49-69)Test(71-81)Test(83-94)Test(96-107)src/Sylius/Bundle/AttributeBundle/tests/Form/Type/AttributeType/SelectAttributeTypeTest.php (4)
setUp(42-48)getExtensions(50-57)assertChoicesLabels(59-69)Test(29-40)
src/Sylius/Bundle/ApiBundle/tests/ApiPlatform/Routing/ApiLoaderTest.php (2)
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/CountryChoiceTypeTest.php (6)
Test(65-78)Test(80-93)Test(95-108)Test(110-123)Test(125-138)Test(140-153)src/Sylius/Bundle/AdminBundle/tests/Notification/HubNotificationProviderTest.php (3)
Test(76-126)Test(128-190)Test(192-261)
src/Sylius/Bundle/AdminBundle/tests/Notification/HubNotificationProviderTest.php (1)
src/Sylius/Bundle/CoreBundle/SyliusCoreBundle.php (1)
SyliusCoreBundle(41-115)
src/Sylius/Bundle/AttributeBundle/tests/Form/Type/AttributeType/SelectAttributeTypeTest.php (1)
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/CountryChoiceTypeTest.php (2)
setUp(36-54)getExtensions(56-63)
src/Sylius/Bundle/CoreBundle/tests/EventListener/MigrationSkipListenerTest.php (1)
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/CountryChoiceTypeTest.php (7)
setUp(36-54)Test(65-78)Test(80-93)Test(95-108)Test(110-123)Test(125-138)Test(140-153)
🪛 PHPMD (2.15.0)
src/Sylius/Bundle/AdminBundle/tests/Notification/HubNotificationProviderTest.php
86-86: Avoid unused parameters such as '$key'. (undefined)
(UnusedFormalParameter)
139-139: Avoid unused parameters such as '$key'. (undefined)
(UnusedFormalParameter)
203-203: Avoid unused parameters such as '$key'. (undefined)
(UnusedFormalParameter)
src/Sylius/Bundle/CoreBundle/tests/EventListener/MigrationSkipListenerTest.php
117-117: Avoid unused parameters such as '$schema'. (undefined)
(UnusedFormalParameter)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: Frontend / NodeJS 24.x
- GitHub Check: End-to-end tests (MariaDB) / Non-JS, PHP 8.4, Symfony ^7.3, MariaDB 11.4.7, State Machine Adapter symfony_workflow, ApiPlatform ~4.1.7
- GitHub Check: End-to-end tests (MariaDB) / Non-JS, PHP 8.3, Symfony ^6.4, MariaDB 10.11.13, State Machine Adapter winzou_state_machine
- GitHub Check: End-to-end tests (MariaDB) / Non-JS, PHP 8.4, Symfony ^7.3, MariaDB 11.4.7, State Machine Adapter symfony_workflow
- GitHub Check: End-to-end tests (PostgreSQL) / Non-JS, PHP 8.4, Symfony ^7.3, PostgreSQL 17.5
- GitHub Check: End-to-end tests (PostgreSQL) / Non-JS, PHP 8.3, Symfony ^6.4, PostgreSQL 15.13
- GitHub Check: End-to-end tests (MySQL) / JS with Panther, PHP 8.3, Symfony ^6.4 (test_cached), MySQL 8.0, Twig ^3.3
- GitHub Check: End-to-end tests (MySQL) / Non-JS, PHP 8.3, Symfony ^6.4 (test_cached), MySQL 8.0, Twig ^3.3
- GitHub Check: End-to-end tests (MySQL) / JS with Panther, PHP 8.4, Symfony ^7.3 (test_cached), MySQL 8.4, Twig ^3.3
- GitHub Check: End-to-end tests (MySQL) / JS with Chromedriver, PHP 8.3, Symfony ^6.4 (test_cached), MySQL 8.0, Twig ^3.3
- GitHub Check: End-to-end tests (MySQL) / JS with Chromedriver, PHP 8.4, Symfony ^7.3 (test_cached), MySQL 8.4, Twig ^3.3
- GitHub Check: End-to-end tests (MySQL) / Non-JS, PHP 8.4, Symfony ^7.3 (test_cached), MySQL 8.4, Twig ^3.3
🔇 Additional comments (16)
src/Sylius/Bundle/AttributeBundle/tests/Form/Type/AttributeType/SelectAttributeTypeTest.php (1)
18-18: LGTM! Clean migration from Prophecy to PHPUnit mocks.The migration from Prophecy to PHPUnit's native mocking is correctly implemented:
- Proper import of
MockObject- Intersection type
TranslationLocaleProviderInterface&MockObjectprovides full type information- Standard PHPUnit mock creation with
createMock()andmethod()->willReturn()- Direct mock usage eliminates the need for
reveal()The pattern matches the reference implementation in
CountryChoiceTypeTest.phpand aligns with modern PHPUnit best practices.Also applies to: 27-27, 44-45, 52-52
src/Sylius/Bundle/ApiBundle/tests/ApiPlatform/Routing/ApiLoaderTest.php (6)
17-17: LGTM! Good use of intersection types.The addition of the
MockObjectimport and the intersection typeLoaderInterface&MockObjectfor the property provides better type safety and IDE support for the mock object.Also applies to: 26-26
30-41: LGTM! Correct migration to PHPUnit mocks.The setup correctly initializes the mock using
createMock()and passes it directly to theApiLoaderconstructor. The migration from Prophecy is clean and follows PHPUnit best practices.
50-69: LGTM! Clean migration to PHPUnit expectations.The test correctly uses PHPUnit's mocking API with proper expectations (
expects(),method(),with(),willReturn()). The assertion directly compares the mock object, which is the correct pattern for PHPUnit mocks.
72-81: LGTM! Proper PHPUnit mock expectations.The test correctly configures mock expectations for the
supportsmethod and properly asserts the boolean return value.
84-94: LGTM! Correct object identity assertion.The test properly creates the mock, sets up expectations, and verifies object identity with
assertSame, which is the correct pattern for PHPUnit mocks.
97-107: LGTM! Proper parameter verification.The test correctly verifies that
setResolveris called once with the expected parameter using PHPUnit'swith()method.src/Sylius/Bundle/CoreBundle/tests/EventListener/MigrationSkipListenerTest.php (6)
28-30: LGTM!The new imports are correctly added to support PHPUnit's native mocking (
MockObject) and the test migration constructors (LoggerInterface). The imports are properly ordered alphabetically.
36-38: LGTM!The property type declarations correctly use intersection types (
Type&MockObject), which is the modern PHPUnit 11+ approach for typed mock properties. This provides better IDE support and type safety compared to the previous Prophecy approach.
44-51: LGTM!The
setUpmethod correctly migrates from Prophecy to PHPUnit's native mocking:
- Uses
createMock()instead ofprophesize()- Uses
->method()->willReturn()for stubbing instead of Prophecy's API- Passes mocks directly without needing
->reveal()The implementation is clean and follows PHPUnit best practices.
58-60: LGTM!The test expectations correctly use PHPUnit's native mocking API:
->expects($this->never())replaces Prophecy'sshouldNotBeCalled()->expects($this->once())replaces Prophecy'sshouldBeCalled()The migration maintains the same test behavior while using PHPUnit's standard mocking capabilities.
Also applies to: 72-74
102-121: LGTM!The use of anonymous classes to create test migrations is a clean and appropriate approach. The classes correctly:
- Extend
AbstractMigrationwith required constructor dependencies- Conditionally implement
MigrationSkipInterfacebased on test requirements- Provide empty
up()anddown()method implementations suitable for testsNote regarding static analysis: The PHPMD warning about unused
$schemaparameters (lines 105, 109, 115, 119) is a false positive. These parameters must be present to satisfy theAbstractMigrationcontract, even though they're not used in the test implementations.
123-135: LGTM!The event construction correctly uses PHPUnit mocks:
- Passes the concrete
$migrationobject directly (no->reveal()needed)- Uses
createMock()forConnectionandMigratorConfigurationdependencies- Properly constructs
MigrationPlanandMigrationsVersionEventArgswith the required argumentsThe migration is complete and consistent with PHPUnit's mocking approach.
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/CountryChoiceTypeTest.php (3)
18-18: Excellent migration to PHPUnit native mocks with modern PHP features.The use of intersection types (
RepositoryInterface&MockObject) provides superior type safety and IDE support compared to the previous Prophecy approach. The migration is clean and consistent:
- Mock creation with
createMock()is properly set up insetUp()- Stubs configured with
method()->willReturn()provide default behavior for country properties- Direct mock passing (no
reveal()calls) simplifies the codeAlso applies to: 28-34, 38-58
68-75: Test expectations migrated correctly.All test methods now use PHPUnit's native expectation API (
expects()->method()->with()->willReturn()) instead of Prophecy. The expectations correctly verify:
- Method call counts (
$this->once())- Method names (
findBy,findAll)- Parameter matching (
['enabled' => true])- Return values (country mock arrays)
This pattern is consistent with the migration in other bundles (AdminBundle, ApiBundle, AttributeBundle).
Also applies to: 83-90, 98-105, 113-120, 128-135, 143-150
1-162: No Prophecy references remain in CountryChoiceTypeTest. Search forprophecy,Prophecy,ObjectProphecy,prophesize, andreveal()returned no matches.
| $this->cache | ||
| ->expects($this->once()) | ||
| ->method('get') | ||
| ->with('latest_sylius_version', $this->isType('callable')) | ||
| ->willReturnCallback(fn ($key, $callback) => $callback()); | ||
|
|
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.
Cache callback must receive an ItemInterface.
CacheInterface::get() will invoke the callback with a Symfony\Contracts\Cache\ItemInterface argument. Calling $callback() with no parameters raises a TypeError, so the test will fail. Create an ItemInterface mock (optionally asserting expiresAfter(60)) and pass it to the callback, e.g.:
+ $cacheItem = $this->createMock(ItemInterface::class);
+ $cacheItem
+ ->expects($this->once())
+ ->method('expiresAfter')
+ ->with(60);
+
$this->cache
->expects($this->once())
->method('get')
->with('latest_sylius_version', $this->isType('callable'))
- ->willReturnCallback(fn ($key, $callback) => $callback());
+ ->willReturnCallback(static fn (string $key, callable $callback) => $callback($cacheItem));(The same fix is needed in the other tests that use this cache callback.)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| $this->cache | |
| ->expects($this->once()) | |
| ->method('get') | |
| ->with('latest_sylius_version', $this->isType('callable')) | |
| ->willReturnCallback(fn ($key, $callback) => $callback()); | |
| $cacheItem = $this->createMock(ItemInterface::class); | |
| $cacheItem | |
| ->expects($this->once()) | |
| ->method('expiresAfter') | |
| ->with(60); | |
| $this->cache | |
| ->expects($this->once()) | |
| ->method('get') | |
| ->with('latest_sylius_version', $this->isType('callable')) | |
| ->willReturnCallback(static fn (string $key, callable $callback) => $callback($cacheItem)); |
🧰 Tools
🪛 PHPMD (2.15.0)
86-86: Avoid unused parameters such as '$key'. (undefined)
(UnusedFormalParameter)
🤖 Prompt for AI Agents
In
src/Sylius/Bundle/AdminBundle/tests/Notification/HubNotificationProviderTest.php
around lines 82 to 87, the cache callback is invoked without the ItemInterface
argument which causes a TypeError; fix by creating a mock of
Symfony\Contracts\Cache\ItemInterface (optionally set expectation that
expiresAfter(60) is called) and call the provided callback with that mock (e.g.
$callback($itemMock)) instead of $callback(), and apply the same change to the
other tests using this cache callback.
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.
Actionable comments posted: 0
🧹 Nitpick comments (5)
src/Sylius/Bundle/AdminBundle/tests/Twig/Component/Shared/Navbar/NotificationsComponentTest.php (1)
42-42: Optional: Consider multi-line formatting for better readability.The nested array could be formatted across multiple lines to improve readability:
- $this->notificationProvider->method('getNotifications')->willReturn(['version' => ['message' => 'sylius.ui.notifications.new_version_of_sylius_available']]); + $this->notificationProvider->method('getNotifications')->willReturn([ + 'version' => [ + 'message' => 'sylius.ui.notifications.new_version_of_sylius_available', + ], + ]);src/Sylius/Bundle/CoreBundle/tests/Installation/Setup/LocaleSetupTest.php (1)
158-206: Consider replacing deprecatedlogicalOr()with modern PHPUnit patterns.While the Prophecy → PHPUnit migration is correct, these tests use
logicalOr()which was soft-deprecated in PHPUnit 9 and may be removed in PHPUnit 11/12. Additionally,logicalOr()doesn't enforce that each message is written exactly once or in a specific order—it only verifies each call matches one of the three messages.Since the messages have a deterministic order in the production code, consider using a callback or consecutive expectations to verify both the content and order of the messages.
Example refactor using a callback:
-$output - ->expects($this->exactly(3)) - ->method('writeln') - ->with($this->logicalOr( - 'Adding <info>French</info> Language.', - 'Adding <info>fr_FR</info> locale.', - '<info>You may also need to add this locale into config/parameters.yaml configuration.</info>', - )); +$expectedMessages = [ + 'Adding <info>French</info> Language.', + 'Adding <info>fr_FR</info> locale.', + '<info>You may also need to add this locale into config/parameters.yaml configuration.</info>', +]; +$callCount = 0; +$output + ->expects($this->exactly(3)) + ->method('writeln') + ->willReturnCallback(function ($message) use ($expectedMessages, &$callCount) { + $this->assertSame($expectedMessages[$callCount++], $message); + });Also applies to: 209-269
src/Sylius/Bundle/ApiBundle/tests/CommandHandler/AddPaymentRequestHandlerTest.php (3)
73-76: Assert invocation count and forbid side-effects in exception pathUse expects($this->once()) to assert the repository call occurs, and never() on unrelated collaborators to preserve Prophecy’s shouldBeCalled semantics.
- $this->paymentRepository->method('findOneByOrderToken')->with(1, 'token')->willReturn(null); + $this->paymentRepository + ->expects($this->once()) + ->method('findOneByOrderToken') + ->with(1, 'token') + ->willReturn(null); + + $this->paymentMethodRepository->expects($this->never())->method('findOneBy'); + $this->paymentRequestFactory->expects($this->never())->method('create'); + $this->defaultActionProvider->expects($this->never())->method('getAction'); + $this->defaultPayloadProvider->expects($this->never())->method('getPayload');
83-89: Likewise, tighten expectations for the “no payment method” pathAssert the two lookups happen exactly once and prevent creation/side-effects when the method is missing.
- $payment = $this->createMock(PaymentInterface::class); - - $this->paymentRepository->method('findOneByOrderToken')->with(1, 'token')->willReturn($payment); - $this->paymentMethodRepository->method('findOneBy')->with(['code' => 'bank_transfer'])->willReturn(null); + $payment = $this->createMock(PaymentInterface::class); + + $this->paymentRepository + ->expects($this->once()) + ->method('findOneByOrderToken') + ->with(1, 'token') + ->willReturn($payment); + + $this->paymentMethodRepository + ->expects($this->once()) + ->method('findOneBy') + ->with(['code' => 'bank_transfer']) + ->willReturn(null); + + $this->paymentRequestFactory->expects($this->never())->method('create'); + $this->defaultActionProvider->expects($this->never())->method('getAction'); + $this->defaultPayloadProvider->expects($this->never())->method('getPayload');
98-106: Prefer expects($this->once()) to verify essential interactions in the happy pathThis preserves the intent from Prophecy’s shouldBeCalled and fails if calls are skipped or duplicated.
- $this->paymentRepository->method('findOneByOrderToken')->with(1, 'token')->willReturn($payment); - $this->paymentMethodRepository->method('findOneBy')->with(['code' => 'bank_transfer'])->willReturn($paymentMethod); - $this->defaultActionProvider->method('getAction')->with($paymentRequest)->willReturn('authorize'); - $this->defaultPayloadProvider->method('getPayload')->with($paymentRequest)->willReturn(['foo' => 'bar']); + $this->paymentRepository + ->expects($this->once()) + ->method('findOneByOrderToken') + ->with(1, 'token') + ->willReturn($payment); + $this->paymentMethodRepository + ->expects($this->once()) + ->method('findOneBy') + ->with(['code' => 'bank_transfer']) + ->willReturn($paymentMethod); + $this->defaultActionProvider + ->expects($this->once()) + ->method('getAction') + ->with($paymentRequest) + ->willReturn('authorize'); + $this->defaultPayloadProvider + ->expects($this->once()) + ->method('getPayload') + ->with($paymentRequest) + ->willReturn(['foo' => 'bar']);- $this->paymentRequestFactory->method('create')->with($payment, $paymentMethod)->willReturn($paymentRequest); + $this->paymentRequestFactory + ->expects($this->once()) + ->method('create') + ->with($payment, $paymentMethod) + ->willReturn($paymentRequest);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/ZoneChoiceTypeTest.php(7 hunks)src/Sylius/Bundle/AdminBundle/tests/Twig/Component/Shared/Navbar/NotificationsComponentTest.php(2 hunks)src/Sylius/Bundle/ApiBundle/tests/CommandHandler/AddPaymentRequestHandlerTest.php(4 hunks)src/Sylius/Bundle/ApiBundle/tests/Converter/IriToIdentifierConverterTest.php(10 hunks)src/Sylius/Bundle/CoreBundle/tests/Fixture/OptionsResolver/LazyOptionTest.php(2 hunks)src/Sylius/Bundle/CoreBundle/tests/Form/Type/CatalogPromotion/CatalogPromotionActionTypeTest.php(12 hunks)src/Sylius/Bundle/CoreBundle/tests/Form/Type/Taxon/ProductTaxonAutocompleteChoiceTypeTest.php(3 hunks)src/Sylius/Bundle/CoreBundle/tests/Installation/Setup/LocaleSetupTest.php(6 hunks)src/Sylius/Bundle/CoreBundle/tests/Mailer/AccountRegistrationEmailManagerTest.php(2 hunks)src/Sylius/Bundle/CoreBundle/tests/Mailer/AccountVerificationEmailManagerTest.php(2 hunks)src/Sylius/Bundle/CoreBundle/tests/Mailer/ContactEmailManagerTest.php(2 hunks)src/Sylius/Bundle/CoreBundle/tests/Mailer/OrderEmailManagerTest.php(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{php,yaml,yml,xml,twig}
📄 CodeRabbit inference engine (AGENTS.md)
Use 4 spaces for indentation in PHP, YAML, XML, and Twig files
Files:
src/Sylius/Bundle/CoreBundle/tests/Mailer/ContactEmailManagerTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Mailer/AccountRegistrationEmailManagerTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Form/Type/CatalogPromotion/CatalogPromotionActionTypeTest.phpsrc/Sylius/Bundle/AddressingBundle/tests/Form/Type/ZoneChoiceTypeTest.phpsrc/Sylius/Bundle/ApiBundle/tests/CommandHandler/AddPaymentRequestHandlerTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Mailer/AccountVerificationEmailManagerTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Fixture/OptionsResolver/LazyOptionTest.phpsrc/Sylius/Bundle/AdminBundle/tests/Twig/Component/Shared/Navbar/NotificationsComponentTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Mailer/OrderEmailManagerTest.phpsrc/Sylius/Bundle/ApiBundle/tests/Converter/IriToIdentifierConverterTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Installation/Setup/LocaleSetupTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Form/Type/Taxon/ProductTaxonAutocompleteChoiceTypeTest.php
**/*.php
📄 CodeRabbit inference engine (AGENTS.md)
**/*.php: Use modern PHP 8.2+ syntax and features
Declare strict_types=1 in all PHP files
Follow the Sylius Coding Standard
Do not use deprecated features from PHP, Symfony, or Sylius
Use final for all classes, except entities and repositories
Use readonly for immutable services and value objects
Add type declarations for all properties, arguments, and return values
Use camelCase for variables and method names
Use SCREAMING_SNAKE_CASE for constants
Use fast returns instead of unnecessary nesting
Use trailing commas in multi-line arrays and argument lists
Order array keys alphabetically where applicable
Use PHPDoc only when necessary (e.g., @var Collection)
Group class elements in order: constants, properties, constructor, public, protected, private methods
Group getter and setter methods for the same properties together
Suffix interfaces with Interface and traits with Trait
Use use statements for all non-global classes
Sort use imports alphabetically and group by type (classes, functions, constants)
Files:
src/Sylius/Bundle/CoreBundle/tests/Mailer/ContactEmailManagerTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Mailer/AccountRegistrationEmailManagerTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Form/Type/CatalogPromotion/CatalogPromotionActionTypeTest.phpsrc/Sylius/Bundle/AddressingBundle/tests/Form/Type/ZoneChoiceTypeTest.phpsrc/Sylius/Bundle/ApiBundle/tests/CommandHandler/AddPaymentRequestHandlerTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Mailer/AccountVerificationEmailManagerTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Fixture/OptionsResolver/LazyOptionTest.phpsrc/Sylius/Bundle/AdminBundle/tests/Twig/Component/Shared/Navbar/NotificationsComponentTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Mailer/OrderEmailManagerTest.phpsrc/Sylius/Bundle/ApiBundle/tests/Converter/IriToIdentifierConverterTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Installation/Setup/LocaleSetupTest.phpsrc/Sylius/Bundle/CoreBundle/tests/Form/Type/Taxon/ProductTaxonAutocompleteChoiceTypeTest.php
🧬 Code graph analysis (8)
src/Sylius/Bundle/CoreBundle/tests/Form/Type/CatalogPromotion/CatalogPromotionActionTypeTest.php (1)
src/Sylius/Bundle/CoreBundle/tests/Fixture/OptionsResolver/LazyOptionTest.php (4)
Test(27-40)Test(42-59)Test(61-82)Test(84-99)
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/ZoneChoiceTypeTest.php (2)
src/Sylius/Bundle/AdminBundle/tests/Twig/Component/Shared/Navbar/NotificationsComponentTest.php (1)
setUp(30-37)src/Sylius/Bundle/ApiBundle/tests/CommandHandler/AddPaymentRequestHandlerTest.php (1)
setUp(49-66)
src/Sylius/Bundle/ApiBundle/tests/CommandHandler/AddPaymentRequestHandlerTest.php (3)
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/ZoneChoiceTypeTest.php (5)
setUp(37-57)Test(74-84)Test(86-96)Test(98-107)Test(109-118)src/Sylius/Bundle/ApiBundle/tests/Converter/IriToIdentifierConverterTest.php (11)
setUp(42-53)Test(66-76)Test(78-88)Test(90-102)Test(133-146)Test(148-161)Test(163-176)Test(178-193)Test(195-210)Test(212-254)Test(256-293)src/Sylius/Bundle/CoreBundle/tests/Fixture/OptionsResolver/LazyOptionTest.php (1)
Test(27-40)
src/Sylius/Bundle/CoreBundle/tests/Fixture/OptionsResolver/LazyOptionTest.php (2)
src/Sylius/Bundle/CoreBundle/tests/Form/Type/Taxon/ProductTaxonAutocompleteChoiceTypeTest.php (4)
Test(61-89)Test(91-116)Test(118-143)Test(145-167)src/Sylius/Bundle/CoreBundle/tests/Installation/Setup/LocaleSetupTest.php (3)
Test(73-115)Test(117-155)Test(157-206)
src/Sylius/Bundle/AdminBundle/tests/Twig/Component/Shared/Navbar/NotificationsComponentTest.php (2)
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/ZoneChoiceTypeTest.php (4)
Test(74-84)Test(86-96)Test(98-107)Test(109-118)src/Sylius/Bundle/ApiBundle/tests/CommandHandler/AddPaymentRequestHandlerTest.php (3)
Test(68-76)Test(78-89)Test(91-113)
src/Sylius/Bundle/ApiBundle/tests/Converter/IriToIdentifierConverterTest.php (2)
src/Sylius/Bundle/ApiBundle/tests/CommandHandler/AddPaymentRequestHandlerTest.php (4)
setUp(49-66)Test(68-76)Test(78-89)Test(91-113)src/Sylius/Bundle/CoreBundle/tests/Fixture/OptionsResolver/LazyOptionTest.php (4)
Test(27-40)Test(42-59)Test(61-82)Test(84-99)
src/Sylius/Bundle/CoreBundle/tests/Installation/Setup/LocaleSetupTest.php (3)
src/Sylius/Bundle/CoreBundle/Installer/Setup/LocaleSetup.php (2)
LocaleSetup(28-118)setup(44-63)src/Sylius/Bundle/ApiBundle/tests/Application/src/Kernel.php (1)
getProjectDir(38-41)src/Sylius/Bundle/CoreBundle/tests/Fixture/OptionsResolver/LazyOptionTest.php (4)
Test(27-40)Test(42-59)Test(61-82)Test(84-99)
src/Sylius/Bundle/CoreBundle/tests/Form/Type/Taxon/ProductTaxonAutocompleteChoiceTypeTest.php (2)
src/Sylius/Bundle/AddressingBundle/tests/Form/Type/ZoneChoiceTypeTest.php (2)
setUp(37-57)getExtensions(59-72)src/Sylius/Bundle/CoreBundle/tests/Fixture/OptionsResolver/LazyOptionTest.php (4)
Test(27-40)Test(42-59)Test(61-82)Test(84-99)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Static checks / PHP 8.3, Symfony ^6.4
🔇 Additional comments (31)
src/Sylius/Bundle/CoreBundle/tests/Fixture/OptionsResolver/LazyOptionTest.php (1)
17-99: LGTM! Clean migration from Prophecy to PHPUnit native mocks.The migration is executed correctly and follows PHPUnit best practices:
- Intersection types (
RepositoryInterface&MockObject) provide proper type safety for PHP 8.2+willReturnMapappropriately handles multiple test scenarios in a single mockexpects($this->never())correctly replaces Prophecy's non-call expectations- Test coverage and logic preserved across all four test methods
- All Prophecy dependencies successfully removed
src/Sylius/Bundle/AdminBundle/tests/Twig/Component/Shared/Navbar/NotificationsComponentTest.php (4)
17-17: LGTM! Correct import for PHPUnit mocks.The
MockObjectimport is necessary for the intersection type used in the property declaration.
24-24: LGTM! Modern type-safe mock declaration.The intersection type
NotificationProviderInterface&MockObjectis the correct approach for typing PHPUnit mocks, providing both interface contract and mock capabilities for better IDE support and static analysis.
30-37: LGTM! Clean migration to PHPUnit native mocking.The setUp method correctly:
- Creates the mock using
createMock()(line 34)- Passes the mock directly to the component constructor without calling
reveal()(line 36)This is the proper PHPUnit native mocking approach.
42-42: LGTM! Correct PHPUnit method stubbing.The method stubbing syntax
->method('getNotifications')->willReturn([...])is the correct PHPUnit native approach.src/Sylius/Bundle/CoreBundle/tests/Installation/Setup/LocaleSetupTest.php (2)
17-17: LGTM! Clean migration to PHPUnit native mocks.The migration from Prophecy to PHPUnit's native mocking is correct:
- Proper use of intersection types (
RepositoryInterface&MockObject,FactoryInterface&MockObject) for type safety- Typed property declarations follow PHP 8.2+ standards
- Direct mock creation with
createMock()in setUp is cleaner than the Prophecy approach- Mocks passed directly to the constructor without needing
reveal()Also applies to: 31-41, 52-63
73-115: LGTM! Test expectations properly migrated.The test methods correctly use PHPUnit's native mocking expectations (
expects()->method()->with()->willReturn()) instead of Prophecy's API. The test logic and assertions remain intact.Also applies to: 117-155
src/Sylius/Bundle/CoreBundle/tests/Mailer/AccountVerificationEmailManagerTest.php (2)
17-17: LGTM! MockObject import added.The import of
PHPUnit\Framework\MockObject\MockObjectis correctly added to support the migration from Prophecy to PHPUnit native mocking.
36-46: LGTM! Clean migration to PHPUnit MockObject.The test correctly migrates from Prophecy to PHPUnit's native mocking:
- Mocks are created with
createMock()instead ofprophesize()- Type hints use MockObject intersections (
UserInterface&MockObject,ChannelInterface&MockObject)- Method stubs configured with
->method(...)->willReturn(...)- Mocks passed directly to the method without
reveal()The migration is consistent and follows PHPUnit best practices.
src/Sylius/Bundle/CoreBundle/tests/Mailer/AccountRegistrationEmailManagerTest.php (2)
17-17: LGTM! MockObject import added.Correctly imports
MockObjectto support PHPUnit native mocking.
37-47: LGTM! Consistent migration to PHPUnit MockObject.The test successfully migrates from Prophecy with the same clean approach as other tests in this PR:
- Uses
createMock()for mock creation- Configures method stubs with
->method(...)->willReturn(...)- Passes mocks directly without
reveal()- Type hints use MockObject intersections
The migration maintains test readability and follows PHPUnit conventions.
src/Sylius/Bundle/CoreBundle/tests/Mailer/ContactEmailManagerTest.php (2)
17-17: LGTM! MockObject import added.Correctly imports
MockObjectfor PHPUnit native mocking support.
36-51: LGTM! Excellent mock setup with parameter constraints.The migration includes proper use of the
->with()constraint on line 44 to verify thatfindOneByCodeis called with the expected parameter. This is a best practice for ensuring method calls receive correct arguments.The overall migration maintains consistency with other tests in this PR.
src/Sylius/Bundle/CoreBundle/tests/Mailer/OrderEmailManagerTest.php (2)
17-17: LGTM! MockObject import added.Correctly imports
MockObjectto support the migration to PHPUnit native mocking.
43-57: LGTM! Proper handling of chained mock dependencies.The test correctly sets up chained mocks where
$order->getCustomer()returns$customer, and$customer->getEmail()returns the email address. This demonstrates proper mock configuration for objects with dependencies.The migration maintains the original test behavior while adopting PHPUnit's native mocking framework.
src/Sylius/Bundle/CoreBundle/tests/Form/Type/CatalogPromotion/CatalogPromotionActionTypeTest.php (3)
17-17: LGTM! MockObject import added.Correctly imports
MockObjectto support PHPUnit native mocking.
34-36: LGTM! Properties correctly typed with MockObject intersections.The class properties use intersection types (
ChannelInterface&MockObject,ChannelRepositoryInterface&MockObject) which correctly combine the interface withMockObject. This provides proper type safety while working with mocks.
273-310: LGTM! Clean setUp and extension configuration.The
setUp()method correctly creates all necessary mocks usingcreateMock(), and thegetExtensions()method passes these mocks directly to the type constructors. The migration from Prophecy is complete and consistent.Note: The
channelRepositorymock is configured withfindAll()behavior in each individual test method rather than insetUp(). While this could be refactored, the current approach provides clarity about what each test expects.src/Sylius/Bundle/CoreBundle/tests/Form/Type/Taxon/ProductTaxonAutocompleteChoiceTypeTest.php (5)
18-18: LGTM! MockObject import added.Correctly imports
MockObjectto support the migration to PHPUnit native mocking.
33-46: LGTM! Properties and setUp correctly migrated.The class properties use MockObject intersections for proper type safety, and the
setUp()method creates all mocks usingcreateMock(). This is a clean migration from Prophecy.
48-59: LGTM! Extensions configured with direct mock references.The
getExtensions()method correctly passes mocks directly to type constructors without usingreveal(). This completes the migration to PHPUnit's native mocking approach.
61-89: LGTM! Excellent use of willReturnMap for multiple scenarios.The test correctly uses
willReturnMap()on lines 71-74 to configure the taxon repository to return different values based on different input codes. This is the recommended PHPUnit approach for handling multiple return values based on method arguments.The migration maintains the original test behavior while adopting PHPUnit MockObject.
91-167: LGTM! Remaining tests consistently migrated.All test methods follow the same migration pattern:
- Create mocks with
createMock()- Configure behavior with
->method(...)->willReturn(...)or->willReturnMap(...)- Pass mocks directly to form options
- Assert expected results
The migration is complete, consistent, and maintains test coverage.
src/Sylius/Bundle/ApiBundle/tests/Converter/IriToIdentifierConverterTest.php (5)
23-23: Clean migration to PHPUnit MockObject types.The import and intersection type declarations correctly replace Prophecy dependencies with PHPUnit native mocking capabilities.
Also applies to: 34-38
42-53: Correct setUp() migration.Replacing
prophesize()->reveal()withcreateMock()is the proper PHPUnit pattern and maintains type safety through the MockObject intersection types.
59-102: Proper PHPUnit expectation syntax.The migration from Prophecy-style expectations to PHPUnit's
expects($this->once())/expects($this->never())withmethod(),with(),willReturn(), andwillThrowException()is correct and explicit.
213-254: Multiple expectations on the same mock handled correctly.Setting independent expectations on the same mock instance (lines 219-222, 224-230) is valid PHPUnit syntax. Each
expects()call registers a separate expectation that will be verified independently.
257-293: Complete and consistent migration pattern.The test demonstrates the full PHPUnit mocking workflow: creating mocks with
createMock(), setting expectations withexpects(), and asserting results. The functional behavior matches the original Prophecy-based implementation while improving type safety.src/Sylius/Bundle/ApiBundle/tests/CommandHandler/AddPaymentRequestHandlerTest.php (3)
17-17: Good migration to PHPUnit mocks with intersection typesImporting MockObject and typing properties as Interface&MockObject is idiomatic for PHP 8.2+ and aligns with the repo’s PHPUnit-native approach. Looks good.
Also applies to: 35-46
51-56: setUp(): mock wiring LGTMcreateMock(...) usage matches the intersection-typed properties. No issues.
58-65: Constructor wiring is correctPassing mocks directly, with trailing comma; consistent with coding guidelines.
Summary
Rationale
This package is no longer needed as the project has migrated away from Prophecy mocking in favor of PHPUnit's native mocking capabilities.
Summary by CodeRabbit
Tests
Chores