コード例 #1
0
	/**
	 * @return void
	 */
	protected function setUp() {
		$this->command = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Cli\Command::class, array('getCommandMethodReflection'), array(), '', FALSE);
		$this->mockMethodReflection = $this->getMock(\TYPO3\CMS\Extbase\Reflection\MethodReflection::class, array(), array(), '', FALSE);
		$this->command->expects($this->any())->method('getCommandMethodReflection')->will($this->returnValue($this->mockMethodReflection));
		$this->mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
		$this->command->_set('objectManager', $this->mockObjectManager);
	}
コード例 #2
0
 /**
  * @test
  */
 public function initializeObjectSetsRespectStoragePidToFalse()
 {
     $this->querySettings->expects($this->atLeastOnce())->method('setRespectStoragePage')->with(false);
     $fixture = $this->getMock(\TYPO3\CMS\Belog\Domain\Repository\HistoryEntryRepository::class, array('setDefaultQuerySettings'), array($this->objectManager));
     $fixture->expects($this->once())->method('setDefaultQuerySettings')->with($this->querySettings);
     $fixture->initializeObject();
 }
コード例 #3
0
ファイル: TaskTest.php プロジェクト: rickymathew/TYPO3.CMS
 /**
  * @test
  * @expectedException Exception
  */
 public function executeCallsLogExceptionOnCaughtExceptionAndRethrowsException()
 {
     $this->taskExecutor->expects($this->once())->method('execute')->will($this->throwException(new \Exception()));
     $this->task->_set('taskExecutor', $this->taskExecutor);
     $this->task->expects($this->once())->method('logException');
     $this->task->execute();
 }
コード例 #4
0
ファイル: CommandTest.php プロジェクト: khanhdeux/typo3test
 /**
  * @return void
  */
 public function setUp()
 {
     $this->command = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Command', array('getCommandMethodReflection'), array(), '', FALSE);
     $this->mockMethodReflection = $this->getMock('TYPO3\\CMS\\Extbase\\Reflection\\MethodReflection', array(), array(), '', FALSE);
     $this->command->expects($this->any())->method('getCommandMethodReflection')->will($this->returnValue($this->mockMethodReflection));
     $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
     $this->command->_set('objectManager', $this->mockObjectManager);
 }
コード例 #5
0
 /**
  * @test
  */
 public function renderReturnsResultOfContentObjectRenderer()
 {
     $this->subject->expects($this->any())->method('renderChildren')->will($this->returnValue('innerContent'));
     $contentObjectRendererMock = $this->getMock(ContentObjectRenderer::class, array(), array(), '', false);
     $contentObjectRendererMock->expects($this->once())->method('stdWrap')->will($this->returnValue('foo'));
     GeneralUtility::addInstance(ContentObjectRenderer::class, $contentObjectRendererMock);
     $this->assertEquals('foo', $this->subject->render('42'));
 }
コード例 #6
0
 /**
  * @test
  * @expectedException \InvalidArgumentException
  * @expectedExceptionCode 1425236663
  */
 public function moduleDispatcherIsCalled()
 {
     $GLOBALS['TBE_MODULES'] = array('_PATHS' => array('module_fixture' => __DIR__ . '/../Fixtures/ModuleFixture/'));
     $this->requestMock->expects($this->any())->method('getQueryParams')->will($this->returnValue(array('M' => 'module_fixture')));
     $this->formProtectionMock->expects($this->once())->method('validateToken')->will($this->returnValue(true));
     $this->subject->expects($this->once())->method('boot');
     $this->subject->expects($this->atLeastOnce())->method('getFormProtection')->will($this->returnValue($this->formProtectionMock));
     $this->subject->handleRequest($this->requestMock);
 }
コード例 #7
0
 /**
  * @test
  * @expectedException \InvalidArgumentException
  * @expectedExceptionCode 1425236663
  */
 public function moduleDispatcherIsCalled()
 {
     $GLOBALS['TBE_MODULES'] = array('_PATHS' => array('_dispatcher' => array(), 'module_fixture' => __DIR__ . '/Fixtures/ModuleFixture/'));
     $_GET['M'] = 'module_fixture';
     $this->formProtectionMock->expects($this->once())->method('validateToken')->will($this->returnValue(TRUE));
     $this->subject->expects($this->once())->method('boot');
     $this->subject->expects($this->once())->method('getFormProtection')->will($this->returnValue($this->formProtectionMock));
     $this->subject->handleRequest();
 }
