8 require_once
__DIR__ .
'/../_files/app/code/Magento/SomeModule/Model/Three/Test.php';
9 require_once
__DIR__ .
'/../_files/app/code/Magento/SomeModule/Model/Two/Test.php';
10 require_once
__DIR__ .
'/../_files/app/code/Magento/SomeModule/Model/One/Test.php';
11 require_once
__DIR__ .
'/../_files/app/code/Magento/SomeModule/Model/Four/Test.php';
12 require_once
__DIR__ .
'/../_files/app/code/Magento/SomeModule/Model/Five/Test.php';
13 require_once
__DIR__ .
'/../_files/app/code/Magento/SomeModule/Model/Six/Test.php';
14 require_once
__DIR__ .
'/_files/ClassesForConstructorIntegrity.php';
24 $this->_model = new \Magento\Framework\Code\Validator\ConstructorIntegrity();
29 $this->assertEquals(
true, $this->_model->validate(\
Magento\SomeModule\Model\One\Test::class));
34 $this->assertEquals(
true, $this->_model->validate(\
Magento\SomeModule\Model\Two\Test::class));
39 $this->assertEquals(
true, $this->_model->validate(\
Magento\SomeModule\Model\Three\Test::class));
44 $fileName = realpath(
__DIR__ .
'/../_files/app/code/Magento/SomeModule/Model/Four/Test.php');
46 $this->expectException(\
Magento\Framework\Exception\ValidatorException::class);
47 $this->expectExceptionMessage(
'Extra parameters passed to parent construct: $factory. File: ' .
$fileName);
48 $this->_model->validate(\
Magento\SomeModule\Model\Four\Test::class);
53 $fileName = realpath(
__DIR__ .
'/../_files/app/code/Magento/SomeModule/Model/Five/Test.php');
55 $this->expectException(\
Magento\Framework\Exception\ValidatorException::class);
56 $this->expectExceptionMessage(
57 'Missed required argument factory in parent::__construct call. File: ' .
$fileName 59 $this->_model->validate(\
Magento\SomeModule\Model\Five\Test::class);
64 $fileName = realpath(
__DIR__ .
'/../_files/app/code/Magento/SomeModule/Model/Six/Test.php');
66 $this->expectException(\
Magento\Framework\Exception\ValidatorException::class);
67 $this->expectExceptionMessage(
68 'Incompatible argument type: Required type: \Magento\SomeModule\Model\Proxy. ' .
69 'Actual type: \Magento\SomeModule\Model\ElementFactory; File: ' .
73 $this->_model->validate(\
Magento\SomeModule\Model\Six\Test::class);
78 $fileName = realpath(
__DIR__) .
'/_files/ClassesForConstructorIntegrity.php';
80 $this->expectException(\
Magento\Framework\Exception\ValidatorException::class);
81 $this->expectExceptionMessage(
82 'Incompatible argument type: Required type: \Context. ' .
83 'Actual type: \ClassA; File: ' .
87 $this->_model->validate(
'ClassArgumentWrongOrderForParentArguments');
92 $fileName = realpath(
__DIR__) .
'/_files/ClassesForConstructorIntegrity.php';
94 $this->expectException(\
Magento\Framework\Exception\ValidatorException::class);
95 $this->expectExceptionMessage(
96 'Incompatible argument type: Required type: array. ' .
'Actual type: \ClassB; File: ' . PHP_EOL .
$fileName 98 $this->_model->validate(
'ClassArgumentWithWrongParentArgumentsType');
defined('TESTS_BP')||define('TESTS_BP' __DIR__
testValidateWrongOptionalParamsType()
testValidateIfClassHasMissingRequiredArguments()
testValidateIfClassHasExtraArgumentInTheParentConstructor()
testValidateIfClassHasIncompatibleArguments()
testValidateIfClassHasArgumentsQtyEqualToParentClass()
testValidateIfClassHasParentConstructCall()
testValidateIfParentClassExist()
testValidateWrongOrderForParentArguments()