7
7
8
8
namespace Magento \WebapiAsync \Test \Unit \Controller \Rest \Asynchronous ;
9
9
10
+ use Magento \Framework \Reflection \MethodsMap ;
10
11
use Magento \Framework \Webapi \Rest \Request ;
11
12
use Magento \Framework \Webapi \ServiceInputProcessor ;
12
13
use Magento \Framework \Webapi \Validator \EntityArrayValidator \InputArraySizeLimitValue ;
@@ -57,6 +58,11 @@ class InputParamsResolverTest extends TestCase
57
58
*/
58
59
private $ inputArraySizeLimitValueMock ;
59
60
61
+ /**
62
+ * @var MethodsMap|MockObject
63
+ */
64
+ private $ methodsMap ;
65
+
60
66
protected function setUp (): void
61
67
{
62
68
$ this ->requestMock = $ this ->createMock (Request::class);
@@ -66,6 +72,7 @@ protected function setUp(): void
66
72
$ this ->requestValidatorMock = $ this ->createMock (RequestValidator::class);
67
73
$ this ->webapiInputParamsResolverMock = $ this ->createMock (WebapiInputParamsResolver::class);
68
74
$ this ->inputArraySizeLimitValueMock = $ this ->createMock (InputArraySizeLimitValue::class);
75
+ $ this ->methodsMap = $ this ->createMock (MethodsMap::class);
69
76
}
70
77
71
78
#[DataProvider('requestBodyDataProvider ' )]
@@ -74,9 +81,12 @@ public function testResolveAsyncBulkShouldThrowAnErrorForInvalidRequestData(
74
81
string $ expectedExceptionMessage
75
82
): void {
76
83
$ routeMock = $ this ->createMock (Route::class);
77
- $ this ->webapiInputParamsResolverMock ->expects ($ this ->once ())
78
- ->method ('getRoute ' )
84
+ $ routeMock ->method ('getParameters ' )
85
+ ->willReturn ([]);
86
+ $ this ->webapiInputParamsResolverMock ->method ('getRoute ' )
79
87
->willReturn ($ routeMock );
88
+ $ this ->paramsOverriderMock ->method ('override ' )
89
+ ->willReturnArgument (0 );
80
90
$ this ->requestMock ->expects ($ this ->once ())
81
91
->method ('getRequestData ' )
82
92
->willReturn ($ requestData );
@@ -89,14 +99,15 @@ public function testResolveAsyncBulk(): void
89
99
{
90
100
$ requestData = [['param1 ' => 'value1 ' ], ['param1 ' => 'value1 ' ]];
91
101
$ routeMock = $ this ->createMock (Route::class);
92
- $ routeMock ->expects ($ this ->once ())
93
- ->method ('getServiceClass ' )
102
+ $ routeMock ->method ('getServiceClass ' )
94
103
->willReturn ('serviceClass ' );
95
- $ routeMock ->expects ($ this ->once ())
96
- ->method ('getServiceMethod ' )
104
+ $ routeMock ->method ('getServiceMethod ' )
97
105
->willReturn ('serviceMethod ' );
98
- $ this ->webapiInputParamsResolverMock ->expects ($ this ->once ())
99
- ->method ('getRoute ' )
106
+ $ routeMock ->method ('getParameters ' )
107
+ ->willReturn ([]);
108
+ $ this ->paramsOverriderMock ->method ('override ' )
109
+ ->willReturnArgument (0 );
110
+ $ this ->webapiInputParamsResolverMock ->method ('getRoute ' )
100
111
->willReturn ($ routeMock );
101
112
$ this ->requestMock ->expects ($ this ->once ())
102
113
->method ('getRequestData ' )
@@ -139,7 +150,8 @@ private function getModel(bool $isBulk = false): InputParamsResolver
139
150
$ this ->requestValidatorMock ,
140
151
$ this ->webapiInputParamsResolverMock ,
141
152
$ isBulk ,
142
- $ this ->inputArraySizeLimitValueMock
153
+ $ this ->inputArraySizeLimitValueMock ,
154
+ $ this ->methodsMap
143
155
);
144
156
}
145
157
}
0 commit comments