public function setUp() { $this->convertEmailLinks = $this->getAccessibleMock('Networkteam\\Neos\\MailObfuscator\\Typoscript\\ConvertEmailLinksImplementation', array('getValue'), array(), '', FALSE); $this->mockContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock(); $this->mockContext->expects($this->any())->method('getWorkspaceName')->will($this->returnValue('live')); $this->mockNode = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->getMock(); $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext)); $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock(); $this->mockTsRuntime->expects($this->any())->method('getCurrentContext')->will($this->returnValue(array('node' => $this->mockNode))); $this->convertEmailLinks->_set('tsRuntime', $this->mockTsRuntime); $this->convertEmailLinks->_set('linkNameConverter', new \Networkteam\Neos\MailObfuscator\String\Converter\RewriteAtCharConverter()); $this->convertEmailLinks->_set('mailToHrefConverter', new \Networkteam\Neos\MailObfuscator\String\Converter\Mailto2HrefObfuscatingConverter()); srand(10); }
/** * @test * @dataProvider attributeExamples */ public function evaluateTests($properties, $expectedOutput) { $path = 'attributes/test'; $this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath, $that) use($path, $properties) { $relativePath = str_replace($path . '/', '', $evaluatePath); return ObjectAccess::getPropertyPath($properties, str_replace('/', '.', $relativePath)); })); $typoScriptObjectName = 'TYPO3.TypoScript:Attributes'; $renderer = new AttributesImplementation($this->mockTsRuntime, $path, $typoScriptObjectName); if ($properties !== null) { foreach ($properties as $name => $value) { ObjectAccess::setProperty($renderer, $name, $value); } } $result = $renderer->evaluate(); $this->assertEquals($expectedOutput, $result); }
public function setUp() { $this->pluginImplementation = $this->getAccessibleMock('TYPO3\\Neos\\TypoScript\\PluginImplementation', ['buildPluginRequest'], [], '', false); $this->mockHttpUri = $this->getMockBuilder('TYPO3\\Flow\\Http\\Uri')->disableOriginalConstructor()->getMock(); $this->mockHttpUri->expects($this->any())->method('getHost')->will($this->returnValue('localhost')); $this->mockHttpRequest = $this->getMockBuilder('TYPO3\\Flow\\Http\\Request')->disableOriginalConstructor()->getMock(); $this->mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($this->mockHttpUri)); $this->mockActionRequest = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\ActionRequest')->disableOriginalConstructor()->getMock(); $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest)); $this->mockControllerContext = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext')->disableOriginalConstructor()->getMock(); $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockActionRequest)); $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock(); $this->mockTsRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext)); $this->pluginImplementation->_set('tsRuntime', $this->mockTsRuntime); $this->mockDispatcher = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\Dispatcher')->disableOriginalConstructor()->getMock(); $this->pluginImplementation->_set('dispatcher', $this->mockDispatcher); }
public function setUp() { $this->pluginImplementation = $this->getAccessibleMock(PluginImplementation::class, ['buildPluginRequest'], [], '', false); $this->mockHttpUri = $this->getMockBuilder(Uri::class)->disableOriginalConstructor()->getMock(); $this->mockHttpUri->expects($this->any())->method('getHost')->will($this->returnValue('localhost')); $this->mockHttpRequest = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); $this->mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($this->mockHttpUri)); $this->mockActionRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock(); $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest)); $this->mockControllerContext = $this->getMockBuilder(ControllerContext::class)->disableOriginalConstructor()->getMock(); $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockActionRequest)); $this->mockTsRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock(); $this->mockTsRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext)); $this->pluginImplementation->_set('tsRuntime', $this->mockTsRuntime); $this->mockDispatcher = $this->getMockBuilder(Dispatcher::class)->disableOriginalConstructor()->getMock(); $this->pluginImplementation->_set('dispatcher', $this->mockDispatcher); }
/** * @test * @dataProvider tagExamples */ public function evaluateTests($properties, $attributes, $content, $expectedOutput) { $path = 'tag/test'; $this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath, $that) use($properties, $path, $attributes, $content) { $relativePath = str_replace($path . '/', '', $evaluatePath); switch ($relativePath) { case 'attributes': return $attributes; case 'content': return $content; } return isset($properties[$relativePath]) ? $properties[$relativePath] : NULL; })); $typoScriptObjectName = 'TYPO3.TypoScript:Tag'; $renderer = new TagImplementation($this->mockTsRuntime, $path, $typoScriptObjectName); $result = $renderer->evaluate(); $this->assertEquals($expectedOutput, $result); }
public function setUp() { parent::setUp(); $this->contentElementEditableService = new ContentElementEditableService(); $this->mockPrivilegeManager = $this->getMockBuilder(PrivilegeManagerInterface::class)->getMock(); $this->inject($this->contentElementEditableService, 'privilegeManager', $this->mockPrivilegeManager); $this->mockNodeAuthorizationService = $this->getMockBuilder(AuthorizationService::class)->getMock(); $this->inject($this->contentElementEditableService, 'nodeAuthorizationService', $this->mockNodeAuthorizationService); $this->mockHtmlAugmenter = $this->getMockBuilder(HtmlAugmenter::class)->getMock(); $this->inject($this->contentElementEditableService, 'htmlAugmenter', $this->mockHtmlAugmenter); $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock(); $this->mockContentContext = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Service\\ContentContext')->disableOriginalConstructor()->getMock(); $this->mockNode = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->getMock(); $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContentContext)); $this->mockNode->expects($this->any())->method('getNodeType')->will($this->returnValue(new NodeType('Acme.Test:Headline', [], []))); $this->mockTsContext = array('node' => $this->mockNode); $this->mockTsRuntime->expects($this->any())->method('getCurrentContext')->will($this->returnValue($this->mockTsContext)); }
/** * @test * @dataProvider responseHeadExamples */ public function evaluateTests($httpVersion, $statusCode, $headers, $expectedOutput) { $path = 'responseHead/test'; $this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath) use($path, $httpVersion, $statusCode, $headers) { $relativePath = str_replace($path . '/', '', $evaluatePath); switch ($relativePath) { case 'httpVersion': return $httpVersion; case 'statusCode': return $statusCode; case 'headers': return $headers; } return isset($properties[$relativePath]) ? $properties[$relativePath] : null; })); $typoScriptObjectName = 'TYPO3.TypoScript:Http.ResponseHead'; $renderer = new \TYPO3\TypoScript\TypoScriptObjects\Http\ResponseHeadImplementation($this->mockTsRuntime, $path, $typoScriptObjectName); $result = $renderer->evaluate(); $this->assertEquals($expectedOutput, $result); }
public function setUp() { parent::setUp(); $this->editableViewHelper = $this->getAccessibleMock('TYPO3\\Neos\\ViewHelpers\\ContentElement\\EditableViewHelper', array('renderChildren')); $this->mockPrivilegeManager = $this->getMockBuilder('TYPO3\\Flow\\Security\\Authorization\\PrivilegeManagerInterface')->getMock(); $this->inject($this->editableViewHelper, 'privilegeManager', $this->mockPrivilegeManager); $this->mockNodeAuthorizationService = $this->getMockBuilder(AuthorizationService::class)->getMock(); $this->inject($this->editableViewHelper, 'nodeAuthorizationService', $this->mockNodeAuthorizationService); $this->mockTemplateImplementation = $this->getMockBuilder('TYPO3\\TypoScript\\TypoScriptObjects\\TemplateImplementation')->disableOriginalConstructor()->getMock(); $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock(); $this->mockContentContext = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Service\\ContentContext')->disableOriginalConstructor()->getMock(); $this->mockNode = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->getMock(); $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContentContext)); $this->mockTsContext = array('node' => $this->mockNode); $this->mockTsRuntime->expects($this->any())->method('getCurrentContext')->will($this->returnValue($this->mockTsContext)); $this->mockTemplateImplementation->expects($this->any())->method('getTsRuntime')->will($this->returnValue($this->mockTsRuntime)); $this->mockView = $this->getAccessibleMock('TYPO3\\TypoScript\\TypoScriptObjects\\Helpers\\FluidView', array(), array(), '', FALSE); $this->mockView->expects($this->any())->method('getTypoScriptObject')->will($this->returnValue($this->mockTemplateImplementation)); $this->editableViewHelper->initializeArguments(); }
public function setUp() { $this->convertUrisImplementation = $this->getAccessibleMock('TYPO3\\Neos\\TypoScript\\ConvertUrisImplementation', array('tsValue'), array(), '', false); $this->mockWorkspace = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace')->disableOriginalConstructor()->getMock(); $this->mockContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock(); $this->mockContext->expects($this->any())->method('getWorkspace')->will($this->returnValue($this->mockWorkspace)); $this->mockNode = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->getMock(); $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext)); $this->mockHttpUri = $this->getMockBuilder('TYPO3\\Flow\\Http\\Uri')->disableOriginalConstructor()->getMock(); $this->mockHttpUri->expects($this->any())->method('getHost')->will($this->returnValue('localhost')); $this->mockHttpRequest = $this->getMockBuilder('TYPO3\\Flow\\Http\\Request')->disableOriginalConstructor()->getMock(); $this->mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($this->mockHttpUri)); $this->mockActionRequest = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\ActionRequest')->disableOriginalConstructor()->getMock(); $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest)); $this->mockControllerContext = $this->getMockBuilder('TYPO3\\Flow\\Mvc\\Controller\\ControllerContext')->disableOriginalConstructor()->getMock(); $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockActionRequest)); $this->mockLinkingService = $this->createMock('TYPO3\\Neos\\Service\\LinkingService'); $this->convertUrisImplementation->_set('linkingService', $this->mockLinkingService); $this->mockTsRuntime = $this->getMockBuilder('TYPO3\\TypoScript\\Core\\Runtime')->disableOriginalConstructor()->getMock(); $this->mockTsRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext)); $this->convertUrisImplementation->_set('tsRuntime', $this->mockTsRuntime); }
/** * @test * @dataProvider attributeExamples */ public function evaluateTests($properties, $expectedOutput, $expectedOutputAsArray) { // print_r(func_get_args()); $path = 'attributes/test'; $this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath, $that) use($path, $properties) { $relativePath = str_replace($path . '/', '', $evaluatePath); return ObjectAccess::getPropertyPath($properties, str_replace('/', '.', $relativePath)); })); $typoScriptObjectName = 'TYPO3.TypoScript:Attributes'; $renderer = new AttributesImplementation($this->mockTsRuntime, $path, $typoScriptObjectName); if ($properties !== NULL) { foreach ($properties as $name => $value) { ObjectAccess::setProperty($renderer, $name, $value); } } $result = $renderer->evaluate(); $this->assertInstanceOf('M12\\Foundation\\TypoScriptObjects\\AttributesImplementation', $result); $this->assertTrue(is_string($result->getAsString())); $this->assertTrue(is_array($result->getAsArray())); $this->assertEquals($expectedOutput, $result); $this->assertEquals($expectedOutput, $result->getAsString()); $this->assertEquals($expectedOutputAsArray, $result->getAsArray()); }
/** * @test */ public function evaluateLocalizesFilenameIfLocalize() { $this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath, $that) { $relativePath = str_replace('resourceUri/test/', '', $evaluatePath); switch ($relativePath) { case 'localize': return true; case 'path': return 'resource://Some.Package/Public/SomeResource'; case 'package': return 'Specified.Package'; } return null; })); $this->mockI18nService->expects($this->atLeastOnce())->method('getLocalizedFilename')->will($this->returnValue(array('resource://Some.Package/Public/LocalizedFilename'))); $this->mockResourceManager->expects($this->atLeastOnce())->method('getPublicPackageResourceUri')->will($this->returnValue('Static/Resources/Packages/Some.Package/LocalizedFilename')); $this->assertSame('Static/Resources/Packages/Some.Package/LocalizedFilename', $this->resourceUriImplementation->evaluate()); }
public function setUp() { $this->convertUrisImplementation = $this->getAccessibleMock(ConvertUrisImplementation::class, array('tsValue'), array(), '', false); $this->mockWorkspace = $this->getMockBuilder(Workspace::class)->disableOriginalConstructor()->getMock(); $this->mockContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); $this->mockContext->expects($this->any())->method('getWorkspace')->will($this->returnValue($this->mockWorkspace)); $this->mockNode = $this->getMockBuilder(NodeInterface::class)->getMock(); $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext)); $this->mockHttpUri = $this->getMockBuilder(Uri::class)->disableOriginalConstructor()->getMock(); $this->mockHttpUri->expects($this->any())->method('getHost')->will($this->returnValue('localhost')); $this->mockHttpRequest = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); $this->mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($this->mockHttpUri)); $this->mockActionRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock(); $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest)); $this->mockControllerContext = $this->getMockBuilder(ControllerContext::class)->disableOriginalConstructor()->getMock(); $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockActionRequest)); $this->mockLinkingService = $this->createMock(LinkingService::class); $this->convertUrisImplementation->_set('linkingService', $this->mockLinkingService); $this->mockTsRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock(); $this->mockTsRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext)); $this->convertUrisImplementation->_set('tsRuntime', $this->mockTsRuntime); }
public function setUp() { parent::setUp(); $this->editableViewHelper = $this->getAccessibleMock(EditableViewHelper::class, array('renderChildren')); $this->mockPrivilegeManager = $this->getMockBuilder(PrivilegeManagerInterface::class)->getMock(); $this->inject($this->editableViewHelper, 'privilegeManager', $this->mockPrivilegeManager); $this->mockNodeAuthorizationService = $this->getMockBuilder(AuthorizationService::class)->getMock(); $this->inject($this->editableViewHelper, 'nodeAuthorizationService', $this->mockNodeAuthorizationService); $this->mockContentElementEditableService = $this->getMockBuilder(ContentElementEditableService::class)->getMock(); $this->inject($this->editableViewHelper, 'contentElementEditableService', $this->mockContentElementEditableService); $this->mockTemplateImplementation = $this->getMockBuilder(TemplateImplementation::class)->disableOriginalConstructor()->getMock(); $this->mockTsRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock(); $this->mockContentContext = $this->getMockBuilder(ContentContext::class)->disableOriginalConstructor()->getMock(); $this->mockNode = $this->getMockBuilder(NodeInterface::class)->getMock(); $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContentContext)); $this->mockNode->expects($this->any())->method('getNodeType')->will($this->returnValue(new NodeType('Acme.Test:Headline', [], []))); $this->mockTsContext = array('node' => $this->mockNode); $this->mockTsRuntime->expects($this->any())->method('getCurrentContext')->will($this->returnValue($this->mockTsContext)); $this->mockTemplateImplementation->expects($this->any())->method('getTsRuntime')->will($this->returnValue($this->mockTsRuntime)); $this->mockView = $this->getAccessibleMock(FluidView::class, array(), array(), '', false); $this->mockView->expects($this->any())->method('getTypoScriptObject')->will($this->returnValue($this->mockTemplateImplementation)); $this->editableViewHelper->initializeArguments(); }
/** * @test */ public function renderPutsSiteNodeInTypoScriptContext() { $this->setUpMockView(); $this->mockRuntime->expects($this->once())->method('pushContextArray')->with($this->arrayHasKey('site')); $this->mockView->render(); }