コード例 #8
0
 /**
  * @test
  */
 public function createEntryFromRawDataSetsPropertiesInEntryObject()
 {
     $rawModule = array('name' => 'nameTest', 'title' => 'titleTest', 'onclick' => 'onclickTest', 'icon' => array('test' => '123'), 'link' => 'linkTest', 'description' => 'descriptionTest', 'navigationComponentId' => 'navigationComponentIdTest');
     $languageServiceMock = $this->getMock(\TYPO3\CMS\Lang\LanguageService::class, array(), array(), '', false);
     $languageServiceMock->expects($this->once())->method('sL')->will($this->returnValue('titleTest'));
     $this->moduleController->expects($this->once())->method('getLanguageService')->will($this->returnValue($languageServiceMock));
     /** @var $entry \TYPO3\CMS\Backend\Domain\Model\Module\BackendModule */
     $entry = $this->moduleController->_call('createEntryFromRawData', $rawModule);
     $this->assertEquals('nameTest', $entry->getName());
     $this->assertEquals('titleTest', $entry->getTitle());
     $this->assertEquals('linkTest', $entry->getLink());
     $this->assertEquals('onclickTest', $entry->getOnClick());
     $this->assertEquals('navigationComponentIdTest', $entry->getNavigationComponentId());
     $this->assertEquals('descriptionTest', $entry->getDescription());
     $this->assertEquals(array('test' => '123'), $entry->getIcon());
 }
コード例 #9
0
 /**
  * Sets up this test case
  *
  * @return void
  */
 protected function setUp()
 {
     $this->singletonInstances = GeneralUtility::getSingletonInstances();
     $this->view = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\StandaloneView::class, array('testFileExistence', 'buildParserConfiguration', 'getOrParseAndStoreTemplate'), array(), '', false);
     $this->mockConfigurationManager = $this->getMock(ConfigurationManagerInterface::class);
     $this->mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
     $this->mockObjectManager->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'objectManagerCallback')));
     $this->mockRequest = $this->getMock(Request::class);
     $this->mockUriBuilder = $this->getMock(UriBuilder::class);
     $this->mockContentObject = $this->getMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
     $this->mockControllerContext = $this->getMock(ControllerContext::class);
     $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockRequest));
     $this->mockTemplatePaths = $this->getMock(TemplatePaths::class);
     $this->mockViewHelperVariableContainer = $this->getMock(ViewHelperVariableContainer::class);
     $this->mockRenderingContext = $this->getMock(\TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextFixture::class);
     $this->mockRenderingContext->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
     $this->mockRenderingContext->expects($this->any())->method('getViewHelperVariableContainer')->will($this->returnValue($this->mockViewHelperVariableContainer));
     $this->mockRenderingContext->expects($this->any())->method('getVariableProvider')->willReturn($this->mockVariableProvider);
     $this->mockRenderingContext->expects($this->any())->method('getTemplatePaths')->willReturn($this->mockTemplatePaths);
     $this->view->_set('objectManager', $this->mockObjectManager);
     $this->view->_set('baseRenderingContext', $this->mockRenderingContext);
     $this->view->_set('controllerContext', $this->mockControllerContext);
     $this->view->expects($this->any())->method('getOrParseAndStoreTemplate')->willReturn($this->mockParsedTemplate);
     GeneralUtility::setSingletonInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class, $this->mockObjectManager);
     GeneralUtility::addInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class, $this->mockContentObject);
     $this->mockCacheManager = $this->getMock(\TYPO3\CMS\Core\Cache\CacheManager::class, array(), array(), '', false);
     $mockCache = $this->getMock(\TYPO3Fluid\Fluid\Core\Cache\FluidCacheInterface::class, array(), array(), '', false);
     $this->mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
     GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $this->mockCacheManager);
 }
