示例#1
0
 /**
  * @test
  */
 public function renderReturnsUnmodifiedChildNodesIfNoValueIsSpecified()
 {
     $childNodes = 'input value " & äöüß@';
     $this->subject->expects($this->once())->method('renderChildren')->will($this->returnValue($childNodes));
     $actualResult = $this->subject->render();
     $this->assertEquals($childNodes, $actualResult);
 }
示例#2
0
	/**
	 * @test
	 */
	public function renderReturnsResultOfContentObjectRenderer() {
		$this->subject->expects($this->any())->method('renderChildren')->will($this->returnValue('innerContent'));
		$contentObjectRendererMock = $this->getMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class, array(), array(), '', FALSE);
		$contentObjectRendererMock->expects($this->once())->method('stdWrap')->will($this->returnValue('foo'));
		GeneralUtility::addInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class, $contentObjectRendererMock);
		$this->assertEquals('foo', $this->subject->render('42'));
	}
示例#3
0
 public function testWitoutOptions()
 {
     $otpions = array('test', 'has', 'processed');
     $this->column->setOptions($otpions);
     $this->assertSame($otpions, $this->column->getOptions());
     $this->column->removeOptions();
     $this->assertEquals('test', $this->column->render('test', array()));
 }
示例#4
0
 public function testRenderWithRenderer()
 {
     $test = $this;
     $this->column->setRenderer(function ($value, $rowData, $cell) use($test) {
         $test->assertTrue(is_string($value));
         $test->assertInstanceOf('stdClass', $rowData);
         $test->assertInstanceOf('Nette\\Utils\\Html', $cell);
         return \Nette\Utils\Strings::upper($value);
     });
     $result = $this->column->render(array('testing', 'is', 'awesome'), array());
     $this->assertEquals('TESTING, IS, AWESOME', $result);
 }
 /**
  * @test
  */
 public function callingRenderAssignsVariablesCorrectlyToUriBuilder()
 {
     $this->uriBuilder->expects($this->once())->method('setSection')->with('section')->will($this->returnSelf());
     $this->uriBuilder->expects($this->once())->method('setArguments')->with(array('additionalParams'))->will($this->returnSelf());
     $this->uriBuilder->expects($this->once())->method('setArgumentsToBeExcludedFromQueryString')->with(array('argumentsToBeExcludedFromQueryString'))->will($this->returnSelf());
     $this->uriBuilder->expects($this->once())->method('setFormat')->with('format')->will($this->returnSelf());
     $expectedModifiedArguments = array('module' => 'the/path', 'moduleArguments' => array('arguments', '@action' => 'action'));
     $this->uriBuilder->expects($this->once())->method('uriFor')->with('index', $expectedModifiedArguments);
     // fallback for the method chaining of the URI builder
     $this->uriBuilder->expects($this->any())->method($this->anything())->will($this->returnValue($this->uriBuilder));
     $this->viewHelper->render('the/path', 'action', array('arguments'), 'section', 'format', array('additionalParams'), true, array('argumentsToBeExcludedFromQueryString'));
 }
 /**
  * @return void
  */
 public function testRenderCompress()
 {
     $this->PartialCacheView = $this->getMockBuilder(PartialCacheView::class)->setMethods(['_getViewFileName', '_render'])->setConstructorArgs([null, null, null, ['compress' => true]])->getMock();
     $this->PartialCacheView->expects($this->once())->method('_getViewFileName')->willReturn('view');
     $this->PartialCacheView->expects($this->once())->method('_render')->willReturn(file_get_contents($this->testCacheFile));
     $this->PartialCacheView->autoLayout(false);
     $content = file_get_contents($this->testCacheFile);
     $content = str_replace('cachetime:0', 'cachetime:' . (time() - HOUR), $content);
     file_put_contents($this->tmpDir . 'view', $content);
     $result = $this->PartialCacheView->render();
     $this->assertSame('<h1>Test</h1> <p>Some paragraph.</p>', $result);
     $this->assertSame('<!--cachetime:0--><h1>Test</h1> <p>Some paragraph.</p>', file_get_contents($this->tmpDir . 'view'));
 }
 /**
  * @test
  * @dataProvider renderReturnsFilesForFoldersDataProvider
  */
 public function renderReturnsFilesForFolders($configuration, $expected)
 {
     $folderMap = array();
     $fileCount = 1;
     for ($i = 1; $i < 4; $i++) {
         $fileArray = array();
         for ($j = 1; $j < 4; $j++) {
             $file = $this->getMock(\TYPO3\CMS\Core\Resource\File::class, array(), array(), '', FALSE);
             $file->expects($this->any())->method('getName')->will($this->returnValue('File ' . $fileCount));
             $file->expects($this->any())->method('hasProperty')->with('name')->will($this->returnValue(TRUE));
             $file->expects($this->any())->method('getProperty')->with('name')->will($this->returnValue('File ' . $fileCount));
             $fileArray[] = $file;
             $fileCount++;
         }
         $folder = $this->getMock(\TYPO3\CMS\Core\Resource\Folder::class, array(), array(), '', FALSE);
         $folder->expects($this->any())->method('getFiles')->will($this->returnValue($fileArray));
         $folderMap[] = array($i . ':myfolder/', $folder);
     }
     $resourceFactory = $this->getMock(\TYPO3\CMS\Core\Resource\ResourceFactory::class);
     $resourceFactory->expects($this->any())->method('getFolderObjectFromCombinedIdentifier')->will($this->returnValueMap($folderMap));
     $fileCollector = $this->getMock(FileCollector::class, array('getResourceFactory'));
     $fileCollector->expects($this->any())->method('getResourceFactory')->will($this->returnValue($resourceFactory));
     $this->subject->expects($this->any())->method('getFileCollector')->will($this->returnValue($fileCollector));
     $this->assertSame($expected, $this->subject->render($configuration));
 }
 /**
  * @test
  */
 public function renderCallsStandardWrapOnResultStringIfGivenInConfiguration()
 {
     $this->addMockViewToSubject();
     $configuration = array('stdWrap.' => array('foo' => 'bar'));
     $this->standaloneView->expects($this->any())->method('render')->will($this->returnValue('baz'));
     $this->contentObjectRenderer->expects($this->once())->method('stdWrap')->with('baz', array('foo' => 'bar'));
     $this->subject->render($configuration);
 }
 /**
  * @return void
  */
 public function testWithDataAndSourceCollection()
 {
     $this->file->expects($this->at(1))->method('process')->will($this->returnValue($this->processedFiles[1]));
     $this->file->expects($this->at(2))->method('process')->will($this->returnValue($this->processedFiles[2]));
     $this->file->expects($this->at(3))->method('process')->will($this->returnValue($this->processedFiles[0]));
     $this->imageRendererConfiguration->expects($this->once())->method('getSourceCollection')->will($this->returnValue([10 => ['width' => '360m', 'dataKey' => 'small'], 20 => ['width' => '720m', 'dataKey' => 'small-retina']]));
     $this->imageRendererConfiguration->expects($this->once())->method('getLayoutKey')->will($this->returnValue('data'));
     $this->assertEquals('<img src="image.jpg" alt="alt" title="title" data-small="image360.jpg" data-small-retina="image720.jpg" />', $this->imageRenderer->render($this->file, '1000', '1000', []));
 }
 /**
  * @test
  */
 public function renderDoesNotModifySourceIfItIsAnObjectThatCantBeConvertedToAString()
 {
     $user = new UserWithoutToString('Xaver <b>Cross-Site</b>');
     $this->viewHelper->expects($this->once())->method('buildRenderChildrenClosure')->willReturn(function () {
         throw new \Exception('rendderChildrenClosure was invoked but should not have been');
     });
     $this->viewHelper->setArguments(['value' => $user]);
     $actualResult = $this->viewHelper->render();
     $this->assertSame($user, $actualResult);
 }
