Skip to content

Commit a087de5

Browse files
committed
AC-15345: Undefined array key in ProductRepository getById
Unit test coverage for returning int value of productId
1 parent c7e306f commit a087de5

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

app/code/Magento/Review/Test/Unit/Block/FormTest.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -129,6 +129,34 @@ public function testGetProductInfo()
129129
$this->assertSame($productMock, $this->object->getProductInfo());
130130
}
131131

132+
public function testGetProductInfoNonIntParam()
133+
{
134+
$productId = 3;
135+
$productIdNonInt = "3abc";
136+
$storeId = 1;
137+
138+
$this->storeManager->expects(
139+
$this->any()
140+
)->method(
141+
'getStore'
142+
)->willReturn(
143+
new DataObject(['id' => $storeId])
144+
);
145+
146+
$this->requestMock->expects($this->once())
147+
->method('getParam')
148+
->with('id', false)
149+
->willReturn($productIdNonInt);
150+
151+
$productMock = $this->getMockForAbstractClass(ProductInterface::class);
152+
$this->productRepository->expects($this->once())
153+
->method('getById')
154+
->with($productId, false, $storeId)
155+
->willReturn($productMock);
156+
157+
$this->assertSame($productMock, $this->object->getProductInfo());
158+
}
159+
132160
/**
133161
* @param bool $isSecure
134162
* @param string $actionUrl

0 commit comments

Comments
 (0)