public function testPreviewDefaultSiteaccess()
{
$contentId = 123;
$lang = 'eng-GB';
$versionNo = 3;
$locationId = 456;
$content = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\Content');
$location = $this->getMockBuilder('eZ\\Publish\\API\\Repository\\Values\\Content\\Location')->setConstructorArgs(array(array('id' => $locationId)))->getMockForAbstractClass();
// Repository expectations
$this->locationProvider->expects($this->once())->method('loadMainLocation')->with($contentId)->will($this->returnValue($location));
$this->contentService->expects($this->once())->method('loadContent')->with($contentId, array($lang), $versionNo)->will($this->returnValue($content));
$this->authorizationChecker->expects($this->once())->method('isGranted')->with($this->equalTo(new AuthorizationAttribute('content', 'versionread', array('valueObject' => $content))))->will($this->returnValue(true));
$previousSiteAccessName = 'foo';
$previousSiteAccess = new SiteAccess($previousSiteAccessName);
$request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request', array('duplicate'));
$this->previewHelper->expects($this->once())->method('getOriginalSiteAccess')->will($this->returnValue($previousSiteAccess));
$this->previewHelper->expects($this->once())->method('restoreConfigScope');
// Request expectations
$duplicatedRequest = $this->getDuplicatedRequest($location, $content, $previousSiteAccess);
$request->expects($this->once())->method('duplicate')->will($this->returnValue($duplicatedRequest));
// Kernel expectations
$expectedResponse = new Response();
$this->httpKernel->expects($this->once())->method('handle')->with($duplicatedRequest, HttpKernelInterface::SUB_REQUEST)->will($this->returnValue($expectedResponse));
$controller = $this->getPreviewController();
$this->assertSame($expectedResponse, $controller->previewContentAction($request, $contentId, $versionNo, $lang));
}