Skip to content

Commit f6f5b53

Browse files
committed
Merge remote-tracking branch 'origin/MC-32711' into 2.4-develop-com-pr11
2 parents e4eb808 + 9a7be2d commit f6f5b53

File tree

2 files changed

+97
-3
lines changed

2 files changed

+97
-3
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Review\Block\Adminhtml\Edit\Tab;
9+
10+
use Magento\Framework\ObjectManagerInterface;
11+
use Magento\Framework\View\LayoutInterface;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
use PHPUnit\Framework\TestCase;
14+
15+
/**
16+
* Checks customer products reviews tab
17+
*
18+
* @see \Magento\Review\Block\Adminhtml\Edit\Tab\Reviews
19+
* @magentoAppArea adminhtml
20+
*/
21+
class ReviewsTest extends TestCase
22+
{
23+
/** @var ObjectManagerInterface */
24+
private $objectManager;
25+
26+
/** @var Reviews */
27+
private $block;
28+
29+
/**
30+
* @inheritdoc
31+
*/
32+
protected function setUp()
33+
{
34+
parent::setUp();
35+
36+
$this->objectManager = Bootstrap::getObjectManager();
37+
$this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Reviews::class);
38+
}
39+
40+
/**
41+
* @magentoDataFixture Magento/Review/_files/customer_review.php
42+
*
43+
* @return void
44+
*/
45+
public function testReviewGrid(): void
46+
{
47+
$this->block->setCustomerId(1);
48+
$this->assertCount(1, $this->block->getPreparedCollection());
49+
}
50+
}

dev/tests/integration/testsuite/Magento/Review/Controller/Adminhtml/Customer/ProductReviewsTest.php

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,30 @@
88
namespace Magento\Review\Controller\Adminhtml\Customer;
99

1010
use Magento\Framework\App\Request\Http;
11+
use Magento\Framework\App\Request\Http as HttpRequest;
12+
use Magento\Framework\View\LayoutInterface;
1113
use Magento\TestFramework\TestCase\AbstractBackendController;
1214

1315
/**
1416
* Test for customer product reviews page.
17+
*
18+
* @magentoAppArea adminhtml
1519
*/
1620
class ProductReviewsTest extends AbstractBackendController
1721
{
22+
/** @var LayoutInterface */
23+
private $layout;
24+
25+
/**
26+
* @inheritdoc
27+
*/
28+
protected function setUp()
29+
{
30+
parent::setUp();
31+
32+
$this->layout = $this->_objectManager->get(LayoutInterface::class);
33+
}
34+
1835
/**
1936
* Check Customer product review action.
2037
*
@@ -23,9 +40,36 @@ class ProductReviewsTest extends AbstractBackendController
2340
*/
2441
public function testProductReviewsAction(): void
2542
{
26-
$this->getRequest()->setPostValue(['id' => 1])->setMethod(Http::METHOD_POST);
43+
$this->dispatchWithIdParam(1);
44+
$this->assertContains('<div id="reviewGrid"', $this->getResponse()->getBody());
45+
}
46+
47+
/**
48+
* @return void
49+
*/
50+
public function testProductReviews(): void
51+
{
52+
$customerId = 1;
53+
$this->dispatchWithIdParam($customerId);
54+
$block = $this->layout->getBlock('admin.customer.reviews');
55+
$this->assertNotFalse($block);
56+
$this->assertEquals(
57+
$customerId,
58+
$block->getCustomerId(),
59+
'Block customer id value does not match expected value'
60+
);
61+
}
62+
63+
/**
64+
* Dispatch request with id parameter
65+
*
66+
* @param int $id
67+
* @return void
68+
*/
69+
private function dispatchWithIdParam(int $id): void
70+
{
71+
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
72+
$this->getRequest()->setParams(['id' => $id]);
2773
$this->dispatch('backend/review/customer/productReviews');
28-
$body = $this->getResponse()->getBody();
29-
$this->assertContains('<div id="reviewGrid"', $body);
3074
}
3175
}

0 commit comments

Comments
 (0)