Neos\Flow\Tests\Unit\Validation\Validator\CollectionValidatorTest::collectionValidatorValidatesNestedObjectStructuresWithoutEndlessLooping PHP Method

collectionValidatorValidatesNestedObjectStructuresWithoutEndlessLooping() public method

    public function collectionValidatorValidatesNestedObjectStructuresWithoutEndlessLooping()
    {
        $classNameA = 'A' . md5(uniqid(mt_rand(), true));
        eval('class ' . $classNameA . '{ public $b = array(); public $integer = 5; }');
        $classNameB = 'B' . md5(uniqid(mt_rand(), true));
        eval('class ' . $classNameB . '{ public $a; public $c; public $integer = "Not an integer"; }');
        $A = new $classNameA();
        $B = new $classNameB();
        $A->b = [$B];
        $B->a = $A;
        $B->c = [$A];
        $this->mockValidatorResolver->expects($this->any())->method('createValidator')->with('Integer')->will($this->returnValue(new IntegerValidator()));
        $this->mockValidatorResolver->expects($this->any())->method('buildBaseValidatorConjunction')->will($this->returnValue(new GenericObjectValidator()));
        // Create validators
        $aValidator = new GenericObjectValidator([]);
        $this->validator->_set('options', ['elementValidator' => 'Integer', 'elementValidatorOptions' => []]);
        $integerValidator = new IntegerValidator([]);
        // Add validators to properties
        $aValidator->addPropertyValidator('b', $this->validator);
        $aValidator->addPropertyValidator('integer', $integerValidator);
        $result = $aValidator->validate($A)->getFlattenedErrors();
        $this->assertEquals('A valid integer number is expected.', $result['b.0'][0]->getMessage());
    }