Example #1
0
 /**
  * Check builder configuration format
  */
 public function testBuilderConfiguration()
 {
     $this->getMockBuilder('Magento\\Framework\\Validator\\Builder')->disableOriginalConstructor()->getMock();
     $this->_initConfig([__DIR__ . '/_files/validation/positive/builder/validation.xml']);
     $builder = $this->_config->createValidatorBuilder('test_entity_a', 'check_builder');
     $this->assertInstanceOf('Magento\\Framework\\Validator\\Builder', $builder);
     $expected = [['alias' => '', 'class' => 'Magento\\Framework\\Validator\\Test\\Unit\\Test\\NotEmpty', 'options' => null, 'property' => 'int', 'type' => 'property'], ['alias' => 'stub', 'class' => 'Validator_Stub', 'options' => ['arguments' => [new \Magento\Framework\Validator\Constraint\Option('test_string_argument'), new \Magento\Framework\Validator\Constraint\Option(['option1' => 'value1', 'option2' => 'value2']), new \Magento\Framework\Validator\Constraint\Option\Callback(['Magento\\Framework\\Validator\\Test\\Unit\\Test\\Callback', 'getId'], null, true)], 'callback' => [new \Magento\Framework\Validator\Constraint\Option\Callback(['Magento\\Framework\\Validator\\Test\\Unit\\Test\\Callback', 'configureValidator'], null, true)], 'methods' => ['setOptionThree' => ['method' => 'setOptionThree', 'arguments' => [new \Magento\Framework\Validator\Constraint\Option(['argOption' => 'argOptionValue']), new \Magento\Framework\Validator\Constraint\Option\Callback(['Magento\\Framework\\Validator\\Test\\Unit\\Test\\Callback', 'getId'], null, true), new \Magento\Framework\Validator\Constraint\Option('10')]], 'enableOptionFour' => ['method' => 'enableOptionFour']]], 'property' => 'int', 'type' => 'property']];
     $this->assertAttributeEquals($expected, '_constraints', $builder);
 }