コード例 #10
0
 /**
  * @test
  */
 public function settingRequestAdminPropertySetsAdminRoleInUserAuthentication()
 {
     $mockedUserAuthentication = $this->getMock(\TYPO3\CMS\Core\Authentication\AbstractUserAuthentication::class);
     $mockedUserAuthentication->user['admin'] = 42;
     $this->commandController->expects($this->once())->method('dummyCommand')->will($this->returnCallback(function () use($mockedUserAuthentication) {
         if ($mockedUserAuthentication->user['admin'] !== 1) {
             throw new \Exception('User role is not admin');
         }
     }));
     $this->commandController->_set('userAuthentication', $mockedUserAuthentication);
     $this->commandController->_set('arguments', array());
     $this->commandController->_set('commandMethodName', 'dummyCommand');
     $this->commandController->_set('requestAdminPermissions', TRUE);
     $this->commandController->_call('callCommandMethod');
     $this->assertSame(42, $mockedUserAuthentication->user['admin']);
 }
コード例 #11
0
 /**
  * @test
  */
 public function baseArgumentDoesNotAffectAbsoluteTime()
 {
     $this->subject->expects($this->never())->method('renderChildren');
     $actualResult = $this->subject->render('@1435784732', 'Y', 1485907200);
     // somewhere in 2017
     $this->assertEquals('2015', $actualResult);
 }
 /**
  * @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', []));
 }
コード例 #13
0
 /**
  * @test
  */
 public function forceAbsoluteUrlReturnsCorrectAbsoluteUrlWithSubfolder()
 {
     // Force hostname and subfolder
     $this->subject->expects($this->any())->method('getEnvironmentVariable')->will($this->returnValueMap(array(array('HTTP_HOST', 'localhost'), array('TYPO3_SITE_PATH', '/subfolder/'))));
     $expected = 'http://localhost/subfolder/fileadmin/my.pdf';
     $url = 'fileadmin/my.pdf';
     $configuration = array('forceAbsoluteUrl' => '1');
     $this->assertEquals($expected, $this->subject->_call('forceAbsoluteUrl', $url, $configuration));
 }
コード例 #14
0
 /**
  * @test
  */
 public function processAjaxRequestUnzipProcessActuallyDoesNotChangeFileData()
 {
     $this->fileController = $this->getAccessibleMock(\TYPO3\CMS\Backend\Controller\File\FileController::class, array('init', 'main'));
     $fileData = array('unzip' => array(true));
     $this->fileController->_set('fileProcessor', $this->mockFileProcessor);
     $this->fileController->_set('fileData', $fileData);
     $this->fileController->_set('redirect', false);
     $this->fileController->expects($this->once())->method('main');
     $this->fileController->processAjaxRequest($this->request, $this->response);
 }
コード例 #15
0
 /**
  * @test
  */
 public function concatenatedJsFileIsFlaggedToNotConcatenateAgain()
 {
     $fileName = 'fooFile.js';
     $concatenatedFileName = 'merged_' . $fileName;
     $testFileFixture = array($fileName => array('file' => $fileName, 'excludeFromConcatenation' => false, 'section' => 'top'));
     $this->subject->expects($this->once())->method('createMergedJsFile')->will($this->returnValue($concatenatedFileName));
     $result = $this->subject->concatenateJsFiles($testFileFixture);
     $this->assertArrayHasKey($concatenatedFileName, $result);
     $this->assertArrayHasKey('excludeFromConcatenation', $result[$concatenatedFileName]);
     $this->assertTrue($result[$concatenatedFileName]['excludeFromConcatenation']);
 }
