-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Separated order items subtotal calculation logic from twig extension #11191
Separated order items subtotal calculation logic from twig extension #11191
Conversation
Sorry I don't know how to fix the memory issues on the php 7.2 installation build. The others pass. |
/** @var OrderItemsSubtotalCalculatorInterface */ | ||
private $calculator; | ||
|
||
public function __construct(OrderItemsSubtotalCalculatorInterface $calculator) |
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.
It's BC break :( We should keep current logic as a fallback
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.
@lchrusciel Thanks for the review! I addressed the BC break, please have another look.
@lchrusciel Is there anymore that needs to be done before this can be merged? |
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.
Hey Youri,
thanks a lot for your contribution. I would like to merge it in the nearest days. Could you take my comments into account?
However, we are slightly blocked by red build on v1.6 :(
src/Sylius/Bundle/ShopBundle/Tests/Calculator/OrderItemsSubtotalCalculatorTest.php
Outdated
Show resolved
Hide resolved
use Sylius\Component\Core\Model\OrderInterface; | ||
use Sylius\Component\Core\Model\OrderItemInterface; | ||
|
||
final class OrderItemsSubtotalCalculatorTest extends TestCase |
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.
The structure of this test seems to be a perfect match for phpspec. It is not necessary but rather recommended. Would you like to give it a try?
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.
Perhaps another time. I'm interested to know when do you prefer spec over unit when it comes to testing? Very similar results can be achieved between the two, but I guess the focus does not 100% have to be on structure alone for unit tests?
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.
PHPSpec - unit testing, but to be more precise it is more for designing implementation. Testing every class in total separation, all collaborators are mocked and you need to be precise, what should be asserted (shouldBeCalled) and return (willReturn). Prophecy is a great part of this library, which was recently deprecated on PHPUnit. Also, it forces you for the usage of mocks rather than separated classes.
PHPUnit - functional testing - mostly used for more than one class initialized in the test suite. Some examples, testing of services fetched from the container, FormType testing, testing of configuration and old API testing
Behat - acceptance tests, focused mostly on business value and covered through all of Sylius layers
The distinction between PHPSpec & PHPUnit in terms of unit testing can indeed be a matter of taste, but we've decided to go with PHPSpec, and keeping codebase coherent is important for us.
Is it clearer right now?
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.
Thanks, that's pretty clear. I'd hate to jump in and learn about how phpspec works right here and now, but next time I'll do it that way for sure.
src/Sylius/Bundle/ShopBundle/Twig/OrderItemsSubtotalExtension.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/Twig/OrderItemsSubtotalExtension.php
Outdated
Show resolved
Hide resolved
Co-Authored-By: Łukasz Chruściel <lchrusciel@gmail.com>
…' of github.com:4c0n/Sylius into feature/separate-order-items-subtotal-calculation-logic
Do you have any idea about the memory issues of the 7.2 installation build? That is what's failing, maybe because of the new package not being in the composer cache or something like that. |
Seems to be something specific to Travis:
Is it possible for you to clear the composer cache somehow? |
I've restarted this build again |
|
So composer crashes because it seems to need more memory. Typical 😝 I don't usually work with Travis, so I kind of don't know if it is possible at all to increase the available memory for composer. |
@lchrusciel Hi Lukasz, |
Thanks, Youri! 🎉 |
I'd like to be able to use the logic for calculating the subtotal of all order items outside of Twig templates, hence this separation.