Definition at line 14 of file TypeProcessorTest.php.
◆ arrayParamTypeDataProvider()
arrayParamTypeDataProvider |
( |
| ) |
|
Get list of methods with expected param types.
- Returns
- array
Definition at line 277 of file TypeProcessorTest.php.
280 [
'method name' =>
'addData',
'type' =>
'array[]'],
281 [
'method name' =>
'addObjectList',
'type' =>
'TSampleInterface[]']
◆ getArrayItemType()
Definition at line 141 of file TypeProcessorTest.php.
143 $this->assertEquals(
'string', $this->typeProcessor->getArrayItemType(
'str[]'));
144 $this->assertEquals(
'string', $this->typeProcessor->getArrayItemType(
'string[]'));
145 $this->assertEquals(
'integer', $this->typeProcessor->getArrayItemType(
'int[]'));
146 $this->assertEquals(
'boolean', $this->typeProcessor->getArrayItemType(
'bool[]'));
147 $this->assertEquals(
'any', $this->typeProcessor->getArrayItemType(
'mixed[]'));
◆ methodParamsDataProvider()
methodParamsDataProvider |
( |
| ) |
|
Gets list of method names with params and their descriptions.
- Returns
- array
Definition at line 311 of file TypeProcessorTest.php.
314 [
'method name' =>
'setName',
'descriptions' => [
'Name of the attribute']],
315 [
'method name' =>
'setData',
'descriptions' => [
'Key is used as index',
null]],
◆ processSimpleTypeExceptionProvider()
static processSimpleTypeExceptionProvider |
( |
| ) |
|
|
static |
- Returns
- array
Definition at line 226 of file TypeProcessorTest.php.
229 "int type, string value" => [
'test',
'int'],
230 "float type, string value" => [
'test',
'float'],
◆ setUp()
◆ testGetArrayParamType()
testGetArrayParamType |
( |
string |
$methodName, |
|
|
string |
$type |
|
) |
| |
Checks a case for different array param types.
- Parameters
-
string | $methodName | |
string | $type | @dataProvider arrayParamTypeDataProvider |
Definition at line 264 of file TypeProcessorTest.php.
266 $class =
new ClassReflection(DataObject::class);
267 $methodReflection =
$class->getMethod($methodName);
268 $params = $methodReflection->getParameters();
269 $this->assertEquals(
$type, $this->typeProcessor->getParamType(array_pop(
$params)));
$_option $_optionId $class
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ testGetOperationName()
Definition at line 319 of file TypeProcessorTest.php.
323 $this->typeProcessor->getOperationName(
"resName",
"methodName")
◆ testGetParameterDescription()
testGetParameterDescription |
( |
string |
$methodName, |
|
|
array |
$descriptions |
|
) |
| |
Checks a case when method param has additional description.
- Parameters
-
string | $methodName | |
array | $descriptions | @dataProvider methodParamsDataProvider |
Definition at line 292 of file TypeProcessorTest.php.
294 $class =
new ClassReflection(DataObject::class);
295 $methodReflection =
$class->getMethod($methodName);
296 $paramsReflection = $methodReflection->getParameters();
297 foreach ($paramsReflection as $paramReflection) {
301 $this->typeProcessor->getParamDescription($paramReflection)
$_option $_optionId $class
◆ testGetParamTypeWithIncorrectAnnotation()
testGetParamTypeWithIncorrectAnnotation |
( |
| ) |
|
@expectedException \LogicException @expectedExceptionMessageRegExp /
- Parameters
-
annotation | is incorrect for the parameter "name" \w+/ |
Definition at line 249 of file TypeProcessorTest.php.
251 $class =
new ClassReflection(DataObject::class);
252 $methodReflection =
$class->getMethod(
'setName');
253 $paramsReflection = $methodReflection->getParameters();
254 $this->typeProcessor->getParamType($paramsReflection[0]);
$_option $_optionId $class
◆ testGetReturnTypeWithInheritDocBlock()
testGetReturnTypeWithInheritDocBlock |
( |
| ) |
|
Checks a case when method has only @inheritdoc
annotation.
Definition at line 330 of file TypeProcessorTest.php.
334 'isRequired' =>
true,
335 'description' =>
null,
336 'parameterCount' => 0
339 $classReflection =
new ClassReflection(TSample::class);
340 $methodReflection = $classReflection->getMethod(
'getPropertyName');
342 self::assertEquals($expected, $this->typeProcessor->getGetterReturnType($methodReflection));
◆ testGetReturnTypeWithoutReturnTag()
testGetReturnTypeWithoutReturnTag |
( |
| ) |
|
Checks a case when method and parent interface don't have @return
annotation.
@expectedException \InvalidArgumentException @expectedExceptionMessage Method's return type must be specified using
- Returns
- annotation. See Magento\Framework\Reflection\Test\Unit\Fixture\TSample::getName()
Definition at line 351 of file TypeProcessorTest.php.
353 $classReflection =
new ClassReflection(TSample::class);
354 $methodReflection = $classReflection->getMethod(
'getName');
355 $this->typeProcessor->getGetterReturnType($methodReflection);
◆ testGetTypeData()
Test retrieval of data type details for the given type name.
Definition at line 66 of file TypeProcessorTest.php.
68 $this->typeProcessor->setTypeData(
'typeA', [
'dataA']);
69 $this->assertEquals([
'dataA'], $this->typeProcessor->getTypeData(
'typeA'));
◆ testGetTypeDataInvalidArgumentException()
testGetTypeDataInvalidArgumentException |
( |
| ) |
|
@expectedException \InvalidArgumentException @expectedExceptionMessage The "NonExistentType" data type isn't declared. Verify the type and try again.
Definition at line 58 of file TypeProcessorTest.php.
60 $this->typeProcessor->getTypeData(
'NonExistentType');
◆ testGetTypesData()
Test Retrieving of processed types data.
Definition at line 32 of file TypeProcessorTest.php.
34 $this->typeProcessor->setTypeData(
'typeA', [
'dataA']);
35 $this->typeProcessor->setTypeData(
'typeB', [
'dataB']);
37 [
'typeA' => [
'dataA'],
'typeB' => [
'dataB']],
38 $this->typeProcessor->getTypesData()
◆ testIsArrayType()
Definition at line 115 of file TypeProcessorTest.php.
117 $this->assertFalse($this->typeProcessor->isArrayType(
'string'));
118 $this->assertTrue($this->typeProcessor->isArrayType(
'string[]'));
◆ testIsTypeAny()
Definition at line 107 of file TypeProcessorTest.php.
109 $this->assertTrue($this->typeProcessor->isTypeAny(
'mixed'));
110 $this->assertTrue($this->typeProcessor->isTypeAny(
'mixed[]'));
111 $this->assertFalse($this->typeProcessor->isTypeAny(
'int'));
112 $this->assertFalse($this->typeProcessor->isTypeAny(
'int[]'));
◆ testIsTypeSimple()
Definition at line 96 of file TypeProcessorTest.php.
98 $this->assertTrue($this->typeProcessor->isTypeSimple(
'string'));
99 $this->assertTrue($this->typeProcessor->isTypeSimple(
'string[]'));
100 $this->assertTrue($this->typeProcessor->isTypeSimple(
'int'));
101 $this->assertTrue($this->typeProcessor->isTypeSimple(
'float'));
102 $this->assertTrue($this->typeProcessor->isTypeSimple(
'double'));
103 $this->assertTrue($this->typeProcessor->isTypeSimple(
'boolean'));
104 $this->assertFalse($this->typeProcessor->isTypeSimple(
'blah'));
◆ testIsValidTypeDeclaration()
testIsValidTypeDeclaration |
( |
| ) |
|
Definition at line 121 of file TypeProcessorTest.php.
123 $this->assertTrue($this->typeProcessor->isValidTypeDeclaration(
'Traversable'));
124 $this->assertTrue($this->typeProcessor->isValidTypeDeclaration(
'stdObj'));
125 $this->assertTrue($this->typeProcessor->isValidTypeDeclaration(
'array'));
126 $this->assertTrue($this->typeProcessor->isValidTypeDeclaration(
'callable'));
127 $this->assertTrue($this->typeProcessor->isValidTypeDeclaration(
'self'));
128 $this->assertTrue($this->typeProcessor->isValidTypeDeclaration(
'self'));
129 $this->assertFalse($this->typeProcessor->isValidTypeDeclaration(
'string'));
130 $this->assertFalse($this->typeProcessor->isValidTypeDeclaration(
'string[]'));
131 $this->assertFalse($this->typeProcessor->isValidTypeDeclaration(
'int'));
132 $this->assertFalse($this->typeProcessor->isValidTypeDeclaration(
'float'));
133 $this->assertFalse($this->typeProcessor->isValidTypeDeclaration(
'double'));
134 $this->assertFalse($this->typeProcessor->isValidTypeDeclaration(
'boolean'));
135 $this->assertFalse($this->typeProcessor->isValidTypeDeclaration(
'[]'));
136 $this->assertFalse($this->typeProcessor->isValidTypeDeclaration(
'mixed[]'));
137 $this->assertFalse($this->typeProcessor->isValidTypeDeclaration(
'stdObj[]'));
138 $this->assertFalse($this->typeProcessor->isValidTypeDeclaration(
'Traversable[]'));
◆ testNormalizeType()
Definition at line 87 of file TypeProcessorTest.php.
89 $this->assertEquals(
'blah', $this->typeProcessor->normalizeType(
'blah'));
90 $this->assertEquals(
'string', $this->typeProcessor->normalizeType(
'str'));
91 $this->assertEquals(
'int', $this->typeProcessor->normalizeType(
'integer'));
92 $this->assertEquals(
'boolean', $this->typeProcessor->normalizeType(
'bool'));
93 $this->assertEquals(
'anyType', $this->typeProcessor->normalizeType(
'mixed'));
◆ testProcessSimpleTypeException()
testProcessSimpleTypeException |
( |
|
$value, |
|
|
|
$type |
|
) |
| |
@dataProvider processSimpleTypeExceptionProvider
Definition at line 214 of file TypeProcessorTest.php.
216 $this->expectException(
217 SerializationException::class,
218 'Invalid type for value: "' .
$value .
'". Expected Type: "' .
$type .
'"' 220 $this->typeProcessor->processSimpleAndAnyType(
$value,
$type);
◆ testProcessSimpleTypeIntArrayToStringArray()
testProcessSimpleTypeIntArrayToStringArray |
( |
| ) |
|
◆ testProcessSimpleTypeIntToString()
testProcessSimpleTypeIntToString |
( |
| ) |
|
◆ testProcessSimpleTypeInvalidType()
testProcessSimpleTypeInvalidType |
( |
| ) |
|
@expectedException \Magento\Framework\Exception\SerializationException @expectedExceptionMessage The "integer" value's type is invalid. The "int[]" type was expected. Verify and try again.
Definition at line 238 of file TypeProcessorTest.php.
242 $this->typeProcessor->processSimpleAndAnyType(
$value,
$type);
◆ testProcessSimpleTypeMixed()
testProcessSimpleTypeMixed |
( |
| ) |
|
◆ testProcessSimpleTypeStringArrayToIntArray()
testProcessSimpleTypeStringArrayToIntArray |
( |
| ) |
|
Definition at line 204 of file TypeProcessorTest.php.
206 $value = [
'1',
'2',
'3',
'4',
'5'];
208 $this->assertSame([1, 2, 3, 4, 5], $this->typeProcessor->processSimpleAndAnyType(
$value,
$type));
◆ testProcessSimpleTypeStringToInt()
testProcessSimpleTypeStringToInt |
( |
| ) |
|
◆ testSetTypeDataArrayMerge()
testSetTypeDataArrayMerge |
( |
| ) |
|
Test data type details for the same type name set multiple times.
Definition at line 75 of file TypeProcessorTest.php.
77 $this->typeProcessor->setTypeData(
'typeA', [
'dataA1']);
78 $this->typeProcessor->setTypeData(
'typeA', [
'dataA2']);
79 $this->typeProcessor->setTypeData(
'typeA', [
'dataA3']);
80 $this->typeProcessor->setTypeData(
'typeA', [
null]);
82 [
'dataA1',
'dataA2',
'dataA3',
null],
83 $this->typeProcessor->getTypeData(
'typeA')
◆ testSetTypesData()
Test set of processed types data.
Definition at line 45 of file TypeProcessorTest.php.
47 $this->typeProcessor->setTypeData(
'typeC', [
'dataC']);
48 $this->assertEquals([
'typeC' => [
'dataC']], $this->typeProcessor->getTypesData());
49 $typeData = [
'typeA' => [
'dataA'],
'typeB' => [
'dataB']];
50 $this->typeProcessor->setTypesData($typeData);
51 $this->assertEquals($typeData, $this->typeProcessor->getTypesData());
◆ testTranslateArrayTypeName()
testTranslateArrayTypeName |
( |
| ) |
|
Definition at line 171 of file TypeProcessorTest.php.
173 $this->assertEquals(
'ArrayOfComplexType', $this->typeProcessor->translateArrayTypeName(
'complexType'));
◆ testTranslateTypeName()
testTranslateTypeName |
( |
| ) |
|
Definition at line 150 of file TypeProcessorTest.php.
153 'TestModule1V1EntityItem',
154 $this->typeProcessor->translateTypeName(\
Magento\TestModule1\Service\V1\Entity\Item::class)
157 'TestModule3V1EntityParameter[]',
158 $this->typeProcessor->translateTypeName(
'\Magento\TestModule3\Service\V1\Entity\Parameter[]')
◆ testTranslateTypeNameInvalidArgumentException()
testTranslateTypeNameInvalidArgumentException |
( |
| ) |
|
@expectedException \InvalidArgumentException @expectedExceptionMessage The "\Magento\TestModule3\V1\Parameter[]" parameter type is invalid. Verify the parameter and try again.
Definition at line 166 of file TypeProcessorTest.php.
168 $this->typeProcessor->translateTypeName(
'\Magento\TestModule3\V1\Parameter[]');
The documentation for this class was generated from the following file: