Skip to content

Commit a3016bc

Browse files
magentomagento2#23353: Unit and static tests fix.
1 parent 78af5b8 commit a3016bc

File tree

2 files changed

+11
-1
lines changed
  • app/code/Magento/Review

2 files changed

+11
-1
lines changed

app/code/Magento/Review/Controller/Adminhtml/Product/Post.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@
1212
use Magento\Framework\Exception\LocalizedException;
1313
use Magento\Review\Model\Review;
1414

15+
/**
16+
* Review admin controller for POST request.
17+
*/
1518
class Post extends ProductController implements HttpPostActionInterface
1619
{
1720
/**
21+
* Create a product review.
22+
*
1823
* @return \Magento\Backend\Model\View\Result\Redirect
1924
*/
2025
public function execute()

app/code/Magento/Review/Test/Unit/Controller/Adminhtml/Product/PostTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Review\Test\Unit\Controller\Adminhtml\Product;
77

88
use Magento\Framework\Controller\ResultFactory;
9+
use Magento\Review\Model\Review;
910

1011
/**
1112
* @SuppressWarnings(PHPMD.TooManyFields)
@@ -109,7 +110,7 @@ protected function _prepareMockObjects()
109110
$this->storeModelMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['__wakeup', 'getId']);
110111
$this->reviewMock = $this->createPartialMock(
111112
\Magento\Review\Model\Review::class,
112-
['__wakeup', 'create', 'save', 'getId', 'getResource', 'aggregate']
113+
['__wakeup', 'create', 'save', 'getId', 'getResource', 'aggregate', 'getEntityIdByCode']
113114
);
114115
$this->reviewFactoryMock = $this->createPartialMock(\Magento\Review\Model\ReviewFactory::class, ['create']);
115116
$this->ratingMock = $this->createPartialMock(
@@ -174,6 +175,10 @@ public function testPostAction()
174175
$this->reviewMock->expects($this->once())
175176
->method('aggregate')
176177
->willReturn($this->reviewMock);
178+
$this->reviewMock->expects($this->once())
179+
->method('getEntityIdByCode')
180+
->with(Review::ENTITY_PRODUCT_CODE)
181+
->willReturn(1);
177182
$this->ratingMock->expects($this->once())
178183
->method('setRatingId')
179184
->willReturnSelf();

0 commit comments

Comments
 (0)