public function testAddRelation()
{
// expected relation object after creation
$expectedRelationObject = new Relation();
$expectedRelationObject->id = 42;
// mocked value, not a real one
$expectedRelationObject->sourceContentId = 23;
$expectedRelationObject->sourceContentVersionNo = 1;
$expectedRelationObject->destinationContentId = 66;
$expectedRelationObject->type = RelationValue::COMMON;
// relation create struct
$relationCreateStruct = new Relation\CreateStruct();
$relationCreateStruct->destinationContentId = 66;
$relationCreateStruct->sourceContentId = 23;
$relationCreateStruct->sourceContentVersionNo = 1;
$relationCreateStruct->type = RelationValue::COMMON;
$handler = $this->getContentHandler();
$gatewayMock = $this->getGatewayMock();
$mapperMock = $this->getMapperMock();
$mapperMock->expects($this->once())->method('createRelationFromCreateStruct')->with($this->equalTo($relationCreateStruct))->will($this->returnValue($expectedRelationObject));
$gatewayMock->expects($this->once())->method('insertRelation')->with($this->equalTo($relationCreateStruct))->will($this->returnValue(42));
$result = $handler->addRelation($relationCreateStruct);
$this->assertEquals($result, $expectedRelationObject);
}