コード例 #16
0
 /**
  * @test
  * @author Alexander Schnitzler <*****@*****.**>
  */
 public function overrideConfigurationFromPluginOverridesCorrectly()
 {
     /** @var $frontendConfigurationManager \TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager */
     $frontendConfigurationManager = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Configuration\\FrontendConfigurationManager', array('getTypoScriptSetup'));
     $frontendConfigurationManager->_set('contentObject', $this->mockContentObject);
     $frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
     $this->mockTypoScriptService->expects($this->once())->method('convertTypoScriptArrayToPlainArray')->will($this->returnValue(array('persistence' => array('storagePid' => '0,1,2,3'), 'settings' => array('foo' => 'bar'), 'view' => array('foo' => 'bar'))));
     $frontendConfigurationManager->expects($this->any())->method('getTypoScriptSetup')->will($this->returnValue(array('plugin.' => array('tx_ext_pi1.' => array('persistence.' => array('storagePid' => '0,1,2,3'), 'settings.' => array('foo' => 'bar'), 'view.' => array('foo' => 'bar'))))));
     $frameworkConfiguration = array('extensionName' => 'ext', 'pluginName' => 'pi1', 'persistence' => array('storagePid' => '1'), 'settings' => array('foo' => 'qux'), 'view' => array('foo' => 'qux'));
     $this->assertSame(array('extensionName' => 'ext', 'pluginName' => 'pi1', 'persistence' => array('storagePid' => '0,1,2,3'), 'settings' => array('foo' => 'bar'), 'view' => array('foo' => 'bar')), $frontendConfigurationManager->_call('overrideConfigurationFromPlugin', $frameworkConfiguration));
 }
コード例 #17
0
 /**
  * @test
  */
 public function getRecordArrayFetchesTranslationWhenLanguageIdIsSet()
 {
     $pageData = array('uid' => 1, 'title' => 'Original');
     $pageDataTranslated = array('uid' => 1, 'title' => 'Translated', '_PAGES_OVERLAY_UID' => '2');
     $this->subject->expects($this->any())->method('enrichWithRelationFields')->with(2, $pageDataTranslated)->will($this->returnArgument(1));
     $databaseConnectionMock = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class);
     $databaseConnectionMock->expects($this->once())->method('exec_SELECTgetSingleRow')->will($this->returnValue($pageData));
     $this->subject->_set('databaseConnection', $databaseConnectionMock);
     $this->pageContextMock->expects($this->any())->method('getPageOverlay')->will($this->returnValue($pageDataTranslated));
     $this->subject->_set('languageUid', 1);
     $this->assertSame($pageDataTranslated, $this->subject->_call('getRecordArray', 1));
 }
コード例 #18
0
 /**
  * @test
  */
 public function getLayoutPathAndFilenameWalksStringKeysInReversedOrder()
 {
     $this->view->setLayoutRootPaths(array('default' => 'some/Default/Directory', 'specific' => 'specific/Layout', 'verySpecific' => 'evenMore/Specific/Layout'));
     $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
     $this->view->expects($this->at(0))->method('testFileExistence')->with('evenMore/Specific/Layout/Default.html')->will($this->returnValue(FALSE));
     $this->view->expects($this->at(1))->method('testFileExistence')->with('evenMore/Specific/Layout/Default')->will($this->returnValue(FALSE));
     $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Layout/Default.html')->will($this->returnValue(FALSE));
     $this->view->expects($this->at(3))->method('testFileExistence')->with('specific/Layout/Default')->will($this->returnValue(FALSE));
     $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Default.html')->will($this->returnValue(FALSE));
     $this->view->expects($this->at(5))->method('testFileExistence')->with('some/Default/Directory/Default')->will($this->returnValue(TRUE));
     $this->assertEquals('some/Default/Directory/Default', $this->view->_call('getLayoutPathAndFilename'));
 }
コード例 #19
0
 /**
  * @test
  */
 public function cachingOfActionsCanNotBeChanged()
 {
     $configuration = array('extensionName' => 'CurrentExtensionName', 'pluginName' => 'CurrentPluginName', 'switchableControllerActions' => array('Controller1' => array('newAction', 'action1'), 'Controller2' => array('newAction2', 'action4', 'action5')));
     $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
     $this->abstractConfigurationManager->setConfiguration($configuration);
     $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testPluginConfiguration));
     $this->abstractConfigurationManager->expects($this->once())->method('getSwitchableControllerActions')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testSwitchableControllerActions));
     $this->abstractConfigurationManager->expects($this->once())->method('getContextSpecificFrameworkConfiguration')->will($this->returnCallBack(create_function('$a', 'return $a;')));
     $mergedConfiguration = $this->abstractConfigurationManager->getConfiguration();
     $expectedResult = array('Controller1' => array('actions' => array('newAction', 'action1')), 'Controller2' => array('actions' => array('newAction2', 'action4', 'action5'), 'nonCacheableActions' => array('action4')));
     $actualResult = $mergedConfiguration['controllerConfiguration'];
     $this->assertEquals($expectedResult, $actualResult);
 }
