-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Defaulting missing alt-text for a product to use the product name. #11323
Conversation
Thanks for this PR @brobie I will review and process this now for you. If I need any further information I will let you know. |
Hi @brobie the fix looks good to me so far but it would be great if you could cover it with a test. Ideally an integration test but a unit test would also be of some benefit here as the method |
…tGalleryImagesJson() function magento#9931
@dmanners The unit tests have been added. I'm not sure how to kick them off as a part of this new addition to the pull request. |
@brobie thanks, they will be picked up by travis automatically. |
@@ -77,6 +77,83 @@ protected function mockContext() | |||
->willReturn($this->registry); | |||
} | |||
|
|||
public function testGetGalleryImagesJsonWithLabel(){ |
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 static tests will complain that the {
needs to be on a new line. You should be able to run the static tests over your changes and see all the issues otherwise you can wait until Travis has finished. Though I think there will be nothing more than:
FILE: ...ode/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
----------------------------------------------------------------------
80 | ERROR | [x] Opening brace should be on a new line
94 | ERROR | [x] Opening brace should be on a new line
100 | ERROR | [x] Function closing brace must go on the next line
| | following the body; found 1 blank lines before
| | brace
102 | ERROR | [x] Opening brace should be on a new line
----------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
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.
@dmanners - I have fixed the above issues, but am curious if you can point me to the correct configuration for running the static code analysis. When I run the below command, I get more issues than what you have said.
vendor/squizlabs/php_codesniffer/bin/phpcs app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php
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.
So those results came from the build system. Not 100% sure how it was run but there are a couple of things I have done locally before.
./vendor/bin/phpcs app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php dev/tests/static/framework/Magento
- This will run the framework/Magento standards when running phpcs.
You could also try bin/magento dev:tests:run static
but that runs them all.
Finally there is a way of running them only on a diff (though I have as yet got that running....) From what I understand you run git diff origin/2.2-develop HEAD --name-only > dev/tests/static/testsuite/Magento/Test/_files/changed_files_local.txt
and this will create a list of changed files from your branch compared to another branch (in this case origin/2.2-develop). Then after that when running the suite it should only run on those files you changes. Maybe @okorshenko knows the full command for the static 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.
There is one other option which is to setup Travis against your fork. This would then mean you could run the travis checks before providing a PR.
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.
@brobie ok so if you run the git diff
as described above followed by ./vendor/bin/phpunit --config dev/tests/static/phpunit.xml.dist
that should show you the details you are looking for.
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.
Awesome, I'll 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.
Here is the request that mimics the rules used by Magento for Code Sniffer (I think)
vendor/squizlabs/php_codesniffer/bin/phpcs --standard=dev/tests/static/framework/Magento/ruleset.xml app/code/Magento/Catalog/Test/Unit/Block/Product/View/GalleryTest.php
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 for this PR. It looks good. I will start to process this now.
@brobie so we have the following issue during internal testing.
Would you be up for having a look at fixing this also here. This is part of #9931 which has been linked to this PR. Thanks |
I can try to have a look at it in the next few days.
…On Sat, Nov 4, 2017 at 5:29 AM David Manners ***@***.***> wrote:
@brobie <https://github.com/brobie> so we have the following issue during
internal testing.
1. Create a simple product that will have an image with an alt text.
2. Export this product to a CSV file.
3. Delete the product from Website
4. Import the previously exported product (CSV) back to the website
5. Open the imported product page (on a backend)
Expected result:
The product still has the alt text, that we created in the first step
Actual result:
The alt text that we had is gone from the product (it was lost)
Would you be up for having a look at fixing this also here. This is part
of #9931 <#9931> which has been
linked to this PR.
Thanks
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11323 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAND5oqPl7kRHTM8kDCEbyFW-VS5Vmldks5szDySgaJpZM4PzWXJ>
.
|
Hi @brobie have you had any chance to look into this issue? |
@brobie I think I found the issue with the labels being saved. Will check the fix provided and let you know. |
Description
The code in app/code/Magento/Catalog/Block/Product/View/Gallery.php's getGalleryImagesJson() function was setting the image's label to $image->getLabel() regardless of whether the image's label was null or empty. The fix was to test the $image->getLabel() response and if it was empty to use the product's name instead.
Fixed Issues (if relevant)
Manual testing scenarios
Contribution checklist