eZ\Publish\Core\Repository\Tests\Service\Mock\RelationProcessorTest::testProcessFieldRelationsAddsRelations PHP Method

testProcessFieldRelationsAddsRelations() public method

Test for the processFieldRelations() method.
    public function testProcessFieldRelationsAddsRelations()
    {
        $relationProcessor = $this->getPartlyMockedRelationProcessor();
        $contentHandlerMock = $this->getPersistenceMockHandler('Content\\Handler');
        $contentTypeMock = $this->getMockForAbstractClass('eZ\\Publish\\API\\Repository\\Values\\ContentType\\ContentType');
        $existingRelations = array($this->getStubbedRelation(1, Relation::COMMON, null, 10), $this->getStubbedRelation(2, Relation::EMBED, null, 11), $this->getStubbedRelation(3, Relation::LINK, null, 12), $this->getStubbedRelation(5, Relation::EMBED | Relation::COMMON, null, 14), $this->getStubbedRelation(6, Relation::LINK | Relation::COMMON, null, 15), $this->getStubbedRelation(7, Relation::EMBED | Relation::LINK, null, 16));
        $inputRelations = array(Relation::EMBED => array_flip(array(11, 14, 16, 17)), Relation::LINK => array_flip(array(12, 15, 16, 17)), Relation::FIELD => array(42 => array_flip(array(13))));
        $contentTypeMock->expects($this->never())->method('getFieldDefinition');
        $contentHandlerMock->expects($this->never())->method('removeRelation');
        $contentHandlerMock->expects($this->at(0))->method('addRelation')->with(new CreateStruct(array('sourceContentId' => 24, 'sourceContentVersionNo' => 2, 'sourceFieldDefinitionId' => null, 'destinationContentId' => 17, 'type' => Relation::EMBED)));
        $contentHandlerMock->expects($this->at(1))->method('addRelation')->with(new CreateStruct(array('sourceContentId' => 24, 'sourceContentVersionNo' => 2, 'sourceFieldDefinitionId' => null, 'destinationContentId' => 17, 'type' => Relation::LINK)));
        $contentHandlerMock->expects($this->at(2))->method('addRelation')->with(new CreateStruct(array('sourceContentId' => 24, 'sourceContentVersionNo' => 2, 'sourceFieldDefinitionId' => 42, 'destinationContentId' => 13, 'type' => Relation::FIELD)));
        $relationProcessor->processFieldRelations($inputRelations, 24, 2, $contentTypeMock, $existingRelations);
    }