コード例 #20
0
 /**
  * @test
  */
 public function setTemplateWalksStringKeysInReversedOrder()
 {
     $this->view->setTemplateRootPaths(array('default' => 'some/Default/Directory', 'specific' => 'specific/Templates', 'verySpecific' => 'evenMore/Specific/Templates'));
     $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
     $this->view->expects($this->at(0))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Templates/Template.html')->will($this->returnValue(false));
     $this->view->expects($this->at(1))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Templates/Template')->will($this->returnValue(false));
     $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'specific/Templates/Template.html')->will($this->returnValue(false));
     $this->view->expects($this->at(3))->method('testFileExistence')->with(PATH_site . 'specific/Templates/Template')->will($this->returnValue(false));
     $this->view->expects($this->at(4))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Template.html')->will($this->returnValue(false));
     $this->view->expects($this->at(5))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Template')->will($this->returnValue(true));
     $this->view->setTemplate('Template');
     $this->assertEquals(PATH_site . 'some/Default/Directory/Template', $this->view->getTemplatePathAndFilename());
 }
コード例 #21
0
 /**
  * @test
  */
 public function getPluginConfigurationRecursivelyMergesExtensionAndPluginConfiguration()
 {
     $testExtensionSettings = array('settings.' => array('foo' => 'bar', 'some.' => array('nested' => 'value')));
     $testExtensionSettingsConverted = array('settings' => array('foo' => 'bar', 'some' => array('nested' => 'value')));
     $testPluginSettings = array('settings.' => array('some.' => array('nested' => 'valueOverridde', 'new' => 'value')));
     $testPluginSettingsConverted = array('settings' => array('some' => array('nested' => 'valueOverridde', 'new' => 'value')));
     $testSetup = array('module.' => array('tx_someextensionname.' => $testExtensionSettings, 'tx_someextensionname_somepluginname.' => $testPluginSettings));
     $this->mockTypoScriptService->expects($this->at(0))->method('convertTypoScriptArrayToPlainArray')->with($testExtensionSettings)->will($this->returnValue($testExtensionSettingsConverted));
     $this->mockTypoScriptService->expects($this->at(1))->method('convertTypoScriptArrayToPlainArray')->with($testPluginSettings)->will($this->returnValue($testPluginSettingsConverted));
     $this->backendConfigurationManager->expects($this->once())->method('getTypoScriptSetup')->will($this->returnValue($testSetup));
     $expectedResult = array('settings' => array('foo' => 'bar', 'some' => array('nested' => 'valueOverridde', 'new' => 'value')));
     $actualResult = $this->backendConfigurationManager->_call('getPluginConfiguration', 'SomeExtensionName', 'SomePluginName');
     $this->assertEquals($expectedResult, $actualResult);
 }
コード例 #22
0
 /**
  * @test
  */
 public function createValidationErrorMessageAddsErrorFlashMessageButNotInSessionInAjaxRequest()
 {
     /** @var $flashMessageServiceMock \TYPO3\CMS\Core\Messaging\FlashMessageService|\PHPUnit_Framework_MockObject_MockObject */
     $flashMessageServiceMock = $this->getMock('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService', $flashMessageServiceMock);
     $flashMessageQueueMock = $this->getMock('TYPO3\\CMS\\Core\\Messaging\\FlashMessageQueue', array(), array(), '', FALSE);
     $flashMessageServiceMock->expects($this->once())->method('getMessageQueueByIdentifier')->will($this->returnValue($flashMessageQueueMock));
     $flashMessageQueueMock->expects($this->once())->method('enqueue')->with($this->isInstanceOf('TYPO3\\CMS\\Core\\Messaging\\FlashMessage'))->will($this->returnCallback(array($this, 'enqueueAjaxFlashMessageCallback')));
     $languageServiceMock = $this->getMock('TYPO3\\CMS\\Lang\\LanguageService', array(), array(), '', FALSE);
     $languageServiceMock->expects($this->once())->method('sL')->will($this->returnValue('foo'));
     $this->subject->expects($this->once())->method('getLanguageService')->will($this->returnValue($languageServiceMock));
     $this->subject->expects($this->any())->method('isAjaxRequest')->will($this->returnValue(TRUE));
     $this->subject->_call('createValidationErrorMessage');
 }
