|
<?php |
|
/** |
|
* Tests processing of URL items found in the XML |
|
*/ |
|
public function testProcessRelatedContent() |
|
{ |
|
$idArray = array( 1, 2, 3 ); |
|
|
|
$version = $this->getMock( 'ezp\\Content\\Version' ); |
|
$version->id = 1; |
|
$version->contentId = 1; |
|
|
|
$repository = $this->getMockBuilder( '\\ezp\\Base\\Repository' ) |
|
->disableOriginalConstructor() |
|
->getMock(); |
|
|
|
$repositoryHandler = $this->getMock( 'ezp\\Persistence\\Repository\\Handler' ); |
|
|
|
$fieldTypeService = $this->getMockBuilder( 'ezp\\Content\\FieldType\\Service' ) |
|
->setConstructorArgs( array( $repository, $repositoryHandler ) ) |
|
->getMock(); |
|
|
|
$fieldTypeService |
|
->expects( $this->exactly( 6 ) ) |
|
->method( 'addRelation' ) |
|
->with( |
|
$this->logicalOr( $this->equalTo( Relation::ATTRIBUTE ), $this->equalTo( Relation::LINK ) ), |
|
$version->contentId, |
|
$version->id, |
|
$this->logicalOr( $this->equalTo( 1 ), $this->equalTo( 2 ), $this->equalTo( 3 ) ), |
|
$this->isNull() |
|
); |
|
|
|
$repository |
|
->expects( $this->once() ) |
|
->method( 'getInternalFieldTypeService' ) |
|
->will( $this->returnValue( $fieldTypeService ) ); |
|
|
|
$inputParser = $this->getInputParserMock(); |
|
|
|
// Parser::process => DOMDocument |
|
$inputParser |
|
->expects( $this->once() ) |
|
->method( 'process' ) |
|
->will( $this->returnValue( $this->getMock( '\\DOMDocument' ) ) ); |
|
|
|
// Parser::getRelatedContentIdArray() => array |
|
$inputParser |
|
->expects( $this->once() ) |
|
->method( 'getRelatedContentIdArray' ) |
|
->will( $this->returnValue( $idArray ) ); |
|
|
|
// Parser::getLinkedContentIdArray() => array |
|
$inputParser |
|
->expects( $this->once() ) |
|
->method( 'getLinkedContentIdArray' ) |
|
->will( $this->returnValue( $idArray ) ); |
|
|
|
$handler = new InputHandler( $inputParser ); |
|
self::assertTrue( $handler->process( '', $repository, $version ) ); |
|
} |
|
?> |