Neos\Flow\Tests\Unit\Mvc\Routing\IdentityRoutePartTest::resolveValueAppendsCounterIfNoMatchingObjectPathMappingWasFoundAndCreatedPathSegmentIsNotUnique PHP Метод

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

    public function resolveValueAppendsCounterIfNoMatchingObjectPathMappingWasFoundAndCreatedPathSegmentIsNotUnique()
    {
        $object = new \stdClass();
        $this->mockPersistenceManager->expects($this->atLeastOnce())->method('getIdentifierByObject')->with($object)->will($this->returnValue('TheIdentifier'));
        $this->mockPersistenceManager->expects($this->atLeastOnce())->method('getObjectByIdentifier')->with('TheIdentifier')->will($this->returnValue($object));
        $this->mockObjectPathMappingRepository->expects($this->once())->method('findOneByObjectTypeUriPatternAndIdentifier')->with('stdClass', 'SomeUriPattern', 'TheIdentifier')->will($this->returnValue(null));
        $existingObjectPathMapping = new ObjectPathMapping();
        $existingObjectPathMapping->setObjectType('stdClass');
        $existingObjectPathMapping->setUriPattern('SomeUriPattern');
        $existingObjectPathMapping->setPathSegment('The/Path/Segment');
        $existingObjectPathMapping->setIdentifier('AnotherIdentifier');
        $this->identityRoutePart->expects($this->once())->method('createPathSegmentForObject')->with($object)->will($this->returnValue('The/Path/Segment'));
        $this->mockObjectPathMappingRepository->expects($this->at(1))->method('findOneByObjectTypeUriPatternAndPathSegment')->with('stdClass', 'SomeUriPattern', 'The/Path/Segment', false)->will($this->returnValue($existingObjectPathMapping));
        $this->mockObjectPathMappingRepository->expects($this->at(2))->method('findOneByObjectTypeUriPatternAndPathSegment')->with('stdClass', 'SomeUriPattern', 'The/Path/Segment-1', false)->will($this->returnValue($existingObjectPathMapping));
        $this->mockObjectPathMappingRepository->expects($this->at(3))->method('findOneByObjectTypeUriPatternAndPathSegment')->with('stdClass', 'SomeUriPattern', 'The/Path/Segment-2', false)->will($this->returnValue(null));
        $expectedObjectPathMapping = new ObjectPathMapping();
        $expectedObjectPathMapping->setObjectType('stdClass');
        $expectedObjectPathMapping->setUriPattern('SomeUriPattern');
        $expectedObjectPathMapping->setPathSegment('The/Path/Segment-2');
        $expectedObjectPathMapping->setIdentifier('TheIdentifier');
        $this->mockObjectPathMappingRepository->expects($this->once())->method('add')->with($expectedObjectPathMapping);
        $this->mockObjectPathMappingRepository->expects($this->once())->method('persistEntities');
        $this->identityRoutePart->setObjectType('stdClass');
        $this->identityRoutePart->setUriPattern('SomeUriPattern');
        $this->assertTrue($this->identityRoutePart->_call('resolveValue', $object));
        $this->assertSame('the/path/segment-2', $this->identityRoutePart->getValue());
    }
IdentityRoutePartTest