コード例 #23
0
 /**
  * @test
  */
 public function processAjaxRequestUploadProcess()
 {
     $this->fileController = $this->getAccessibleMock('TYPO3\\CMS\\Backend\\Controller\\File\\FileController', array('init', 'main'));
     $this->mockAjaxRequestHandler = $this->getMock('TYPO3\\CMS\\Core\\Http\\AjaxRequestHandler', array('addContent', 'setContentFormat'), array(), '', FALSE);
     $fileData = array('upload' => array(array($this->fileResourceMock)));
     $result = array('upload' => array(array('id' => 'foo', 'date' => '29-11-73', 'iconClasses' => 't3-icon t3-icon-mimetypes t3-icon-mimetypes-text t3-icon-text-html')));
     $this->fileController->_set('fileProcessor', $this->mockFileProcessor);
     $this->fileController->_set('fileData', $fileData);
     $this->fileController->_set('redirect', FALSE);
     $this->fileController->expects($this->once())->method('init');
     $this->fileController->expects($this->once())->method('main');
     $this->mockAjaxRequestHandler->expects($this->once())->method('addContent')->with('result', $result);
     $this->mockAjaxRequestHandler->expects($this->once())->method('setContentFormat')->with('json');
     $this->fileController->processAjaxRequest(array(), $this->mockAjaxRequestHandler);
 }
コード例 #24
0
ファイル: JumpUrlHandlerTest.php プロジェクト: hlop/TYPO3.CMS
 /**
  * @test
  * @dataProvider jumpUrlDefaultValidParametersDataProvider
  * @param string $hash
  * @param string $jumpUrl
  */
 public function jumpUrlDefaultTransfersSession($hash, $jumpUrl)
 {
     $tsConfig['TSFE.']['jumpUrl_transferSession'] = 1;
     /** @var \PHPUnit_Framework_MockObject_MockObject|FrontendUserAuthentication $frontendUserMock */
     $frontendUserMock = $this->getMock(FrontendUserAuthentication::class);
     $frontendUserMock->id = 123;
     $this->tsfe->_set('fe_user', $frontendUserMock);
     $this->tsfe->expects($this->once())->method('getPagesTSconfig')->will($this->returnValue($tsConfig));
     $sessionGetParameter = (strpos($jumpUrl, '?') === false ? '?' : '') . '&FE_SESSION_KEY=123-fc9f825a9af59169895f3bb28267a42f';
     $expectedJumpUrl = $jumpUrl . $sessionGetParameter;
     $this->jumpUrlHandler->expects($this->once())->method('redirect')->with($expectedJumpUrl, HttpUtility::HTTP_STATUS_303);
     $_GET['jumpurl'] = $jumpUrl;
     $_GET['juHash'] = $hash;
     $this->jumpUrlHandler->canHandleCurrentUrl();
     $this->jumpUrlHandler->handle();
 }
コード例 #25
0
 /**
  * @test
  */
 public function getChildrenOfLevelMaximumSetToTwoWorks()
 {
     $expectedStorage = new TreeNodeCollection();
     $expectedFirstLevelTreeNode = new TreeNode();
     $expectedFirstLevelTreeNode->setId(1);
     $expectedSecondLevelTreeNode = new TreeNode();
     $expectedSecondLevelTreeNode->setId(2);
     $expectedStorageOfSecondLevelChildren = new TreeNodeCollection();
     $expectedStorageOfSecondLevelChildren->append($expectedSecondLevelTreeNode);
     $expectedFirstLevelTreeNode->setChildNodes($expectedStorageOfSecondLevelChildren);
     $expectedStorage->append($expectedFirstLevelTreeNode);
     $this->initializeSubjectMock(array('getRelatedRecords', 'getRootUid'));
     $this->subject->_set('levelMaximum', 2);
     $this->subject->expects($this->at(0))->method('getRelatedRecords')->will($this->returnValue(array(1)));
     $this->subject->expects($this->at(1))->method('getRelatedRecords')->will($this->returnValue(array(2)));
     $storage = $this->subject->_call('getChildrenOf', $this->treeData, 1);
     $this->assertEquals($expectedStorage, $storage);
 }