示例#11
0
 /**
  * @dataProvider dateViewHelperFormatsDateLocalizedDataProvider
  *
  * @test
  */
 public function dateViewHelperFormatsDateLocalized($locale, $expected)
 {
     $format = '%d. %B %Y';
     // 2013-02-03 11:40 UTC
     $timestamp = '@1359891658';
     if (!setlocale(LC_COLLATE, $locale)) {
         $this->markTestSkipped('Locale ' . $locale . ' is not available.');
     }
     $this->setCustomLocale($locale);
     $this->assertEquals($expected, $this->subject->render($timestamp, $format));
 }
示例#12
0
	/**
	 * @test
	 * @expectedException \LogicException
	 * @expectedExceptionCode 1414513947
	 */
	public function specificExceptionsCanBeIgnoredByExceptionHandler() {
		$contentObjectFixture = $this->createContentObjectThrowingExceptionFixture();

		$configuration = array(
			'exceptionHandler' => '1',
			'exceptionHandler.' => array(
				'ignoreCodes.' => array('10.' => '1414513947'),
			)
		);

		$this->subject->render($contentObjectFixture, $configuration);
	}
 /**
  * @test
  */
 public function viewHelperUsesSpecifiedAccountForCheck()
 {
     $mockAccount = $this->createMock(\Neos\Flow\Security\Account::class);
     $mockAccount->expects($this->any())->method('hasRole')->will($this->returnCallback(function (Role $role) {
         switch ($role->getIdentifier()) {
             case 'Neos.FluidAdaptor:Administrator':
                 return true;
         }
     }));
     $this->mockViewHelper->expects($this->any())->method('renderThenChild')->will($this->returnValue('true'));
     $this->mockViewHelper->expects($this->any())->method('renderElseChild')->will($this->returnValue('false'));
     $arguments = ['role' => new Role('Neos.FluidAdaptor:Administrator'), 'packageKey' => null, 'account' => $mockAccount];
     $this->mockViewHelper->setArguments($arguments);
     $actualResult = $this->mockViewHelper->render();
     $this->assertEquals('true', $actualResult, 'Full role identifier in role argument is accepted');
 }
 /**
  * @test
  * @dataProvider renderReturnsFilesForFoldersDataProvider
  */
 public function renderReturnsFilesForFolders($configuration, $expected, $recursive = false)
 {
     $folderMap = array();
     $folders = array();
     $fileCount = 1;
     $filesArrayForFolder = [];
     for ($i = 1; $i < 4; $i++) {
         $filesArrayForFolder[$i] = [];
         for ($j = 1; $j < 4; $j++) {
             $file = $this->getMock(File::class, [], [], '', false);
             $file->expects($this->any())->method('getName')->will($this->returnValue('File ' . $fileCount));
             $file->expects($this->any())->method('hasProperty')->with('name')->will($this->returnValue(true));
             $file->expects($this->any())->method('getProperty')->with('name')->will($this->returnValue('File ' . $fileCount));
             $filesArrayForFolder[$i][] = $file;
             $fileCount++;
         }
         $folder = $this->getMock(Folder::class, array(), array(), '', false);
         if ($recursive) {
             if ($i < 3) {
                 $folders[$i] = $folder;
                 $folderMap[$i] = array('1:myfolder/mysubfolder-' . $i . '/', $folder);
             } else {
                 $folder->expects($this->any())->method('getSubfolders')->will($this->returnValue($folders));
                 $folderMap[$i] = array('1:myfolder/', $folder);
             }
         } else {
             $folderMap[$i] = array($i . ':myfolder/', $folder);
         }
     }
     foreach ($folderMap as $i => $folderMapInfo) {
         if ($i < 3 || !$recursive) {
             $folderMapInfo[1]->expects($this->any())->method('getFiles')->will($this->returnValue($filesArrayForFolder[$i]));
         } else {
             $recursiveFiles = array_merge($filesArrayForFolder[3], $filesArrayForFolder[1], $filesArrayForFolder[2]);
             $folderMapInfo[1]->expects($this->any())->method('getFiles')->will($this->returnValue($recursiveFiles));
         }
     }
     $resourceFactory = $this->getMock(ResourceFactory::class);
     $resourceFactory->expects($this->any())->method('getFolderObjectFromCombinedIdentifier')->will($this->returnValueMap($folderMap));
     $fileCollector = $this->getMock(FileCollector::class, array('getResourceFactory'));
     $fileCollector->expects($this->any())->method('getResourceFactory')->will($this->returnValue($resourceFactory));
     $this->subject->expects($this->any())->method('getFileCollector')->will($this->returnValue($fileCollector));
     $this->assertSame($expected, $this->subject->render($configuration));
 }
 /**
  * @test
  * @dataProvider conversionTestingDataProvider
  */
 public function viewHelperConvertsCorrectly($input, $mode, $expected)
 {
     $this->assertSame($expected, $this->subject->render($input, $mode), sprintf('The conversion with mode "%s" did not perform as expected.', $mode));
 }
