-
Notifications
You must be signed in to change notification settings - Fork 9.4k
[Review] Integration tests for not allowed review submission #19736
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
Merged
magento-engcom-team
merged 2 commits into
magento:2.3-develop
from
eduard13:2.3-develop-product-review-integration-tests
Dec 19, 2018
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
...tion/testsuite/Magento/Review/Controller/CaseCheckUnsuccessfulAddingProductReviewTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| <?php | ||
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| */ | ||
| namespace Magento\Review\Controller; | ||
|
|
||
| use Magento\Catalog\Api\Data\ProductInterface; | ||
| use Magento\Catalog\Api\ProductRepositoryInterface; | ||
| use Magento\Framework\Data\Form\FormKey; | ||
| use Magento\Framework\Message\MessageInterface; | ||
| use Magento\TestFramework\Request; | ||
| use Magento\TestFramework\TestCase\AbstractController; | ||
|
|
||
| /** | ||
| * Test review product controller behavior | ||
| * | ||
| * @magentoAppArea frontend | ||
| */ | ||
| class CaseCheckUnsuccessfulAddingProductReviewTest extends AbstractController | ||
| { | ||
| /** | ||
| * Test adding a review for allowed guests with incomplete data by a not logged in user | ||
| * | ||
| * @magentoDbIsolation enabled | ||
| * @magentoAppIsolation enabled | ||
| * @magentoConfigFixture default_store catalog/review/allow_guest 1 | ||
| * @magentoDataFixture Magento/Catalog/_files/products.php | ||
| */ | ||
| public function testAttemptForGuestToAddReviewsWithIncompleteData() | ||
| { | ||
| $product = $this->getProduct(); | ||
| /** @var FormKey $formKey */ | ||
| $formKey = $this->_objectManager->get(FormKey::class); | ||
| $post = [ | ||
| 'nickname' => 'Test nick', | ||
| 'title' => 'Summary', | ||
| 'form_key' => $formKey->getFormKey(), | ||
| ]; | ||
| $this->prepareRequestData($post); | ||
| $this->dispatch('review/product/post/id/' . $product->getId()); | ||
| $this->assertSessionMessages( | ||
| $this->equalTo(['Please enter a review.']), | ||
| MessageInterface::TYPE_ERROR | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Test adding a review for not allowed guests by a guest | ||
| * | ||
| * @magentoDbIsolation enabled | ||
| * @magentoAppIsolation enabled | ||
| * @magentoConfigFixture default_store catalog/review/allow_guest 0 | ||
| * @magentoDataFixture Magento/Catalog/_files/products.php | ||
| */ | ||
| public function testAttemptForGuestToAddReview() | ||
| { | ||
| $product = $this->getProduct(); | ||
| /** @var FormKey $formKey */ | ||
| $formKey = $this->_objectManager->get(FormKey::class); | ||
| $post = [ | ||
| 'nickname' => 'Test nick', | ||
| 'title' => 'Summary', | ||
| 'detail' => 'Test Details', | ||
| 'form_key' => $formKey->getFormKey(), | ||
| ]; | ||
|
|
||
| $this->prepareRequestData($post); | ||
| $this->dispatch('review/product/post/id/' . $product->getId()); | ||
|
|
||
| $this->assertRedirect($this->stringContains('customer/account/login')); | ||
| } | ||
|
|
||
| /** | ||
| * @return ProductInterface | ||
| */ | ||
| private function getProduct() | ||
| { | ||
| return $this->_objectManager->get(ProductRepositoryInterface::class)->get('custom-design-simple-product'); | ||
| } | ||
|
|
||
| /** | ||
| * @param array $postData | ||
| * @return void | ||
| */ | ||
| private function prepareRequestData($postData) | ||
| { | ||
| $this->getRequest()->setMethod(Request::METHOD_POST); | ||
| $this->getRequest()->setPostValue($postData); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.