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
Adding a coupon generator command #10355
Conversation
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Resources/config/services/command.xml
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/spec/Command/GenerateCouponsCommandSpec.php
Outdated
Show resolved
Hide resolved
I am trying to write a behat test but I am not sure how to mock the dependencies properly. The other commands use the container aware command as their base class which is deprecated. Should the |
What about some functional test with PHPunit, where we will generate some commands and assert if they are available in the database? |
src/Sylius/Bundle/PromotionBundle/spec/Command/GenerateCouponsCommandSpec.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Resources/config/services/command.xml
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/spec/Command/GenerateCouponsCommandSpec.php
Outdated
Show resolved
Hide resolved
I will try to get to it this evening. |
Is there any kind of reference for a command that is tested with phpunit? |
https://symfony.com/doc/current/console.html#testing-commands this can be useful, for the start |
Done. :D |
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.
Minor cs problems, vendor/bin/ecs check --ansi --no-progress-bar path-toyour-classes --fix
should fix it. Other than that, good to go.
src/Sylius/Bundle/PromotionBundle/Tests/Command/GenerateCouponsCommandTest.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Tests/Command/GenerateCouponsCommandTest.php
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Tests/Command/GenerateCouponsCommandTest.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/PromotionBundle/Tests/Command/GenerateCouponsCommandTest.php
Outdated
Show resolved
Hide resolved
Yeah, right forgot that. 👍 |
@Zales0123 What do you think? |
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | ||
use Symfony\Component\Console\Tester\CommandTester; | ||
|
||
class GenerateCouponsCommandTest extends KernelTestCase |
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.
Could be finalized
Thanks, @mamazu! 🥇 |
You have related the command to the core component and this will make problem if the PromotionBundle is integrated into Symfony app, without the Sylius core component. I suggest to change this: to: |
Yes, there is a problem, see #10692 |
True I didn't thought of that and this should be fixed. |
For people who like to generate coupon codes with the command line I have written a command to do so.