Neos\Flow\Tests\Unit\Validation\ValidatorResolverTest::buildBaseValidatorConjunctionBuildsCorrectValidationChainForCyclicRelations PHP Метод

buildBaseValidatorConjunctionBuildsCorrectValidationChainForCyclicRelations() публичный Метод

    public function buildBaseValidatorConjunctionBuildsCorrectValidationChainForCyclicRelations()
    {
        $fooMockObject = $this->getMockBuilder(\stdClass::class)->setMockClassName('FooMock')->getMock();
        $fooClassName = get_class($fooMockObject);
        $barMockObject = $this->getMockBuilder(\stdClass::class)->setMockClassName('BarMock')->getMock();
        $barClassName = get_class($barMockObject);
        $fooPropertyTagsValues = ['bar' => ['var' => [$barClassName]]];
        $barPropertyTagsValues = ['foo' => ['var' => [$fooClassName]]];
        $mockReflectionService = $this->getMockBuilder(ReflectionService::class)->disableOriginalConstructor()->getMock();
        $mockReflectionService->expects($this->any())->method('getAllImplementationClassNamesForInterface')->with(PolyTypeObjectValidatorInterface::class)->will($this->returnValue([]));
        $mockReflectionService->expects($this->any())->method('getClassPropertyNames')->will($this->returnValueMap([[$fooClassName, ['bar']], [$barClassName, ['foo']]]));
        $mockReflectionService->expects($this->any())->method('getPropertyTagsValues')->will($this->returnValueMap([[$fooClassName, 'bar', $fooPropertyTagsValues['bar']], [$barClassName, 'foo', $barPropertyTagsValues['foo']]]));
        $mockReflectionService->expects($this->any())->method('isPropertyAnnotatedWith')->will($this->returnValue(false));
        $mockReflectionService->expects($this->any())->method('getPropertyAnnotations')->will($this->returnValue([]));
        $mockObjectManager = $this->createMock(ObjectManagerInterface::class);
        $mockObjectManager->expects($this->any())->method('isRegistered')->will($this->returnValue(true));
        $mockObjectManager->expects($this->any())->method('getScope')->will($this->returnValue(Configuration::SCOPE_PROTOTYPE));
        $mockObjectManager->expects($this->any())->method('get')->with(ReflectionService::class)->will($this->returnValue($mockReflectionService));
        $validatorResolver = $this->getAccessibleMock(ValidatorResolver::class, ['resolveValidatorObjectName', 'createValidator']);
        $validatorResolver->_set('reflectionService', $mockReflectionService);
        $validatorResolver->_set('objectManager', $mockObjectManager);
        /* @var $validatorChain ConjunctionValidator */
        $validatorChain = $validatorResolver->getBaseValidatorConjunction($fooClassName);
        $fooValidators = $validatorChain->getValidators();
        $this->assertGreaterThan(0, $fooValidators->count());
        // ugh, it's so cumbersome to work with SplObjectStorage outside of iterations...
        $fooValidators->rewind();
        $barValidators = $fooValidators->current()->getPropertyValidators('bar');
        $this->assertGreaterThan(0, $barValidators->count());
        $barValidators->rewind();
        $barValidators = $barValidators->current()->getValidators();
        $this->assertGreaterThan(0, $barValidators->count());
        $barValidators->rewind();
        $this->assertGreaterThan(0, $barValidators->current()->getPropertyValidators('foo')->count());
    }
ValidatorResolverTest