public testCreateContentThrowsUnauthorizedException ( ) |
public function testCreateContentThrowsUnauthorizedException()
{
$repositoryMock = $this->getRepositoryMock();
$mockedService = $this->getPartlyMockedContentService();
$contentTypeServiceMock = $this->getContentTypeServiceMock();
$contentType = new ContentType(array('id' => 123, 'fieldDefinitions' => array()));
$contentCreateStruct = new ContentCreateStruct(array('ownerId' => 169, 'alwaysAvailable' => false, 'mainLanguageCode' => 'eng-US', 'contentType' => $contentType));
$repositoryMock->expects($this->once())->method('getCurrentUserReference')->will($this->returnValue(new UserReference(169)));
$contentTypeServiceMock->expects($this->once())->method('loadContentType')->with($this->equalTo(123))->will($this->returnValue($contentType));
$repositoryMock->expects($this->once())->method('getContentTypeService')->will($this->returnValue($contentTypeServiceMock));
$repositoryMock->expects($this->once())->method('canUser')->with($this->equalTo('content'), $this->equalTo('create'), $this->isInstanceOf($contentCreateStruct), $this->equalTo(array()))->will($this->returnValue(false));
$mockedService->createContent(new ContentCreateStruct(array('mainLanguageCode' => 'eng-US', 'contentType' => $contentType)), array());
}