コード例 #26
0
 /**
  * Make sure the hook in get sourceCollection is called
  *
  * @test
  */
 public function getImageSourceCollectionHookCalled()
 {
     $this->cObj = $this->getAccessibleMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', array('getResourceFactory', 'stdWrap', 'getImgResource'));
     $this->cObj->start(array(), 'tt_content');
     // Avoid calling stdwrap and getImgResource
     $this->cObj->expects($this->any())->method('stdWrap')->will($this->returnArgument(0));
     $this->cObj->expects($this->any())->method('getImgResource')->will($this->returnValue(array(100, 100, NULL, 'bar-file.jpg')));
     $resourceFactory = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', array(), array(), '', FALSE);
     $this->cObj->expects($this->any())->method('getResourceFactory')->will($this->returnValue($resourceFactory));
     $className = uniqid('tx_coretest_getImageSourceCollectionHookCalled');
     $getImageSourceCollectionHookMock = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectOneSourceCollectionHookInterface', array('getOneSourceCollection'), array(), $className);
     $GLOBALS['T3_VAR']['getUserObj'][$className] = $getImageSourceCollectionHookMock;
     $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImageSourceCollection'][] = $className;
     $getImageSourceCollectionHookMock->expects($this->exactly(1))->method('getOneSourceCollection')->will($this->returnCallback(array($this, 'isGetOneSourceCollectionCalledCallback')));
     $configuration = array('layoutKey' => 'data', 'layout.' => array('data.' => array('element' => '<img src="###SRC###" ###SOURCECOLLECTION### ###PARAMS### ###ALTPARAMS######SELFCLOSINGTAGSLASH###>', 'source' => 'data-###DATAKEY###="###SRC###"')), 'sourceCollection.' => array('small.' => array('width' => '200', 'srcsetCandidate' => '600w', 'mediaQuery' => '(max-device-width: 600px)', 'dataKey' => 'small')));
     $result = $this->cObj->getImageSourceCollection('data', $configuration, uniqid('testImage-'));
     $this->assertSame($result, 'isGetOneSourceCollectionCalledCallback');
 }
コード例 #27
0
 /**
  * @test
  */
 public function renderCallsInitializeStandaloneViewInstance()
 {
     $this->addMockViewToSubject();
     $this->subject->expects($this->once())->method('initializeStandaloneViewInstance');
     $this->subject->render(array());
 }
コード例 #28
0
 /**
  * @test
  */
 public function registerTagAttributeRegistersArgumentWithNullIfNoDefaultValueIsSet()
 {
     $this->viewHelper = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\AbstractTagBasedViewHelper', array('registerArgument'), array(), '', FALSE);
     $this->viewHelper->expects($this->once())->method('registerArgument')->with('foo', 'string', 'Description', FALSE, NULL);
     $this->viewHelper->_call('registerTagAttribute', 'foo', 'string', 'Description', FALSE);
 }
コード例 #29
0
 /**
  * @test
  */
 public function NoNewsFoundConfigurationCallsPageNotFoundHandler()
 {
     $mock = $this->getAccessibleMock('Tx_MooxNews_Controller_NewsBaseController', array('dummy'));
     $this->tsfe->expects($this->once())->method('pageNotFoundAndExit');
     $mock->_call('handleNoNewsFoundError', 'pageNotFoundHandler');
 }
コード例 #30
0
 /**
  * @test
  */
 public function uninstallCallsUnloadExtension()
 {
     $this->installMock->expects($this->once())->method('unloadExtension');
     $this->installMock->uninstall($this->extensionKey);
 }