示例#16
0
 /**
  * @test
  */
 public function renderRendersChildren()
 {
     $this->subject->expects($this->once())->method('renderChildren')->will($this->returnValue('foo'));
     $actualResult = $this->subject->render();
     $this->assertEquals('foo', $actualResult);
 }
 /**
  * @test
  */
 public function renderReturnsContentFromDefaultObjectIfKeyDoesNotExist()
 {
     $conf = array('key' => 'not existing', 'default' => 'TEXT', 'default.' => array('value' => 'expected value'));
     $this->assertSame('expected value', $this->subject->render($conf));
 }
 /**
  * @test
  * @expectedException \TYPO3\CMS\Fluid\View\Exception\InvalidTemplateResourceException
  */
 public function renderThrowsExceptionIfSpecifiedTemplateFileDoesNotExist()
 {
     $this->view->setTemplatePathAndFilename('NonExistingTemplatePath');
     @$this->view->render();
 }
 /**
  * @test
  */
 public function renderOutputWithAutoplayAndWithoutControllsIsCorrect()
 {
     /** @var File|\PHPUnit_Framework_MockObject_MockObject $fileResourceMock */
     $fileResourceMock = $this->getMock(File::class, array(), array(), '', false);
     $this->assertSame('<iframe src="//www.youtube.com/embed/7331?autohide=1&amp;autoplay=1&amp;enablejsapi=1&amp;origin=test.server.org&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>', $this->subject->render($fileResourceMock, '300m', '200', array('controls' => 0, 'autoplay' => 1)));
 }
 /**
  * @test
  */
 public function viewHelperHandlesMultiByteValuesCorrectly()
 {
     $this->viewHelper->expects($this->never())->method('renderChildren');
     $actualResult = $this->viewHelper->render(3, '...', 'Äßütest');
     $this->assertEquals('Äßü...', $actualResult);
 }
 /**
  * @test
  */
 public function formatNumberWithDecimalsDecimalPointAndSeparator()
 {
     $this->assertEquals('3.333,333', $this->fixture->render(3, ',', '.'));
 }
 /**
  * @test
  */
 public function callingRenderReturnsTagBuildersRenderResult()
 {
     $this->tagBuilder->expects($this->once())->method('render')->will($this->returnValue('renderingResult'));
     $this->assertSame('renderingResult', $this->viewHelper->render('path'));
 }
 /**
  * @test
  */
 public function renderCallsSetErrorClassAttribute()
 {
     $this->viewHelper->expects($this->once())->method('setErrorClassAttribute');
     $this->viewHelper->render();
 }
 /**
  * __test
  */
 public function renderDoesNotModifySourceIfItIsAnObjectThatCantBeConvertedToAString()
 {
     $user = new UserWithoutToString('Xaver <b>Cross-Site</b>');
     $actualResult = $this->viewHelper->render($user);
     $this->assertSame($user, $actualResult);
 }
示例#25
0
 /**
  * @test
  */
 public function renderOutputWithAutoplayAndWithoutControllsIsCorrect()
 {
     /** @var File|\PHPUnit_Framework_MockObject_MockObject $fileResourceMock */
     $fileResourceMock = $this->getMock(File::class, array(), array(), '', false);
     $this->assertSame('<iframe src="//player.vimeo.com/video/7331?autoplay=1&amp;title=0&amp;byline=0&amp;portrait=0" allowfullscreen width="300" height="200"></iframe>', $this->subject->render($fileResourceMock, '300m', '200', array('autoplay' => 1)));
 }