Skip to content

Commit 1a2603f

Browse files
committed
Adding a new case for successfully adding the review by guest
1 parent af7fa26 commit 1a2603f

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed
Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
*
1818
* @magentoAppArea frontend
1919
*/
20-
class CaseCheckUnsuccessfulAddingProductReviewTest extends AbstractController
20+
class CaseCheckAddingProductReviewTest extends AbstractController
2121
{
2222
/**
2323
* Test adding a review for allowed guests with incomplete data by a not logged in user
2424
*
2525
* @magentoDbIsolation enabled
2626
* @magentoAppIsolation enabled
27-
* @magentoConfigFixture default_store catalog/review/allow_guest 1
27+
* @magentoDataFixture Magento/Review/_files/config.php
2828
* @magentoDataFixture Magento/Catalog/_files/products.php
2929
*/
3030
public function testAttemptForGuestToAddReviewsWithIncompleteData()
@@ -50,7 +50,7 @@ public function testAttemptForGuestToAddReviewsWithIncompleteData()
5050
*
5151
* @magentoDbIsolation enabled
5252
* @magentoAppIsolation enabled
53-
* @magentoConfigFixture default_store catalog/review/allow_guest 0
53+
* @magentoDataFixture Magento/Review/_files/disable_config.php
5454
* @magentoDataFixture Magento/Catalog/_files/products.php
5555
*/
5656
public function testAttemptForGuestToAddReview()
@@ -71,6 +71,35 @@ public function testAttemptForGuestToAddReview()
7171
$this->assertRedirect($this->stringContains('customer/account/login'));
7272
}
7373

74+
/**
75+
* Test successfully adding a product review by a guest
76+
*
77+
* @magentoDbIsolation enabled
78+
* @magentoAppIsolation enabled
79+
* @magentoDataFixture Magento/Review/_files/config.php
80+
* @magentoDataFixture Magento/Catalog/_files/products.php
81+
*/
82+
public function testSuccessfullyAddingProductReviewForGuest()
83+
{
84+
$product = $this->getProduct();
85+
/** @var FormKey $formKey */
86+
$formKey = $this->_objectManager->get(FormKey::class);
87+
$post = [
88+
'nickname' => 'Test nick',
89+
'title' => 'Summary',
90+
'detail' => 'Test Details',
91+
'form_key' => $formKey->getFormKey(),
92+
];
93+
94+
$this->prepareRequestData($post);
95+
$this->dispatch('review/product/post/id/' . $product->getId());
96+
97+
$this->assertSessionMessages(
98+
$this->equalTo(['You submitted your review for moderation.']),
99+
MessageInterface::TYPE_SUCCESS
100+
);
101+
}
102+
74103
/**
75104
* @return ProductInterface
76105
*/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/** @var Value $config */
8+
use Magento\Framework\App\Config\Value;
9+
10+
$config = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(Value::class);
11+
$config->setPath('catalog/review/allow_guest');
12+
$config->setScope('default');
13+
$config->setScopeId(0);
14+
$config->setValue(0);
15+
$config->save();

0 commit comments

Comments
 (0)