Skip to content

Commit fe93034

Browse files
MAGETWO-93424: Permanent Redirect for old URL missing via API or no documentation
1 parent 33b0a51 commit fe93034

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

app/code/Magento/CatalogUrlRewrite/Plugin/Webapi/Controller/Rest/InputParamsResolver.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Magento\Catalog\Api\ProductRepositoryInterface;
1212
use Magento\Framework\Webapi\Rest\Request as RestRequest;
13+
use Magento\Webapi\Controller\Rest\InputParamsResolver as InputParamsResolverController;
1314

1415
/**
1516
* Plugin for InputParamsResolver
@@ -35,11 +36,11 @@ public function __construct(RestRequest $request)
3536
* Add 'save_rewrites_history' param to the product data
3637
*
3738
* @see \Magento\CatalogUrlRewrite\Plugin\Catalog\Controller\Adminhtml\Product\Initialization\Helper
38-
* @param \Magento\Webapi\Controller\Rest\InputParamsResolver $subject
39+
* @param InputParamsResolverController $subject
3940
* @param array $result
4041
* @return array
4142
*/
42-
public function afterResolve(\Magento\Webapi\Controller\Rest\InputParamsResolver $subject, array $result): array
43+
public function afterResolve(InputParamsResolverController $subject, array $result): array
4344
{
4445
$route = $subject->getRoute();
4546
$serviceMethodName = $route->getServiceMethod();

app/code/Magento/CatalogUrlRewrite/Test/Unit/Plugin/Webapi/Controller/Rest/InputParamsResolverTest.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Catalog\Model\Product;
1616
use Magento\Webapi\Controller\Rest\Router\Route;
1717
use Magento\Catalog\Api\ProductRepositoryInterface;
18+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
1819

1920
/**
2021
* Unit test for InputParamsResolver plugin
@@ -42,22 +43,22 @@ class InputParamsResolverTest extends \PHPUnit\Framework\TestCase
4243
private $objectManager;
4344

4445
/**
45-
* @var InputParamsResolver|\PHPUnit_Framework_MockObject_MockObject
46+
* @var InputParamsResolver|MockObject
4647
*/
4748
private $subject;
4849

4950
/**
50-
* @var RestRequest|\PHPUnit_Framework_MockObject_MockObject
51+
* @var RestRequest|MockObject
5152
*/
5253
private $request;
5354

5455
/**
55-
* @var Product|\PHPUnit_Framework_MockObject_MockObject
56+
* @var Product|MockObject
5657
*/
5758
private $product;
5859

5960
/**
60-
* @var Route|\PHPUnit_Framework_MockObject_MockObject
61+
* @var Route|MockObject
6162
*/
6263
private $route;
6364

@@ -76,16 +77,21 @@ protected function setUp()
7677
'product' => [
7778
'sku' => 'test',
7879
'custom_attributes' => [
79-
['attribute_code' => $this->saveRewritesHistory, 'value' => 1]
80+
[
81+
'attribute_code' => $this->saveRewritesHistory,
82+
'value' => 1
83+
]
8084
]
8185
]
8286
];
8387

8488
$this->route = $this->createPartialMock(Route::class, ['getServiceMethod', 'getServiceClass']);
8589
$this->request = $this->createPartialMock(RestRequest::class, ['getBodyParams']);
86-
$this->request->expects($this->any())->method('getBodyParams')->willReturn($this->requestBodyParams);
90+
$this->request->method('getBodyParams')
91+
->willReturn($this->requestBodyParams);
8792
$this->subject = $this->createPartialMock(InputParamsResolver::class, ['getRoute']);
88-
$this->subject->expects($this->any())->method('getRoute')->willReturn($this->route);
93+
$this->subject->method('getRoute')
94+
->willReturn($this->route);
8995
$this->product = $this->createPartialMock(Product::class, ['setData']);
9096

9197
$this->result = [false, $this->product, 'test'];

0 commit comments

Comments
 (0)