-
-
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
[Product] Implement Toggleable interface on Product #3342
[Product] Implement Toggleable interface on Product #3342
Conversation
CoderMaggie
commented
Sep 23, 2015
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Fixed tickets | #3213 |
License | MIT |
function it_is_toggleable() | ||
{ | ||
$this->enable(); | ||
$this->isEnabled()->shouldReturn(true); |
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.
$this->shouldBeEnabled();
bef12ff
to
1ca0d5c
Compare
|
||
return $product; | ||
} | ||
$product = $this->getRepository('product')->createNew(); |
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.
you should add a blank line before 311
3a496a5
to
b4d50c5
Compare
$product = $this->getRepository('product')->findOneBy(array('name' => $name)); | ||
|
||
$isEnabled = false; | ||
if ('enabled' == $enabled) { |
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.
if('enabled' === $enabled)
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.
if ('enabled' === $enabled) {
😃
Anyway, aren't triple ===
usefull for bool
only ?
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.
Due to PHP dynamic typing they are always useful :) In this case not so much, but it's better to get used to them to avoid nasty bugs in the future.
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.
Anyway:
$isEnabled = 'enabled' === $enabled;
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.
👍
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.
In fact not only this should be changed, the whole part is wrong. It should be:
if (null === $product) {
$product = $this->getRepository('product')->createNew();
$product->setName($name);
}
$product->setEnabled('enabled' === $enabled);
$manager = $this->getEntityManager();
$manager->persist($product);
$manager->flush();
return $product;
b4d50c5
to
f603ec7
Compare
@TheMadeleine Requires rebasing. |
2e3e014
to
6dab33c
Compare
@pjedrzejewski done 👍 |
@@ -296,6 +296,7 @@ public function theFollowingOptionTranslationsExist(TableNode $table) | |||
} | |||
|
|||
/** | |||
<<<<<<< HEAD |
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.
Invalid rebase.
@@ -325,9 +326,30 @@ private function getPricingCalculatorConfiguration(array $data) | |||
foreach ($calculatorConfiguration as $channelCode => $price) { | |||
$channel = $channelRepository->findOneBy(array('code' => $channelCode)); | |||
|
|||
$finalCalculatorConfiguration[$channel->getId()] = (int) round($price * 100); | |||
$finalCalculatorConfiguration[$channel->getId()] = (int)round($price * 100); |
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.
Should be reverted.
6dab33c
to
be58518
Compare
|
||
if (null === $product) { | ||
$product = $this->getRepository('product')->createNew(); | ||
$product->setName($name); |
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.
description
as well as price
is necessary also.
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.
Updated :)
be58518
to
9744e38
Compare
@@ -41,6 +41,11 @@ function it_implements_Sylius_product_interface() | |||
$this->shouldImplement(ProductInterface::class); | |||
} | |||
|
|||
function it_implements_toggleable_interface() | |||
{ | |||
$this->shouldImplement('Sylius\Component\Resource\Model\ToggleableInterface'); |
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.
Use ::class
Migration file is missing. |
9744e38
to
3c97421
Compare
function it_is_toggleable() | ||
{ | ||
$this->enable(); | ||
$this->shouldBeEnabled(); |
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.
Since it's enabled by default I would swap the order (disable then enable again).
The migration is wrong and rebase is needed. |
3c97421
to
2372f47
Compare
2372f47
to
2fe64ad
Compare
@michalmarcinkowski updated :) |
[Product] Implement Toggleable interface on Product
Thank you Magda! 👍 |
…leable [Product] Implement Toggleable interface on Product