[ProductAttribute] Fix select product attribute choice value rename#8737
Conversation
787fabd to
bd7d87c
Compare
|
Can we split these two fixes to two standalone PRs? Would be easier to review & merge then :) |
bd7d87c to
9c4dd2d
Compare
|
Btw. as these are bugfixes, it should be targeted against 1.0 |
b7f8395 to
e209bae
Compare
| string $productAttributeType, | ||
| string $productAttributeName, | ||
| string $attributeValue, | ||
| string $language = 'en_US' |
There was a problem hiding this comment.
Isn't the language set to the last "([^"]+)"?
| ) { | ||
| $attribute = $this->provideProductAttribute($productAttributeType, $productAttributeName); | ||
| $attribute->setConfiguration(['multiple' => false, 'choices' => [$attributeValue], 'min' => null, 'max' => null]); | ||
| $attributeValue = $this->createProductAttributeValue(array_keys($values), $attribute, $language); |
| /** | ||
| * @Given /^(this product) has (.+?) attribute "([^"]+)" with value "([^"]+)", "([^"]+)"$/ | ||
| */ | ||
| public function thisProductHasSelectAttributeWithValue( |
There was a problem hiding this comment.
Looks like an abandoned step.
| @@ -232,6 +253,25 @@ public function iWantToSeeAllProductAttributesInStore() | |||
| $this->indexPage->open(); | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
It doesn't feel right reading this step, what about the something like: the administrator changes this product attribute value "foo" to "bar"?
| * @return string | ||
| */ | ||
| private function getValidFormKey(string $value): string | ||
| private function getValidFormKey(): string |
There was a problem hiding this comment.
getValidFormKey -> getUniqueKey?
| "green": "green", | ||
| "black": "black" | ||
| }, | ||
| "choices": @array@, |
There was a problem hiding this comment.
IMO we should change it to something like:
{
"@string@": "yellow",
"@string@": "green",
// etc..
}
There was a problem hiding this comment.
I know and I agree that current example doesn't check behaviour properly, but this feature is not implemented in php-matcher (there is even an issue: coduo/php-matcher#92)
There was a problem hiding this comment.
What about adding an additional assertion in the test file, eg. asserting that the response matches this file contents + getting $response['configuration']['choices'] and asserting they are what we expect (like https://github.com/Sylius/SyliusElasticSearchPlugin/blob/master/tests/Controller/SearchControllerApiTest.php#L436)?
| And I specify its code as "mug_material" | ||
| And I name it "Mug material" in "English (United States)" | ||
| And I add material "-100% Banana Skin" | ||
| And I add value "-100% Banana Skin" |
There was a problem hiding this comment.
Value is kinda misleading, my first - AttributeValue, the second - the same. What about naming it an "option" or a "select option"?
There was a problem hiding this comment.
I see the reasoning behind it, but it's still confusing, not sure whether we should solve it already or leave it as is :)
e209bae to
32583a8
Compare
pamil
left a comment
There was a problem hiding this comment.
Let's fix that API test and it's good to go! 🎉
| And I specify its code as "mug_material" | ||
| And I name it "Mug material" in "English (United States)" | ||
| And I add material "-100% Banana Skin" | ||
| And I add value "-100% Banana Skin" |
There was a problem hiding this comment.
I see the reasoning behind it, but it's still confusing, not sure whether we should solve it already or leave it as is :)
| "green": "green", | ||
| "black": "black" | ||
| }, | ||
| "choices": @array@, |
There was a problem hiding this comment.
What about adding an additional assertion in the test file, eg. asserting that the response matches this file contents + getting $response['configuration']['choices'] and asserting they are what we expect (like https://github.com/Sylius/SyliusElasticSearchPlugin/blob/master/tests/Controller/SearchControllerApiTest.php#L436)?
|
Thank you Rzegś! 🎉 |

This PR fixes losing reference to an attribute value on a product when select attribute choice value renames.