9 require_once
__DIR__ .
'/_files/ClassesForArgumentsReader.php';
19 $this->_model = new \Magento\Framework\Code\Reader\ArgumentsReader();
26 'name' =>
'stdClassObject',
28 'type' =>
'\stdClass',
29 'isOptional' =>
false,
32 'withoutConstructorClassObject' => [
33 'name' =>
'withoutConstructorClassObject',
35 'type' =>
'\ClassWithoutConstruct',
36 'isOptional' =>
false,
40 'name' =>
'someVariable',
43 'isOptional' =>
false,
51 'default' =>
'Const Value',
53 'optionalNumValue' => [
54 'name' =>
'optionalNumValue',
60 'optionalStringValue' => [
61 'name' =>
'optionalStringValue',
65 'default' =>
'optional string',
67 'optionalArrayValue' => [
68 'name' =>
'optionalArrayValue',
72 'default' =>
"array('optionalKey' => 'optionalValue')",
75 $class = new \ReflectionClass(
'ClassWithAllArgumentTypes');
76 $actualResult = $this->_model->getConstructorArguments(
$class);
78 $this->assertEquals($expectedResult, $actualResult);
83 $class = new \ReflectionClass(
'classWithoutOwnConstruct');
84 $actualResult = $this->_model->getConstructorArguments(
$class);
86 $this->assertEquals([], $actualResult);
93 'name' =>
'stdClassObject',
95 'type' =>
'\stdClass',
96 'isOptional' =>
false,
99 'withoutConstructorClassObject' => [
100 'name' =>
'withoutConstructorClassObject',
102 'type' =>
'\ClassWithoutConstruct',
103 'isOptional' =>
false,
107 'name' =>
'someVariable',
110 'isOptional' =>
false,
117 'isOptional' =>
true,
118 'default' =>
'Const Value',
120 'optionalNumValue' => [
121 'name' =>
'optionalNumValue',
124 'isOptional' =>
true,
127 'optionalStringValue' => [
128 'name' =>
'optionalStringValue',
131 'isOptional' =>
true,
132 'default' =>
'optional string',
134 'optionalArrayValue' => [
135 'name' =>
'optionalArrayValue',
138 'isOptional' =>
true,
139 'default' =>
"array('optionalKey' => 'optionalValue')",
142 $class = new \ReflectionClass(
'ClassWithoutOwnConstruct');
143 $actualResult = $this->_model->getConstructorArguments(
$class,
false,
true);
145 $this->assertEquals($expectedResult, $actualResult);
150 $class = new \ReflectionClass(
'ClassWithoutConstruct');
151 $actualResult = $this->_model->getConstructorArguments(
$class);
153 $this->assertEquals([], $actualResult);
158 $class = new \ReflectionClass(
'ClassWithoutConstruct');
159 $actualResult = $this->_model->getConstructorArguments(
$class,
false,
true);
161 $this->assertEquals([], $actualResult);
166 $class = new \ReflectionClass(
'ClassExtendsDefaultPhpType');
167 $actualResult = $this->_model->getConstructorArguments(
$class);
169 $this->assertEquals([], $actualResult);
179 'isOptional' =>
true,
186 'isOptional' =>
true,
190 'name' =>
'previous',
192 'type' =>
'\Exception',
193 'isOptional' =>
true,
197 $class = new \ReflectionClass(
'ClassExtendsDefaultPhpTypeWithIOverrideConstructor');
198 $actualResult = $this->_model->getConstructorArguments(
$class,
false,
true);
200 $this->assertEquals($expectedResult, $actualResult);
205 $class = new \ReflectionClass(
'ThirdClassForParentCall');
206 $actualResult = $this->_model->getParentCall(
209 'stdClassObject' => [
'type' =>
'\stdClass'],
210 'secondClass' => [
'type' =>
'\ClassExtendsDefaultPhpType']
214 [
'name' =>
'stdClassObject',
'position' => 0,
'type' =>
'\stdClass'],
215 [
'name' =>
'secondClass',
'position' => 1,
'type' =>
'\ClassExtendsDefaultPhpType'],
217 $this->assertEquals($expectedResult, $actualResult);
222 $class = new \ReflectionClass(
'WrongArgumentsOrder');
223 $actualResult = $this->_model->getParentCall(
226 'stdClassObject' => [
'type' =>
'\stdClass'],
227 'secondClass' => [
'type' =>
'\ClassExtendsDefaultPhpType']
231 [
'name' =>
'secondClass',
'position' => 0,
'type' =>
'\ClassExtendsDefaultPhpType'],
232 [
'name' =>
'stdClassObject',
'position' => 1,
'type' =>
'\stdClass'],
234 $this->assertEquals($expectedResult, $actualResult);
239 $class = new \ReflectionClass(
'ThirdClassForParentCall');
240 $actualResult = $this->_model->getParentCall(
243 'stdClassObject' => [
'type' =>
'\stdClass'],
244 'secondClass' => [
'type' =>
'\ClassExtendsDefaultPhpType']
248 [
'name' =>
'stdClassObject',
'position' => 0,
'type' =>
'\stdClass'],
249 [
'name' =>
'secondClass',
'position' => 1,
'type' =>
'\ClassExtendsDefaultPhpType'],
251 $this->assertEquals($expectedResult, $actualResult);
262 $actualResult = $this->_model->isCompatibleType($requiredType, $actualType);
263 $this->assertEquals($expectedResult, $actualResult);
272 [
'array', 10,
false],
273 [
'array',
'array',
true],
275 [
null,
'array',
true],
276 [
'\ClassWithAllArgumentTypes',
'\ClassWithoutOwnConstruct',
true],
277 [
'\ClassWithoutOwnConstruct',
'\ClassWithAllArgumentTypes',
false]
283 $class = new \ReflectionClass(
'\ClassWithSuppressWarnings');
284 $expected = [
'SuppressWarnings' =>
'Magento.TypeDuplication'];
285 $this->assertEquals($expected, $this->_model->getAnnotations(
$class));
defined('TESTS_BP')||define('TESTS_BP' __DIR__
testGetConstructorArgumentsClassExtendsDefaultPhpTypeInheridetTrue()
testGetConstructorArgumentsClassWithoutConstructInheridetTrue()
testGetConstructorArgumentsClassWithoutOwnConstructorInheritedFalse()
testIsCompatibleType($requiredType, $actualType, $expectedResult)
$_option $_optionId $class
testIsCompatibleTypeDataProvider()
testGetConstructorArgumentsClassWithoutOwnConstructorInheritedTrue()
testGetParentCallWithRightArgumentsOrder()
testGetConstructorArgumentsClassWithAllArgumentsType()
testGetParentCallWithWrongArgumentsOrder()
testGetConstructorArgumentsClassExtendsDefaultPhpTypeInheridetFalse()
testGetConstructorArgumentsClassWithoutConstructInheridetFalse()
testGetParentCallWithSeparateLineFormat()