コード例 #1
0
 /**
  * @test
  */
 public function createEntryFromRawDataSetsLinkIfPathIsGivenInEntryObject()
 {
     $rawModule = array('path' => 'pathTest');
     /** @var $entry \TYPO3\CMS\Backend\Domain\Model\Module\BackendModule */
     $entry = $this->moduleController->_call('createEntryFromRawData', $rawModule);
     $this->assertEquals('pathTest', $entry->getLink());
 }
コード例 #2
0
 /**
  * @test
  * @return void
  */
 public function previousNeighbourCanBeFound()
 {
     $this->news->_setProperty('uid', 106);
     $fo = $this->mockedViewHelper->_call('getNeighbours', $this->news, '', 'datetime');
     $exp = [0 => ['uid' => 105, 'title' => NULL], 1 => ['uid' => 106, 'title' => NULL]];
     $this->assertEquals($exp, $fo);
 }
コード例 #3
0
 /**
  * @test
  * @deprecated since 6.2. Test can be removed if injectInstallTool method is dropped
  */
 public function createValidationErrorMessageAddsErrorMessage()
 {
     $installTool = $this->getMock('stdClass', array('addErrorMessage'), array(), '', FALSE);
     $installTool->expects($this->once())->method('addErrorMessage')->with('Validating the security token of this form has failed. ' . 'Please reload the form and submit it again.');
     $this->fixture->injectInstallTool($installTool);
     $this->fixture->_call('createValidationErrorMessage');
 }
コード例 #4
0
 /**
  * @test
  */
 public function flattenResultDataValueFlattensFileAndFolderResourcesButReturnsAnythingElseAsIs()
 {
     $this->fileController = $this->getAccessibleMock('TYPO3\\CMS\\Backend\\Controller\\File\\FileController', array('dummy'));
     $this->folderResourceMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('bar'));
     $this->mockFileProcessor->expects($this->any())->method('getErrorMessages')->will($this->returnValue(array()));
     $this->assertTrue($this->fileController->_call('flattenResultDataValue', TRUE));
     $this->assertSame(array(), $this->fileController->_call('flattenResultDataValue', array()));
     $this->assertSame(array('id' => 'foo', 'date' => '29-11-73', 'iconClasses' => 't3-icon t3-icon-mimetypes t3-icon-mimetypes-text t3-icon-text-html'), $this->fileController->_call('flattenResultDataValue', $this->fileResourceMock));
     $this->assertSame('bar', $this->fileController->_call('flattenResultDataValue', $this->folderResourceMock));
 }
コード例 #5
0
 /**
  * @test
  */
 public function tokenFromSessionDataIsAvailableForValidateToken()
 {
     $sessionToken = '881ffea2159ac72182557b79dc0c723f5a8d20136f9fab56cdd4f8b3a1dbcfcd';
     $formName = 'foo';
     $action = 'edit';
     $formInstanceName = '42';
     $tokenId = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac($formName . $action . $formInstanceName . $sessionToken);
     $_SESSION['installToolFormToken'] = $sessionToken;
     $this->subject->_call('retrieveSessionToken');
     $this->assertTrue($this->subject->validateToken($tokenId, $formName, $action, $formInstanceName));
 }
コード例 #6
0
 /**
  * @param array $requestArguments
  * @param array $expectedConfiguration
  * @param string $pid
  * @test
  * @dataProvider configurationDataProvider
  */
 public function configurationIsGeneratedCorrectlyFromRequest(array $requestArguments, array $expectedConfiguration, $pid = '42')
 {
     $tsfeMock = $this->getMock('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(), array(), '', FALSE);
     $tsfeMock->id = 42;
     $tsfeMock->page = array('pid' => $pid);
     $contextFixture = new RenderingContext($tsfeMock);
     $requestFixture = new Request($requestArguments);
     // This tests if the provided data makes sense
     $this->assertTrue($this->renderer->canRender($requestFixture));
     // Actual test
     $this->assertSame($expectedConfiguration, $this->renderer->_call('resolveRenderingConfiguration', new Request($requestArguments), $contextFixture));
 }
コード例 #7
0
 /**
  * @test
  */
 public function flattenResultDataValueFlattensFileAndFolderResourcesButReturnsAnythingElseAsIs()
 {
     $this->fileController = $this->getAccessibleMock(\TYPO3\CMS\Backend\Controller\File\FileController::class, array('dummy'));
     $this->folderResourceMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('bar'));
     $this->mockFileProcessor->expects($this->any())->method('getErrorMessages')->will($this->returnValue(array()));
     $this->assertTrue($this->fileController->_call('flattenResultDataValue', true));
     $this->assertSame(array(), $this->fileController->_call('flattenResultDataValue', array()));
     $result = $this->fileController->_call('flattenResultDataValue', $this->fileResourceMock);
     $this->assertContains('<span class="t3js-icon icon icon-size-small icon-state-default icon-mimetypes-text-html" data-identifier="mimetypes-text-html">', $result['icon']);
     unset($result['icon']);
     $this->assertSame(array('id' => 'foo', 'date' => '29-11-73', 'thumbUrl' => ''), $result);
     $this->assertSame('bar', $this->fileController->_call('flattenResultDataValue', $this->folderResourceMock));
 }
コード例 #8
0
 /**
  * @param array $requestArguments
  * @param array $expectedConfiguration
  * @param string $pageId
  * @test
  * @dataProvider configurationDataProvider
  */
 public function configurationIsGeneratedCorrectlyFromRequest(array $requestArguments, array $expectedConfiguration, $pageId = '42')
 {
     $tsfeMock = $this->getMock('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(), array(), '', FALSE);
     $pageRepositoryMock = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
     $pageRepositoryMock->expects($this->any())->method('getRootLine')->willReturn(array(array('uid' => '1', 'pid' => '0')));
     $tsfeMock->id = $pageId;
     $tsfeMock->sys_page = $pageRepositoryMock;
     $contextFixture = new RenderingContext($tsfeMock);
     $requestFixture = new Request($requestArguments);
     // This tests if the provided data makes sense
     $this->assertTrue($this->renderer->canRender($requestFixture));
     // Actual test
     $this->assertSame($expectedConfiguration, $this->renderer->_call('resolveRenderingConfiguration', new Request($requestArguments), $contextFixture));
 }
コード例 #9
0
 /**
  * @param string $value
  * @param string $expectedValue
  *
  * @dataProvider checkValue_checkReturnsExpectedValuesDataProvider
  * @test
  */
 public function checkValue_checkReturnsExpectedValues($value, $expectedValue)
 {
     $expectedResult = array('value' => $expectedValue);
     $result = array();
     $tcaFieldConfiguration = array('items' => array(array('Item 1', 0), array('Item 2', 0), array('Item 3', 0)));
     $this->assertSame($expectedResult, $this->subject->_call('checkValueForCheck', $result, $value, $tcaFieldConfiguration, '', 0, 0, ''));
 }
コード例 #10
0
 /**
  * @test
  * @dataProvider getShouldFieldBeOverlaidData
  */
 public function shouldFieldBeOverlaid($field, $table, $value, $expected, $comment = '')
 {
     $GLOBALS['TCA']['fake_table']['columns'] = array('exclude' => array('l10n_mode' => 'exclude', 'config' => array('type' => 'input')), 'mergeIfNotBlank' => array('l10n_mode' => 'mergeIfNotBlank', 'config' => array('type' => 'input')), 'mergeIfNotBlank_group' => array('l10n_mode' => 'mergeIfNotBlank', 'config' => array('type' => 'group')), 'default' => array('config' => array('type' => 'input')), 'noCopy' => array('l10n_mode' => 'noCopy', 'config' => array('type' => 'input')), 'prefixLangTitle' => array('l10n_mode' => 'prefixLangTitle', 'config' => array('type' => 'input')));
     $result = $this->pageSelectObject->_call('shouldFieldBeOverlaid', $table, $field, $value);
     unset($GLOBALS['TCA']['fake_table']);
     $this->assertSame($expected, $result, $comment);
 }
コード例 #11
0
 /**
  * @test
  */
 public function getContextSpecificFrameworkConfigurationSetsDefaultRequestHandlersIfRequestHandlersAreNotConfigured()
 {
     $frameworkConfiguration = array('pluginName' => 'Pi1', 'extensionName' => 'SomeExtension', 'foo' => array('bar' => array('baz' => 'Foo')));
     $expectedResult = array('pluginName' => 'Pi1', 'extensionName' => 'SomeExtension', 'foo' => array('bar' => array('baz' => 'Foo')), 'mvc' => array('requestHandlers' => array(\TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler::class => \TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler::class, \TYPO3\CMS\Extbase\Mvc\Web\BackendRequestHandler::class => \TYPO3\CMS\Extbase\Mvc\Web\BackendRequestHandler::class)));
     $actualResult = $this->backendConfigurationManager->_call('getContextSpecificFrameworkConfiguration', $frameworkConfiguration);
     $this->assertEquals($expectedResult, $actualResult);
 }
コード例 #12
0
 /**
  * @test
  * @return void
  */
 public function getOverrideDemandSettingsAddsValueIfFilled()
 {
     $flexform = [];
     $this->addContentToFlexform($flexform, 'settings.disableOverrideDemand', '1', 'additional');
     $this->pageLayoutView->_set('flexformData', $flexform);
     $this->pageLayoutView->_call('getOverrideDemandSettings');
     $this->assertEquals(count($this->pageLayoutView->_get('tableData')), 1);
 }
コード例 #13
0
 /**
  * @test
  */
 public function initializeBasicErrorReportingExcludesDeprecated()
 {
     $backupReporting = error_reporting();
     $this->fixture->_call('initializeBasicErrorReporting');
     $actualReporting = error_reporting();
     error_reporting($backupReporting);
     $this->assertEquals(0, $actualReporting & E_DEPRECATED);
 }
コード例 #14
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));
 }
コード例 #15
0
 /**
  * @test
  */
 public function getAllMessagesAndFlushClearsSessionStack()
 {
     $flashMessage = new \TYPO3\CMS\Core\Messaging\FlashMessage('Transient', 'Title', \TYPO3\CMS\Core\Messaging\FlashMessage::OK, true);
     $this->flashMessageQueue->enqueue($flashMessage);
     $this->flashMessageQueue->getAllMessagesAndFlush();
     /** @var $frontendUser \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication */
     $frontendUser = $this->flashMessageQueue->_call('getUserByContext');
     $this->assertNull($frontendUser->getSessionData('core.template.flashMessages'));
 }
コード例 #16
0
 /**
  * @test
  */
 public function processRedirectReferrerDomainsMatchesDomains()
 {
     $conf = array('redirectMode' => 'refererDomains', 'domains' => 'example.com');
     $this->accessibleFixture->_set('conf', $conf);
     $this->accessibleFixture->_set('logintype', 'login');
     $this->accessibleFixture->_set('referer', 'http://www.example.com/snafu');
     $GLOBALS['TSFE']->loginUser = TRUE;
     $this->assertSame(array('http://www.example.com/snafu'), $this->accessibleFixture->_call('processRedirect'));
 }
コード例 #17
0
 /**
  * @test
  */
 public function convertDomainObjectsToIdentityArraysConvertsDomainObjects()
 {
     $mockDomainObject1 = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity', array('dummy'));
     $mockDomainObject1->_set('uid', '123');
     $mockDomainObject2 = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity', array('dummy'));
     $mockDomainObject2->_set('uid', '321');
     $expectedResult = array('foo' => array('bar' => 'baz'), 'domainObject1' => '123', 'second' => array('domainObject2' => '321'));
     $actualResult = $this->uriBuilder->_call('convertDomainObjectsToIdentityArrays', array('foo' => array('bar' => 'baz'), 'domainObject1' => $mockDomainObject1, 'second' => array('domainObject2' => $mockDomainObject2)));
     $this->assertEquals($expectedResult, $actualResult);
 }
コード例 #18
0
 /**
  *
  * @test
  * @return void
  */
 public function mergeWithExistingConfigurationOverwritesDefaultKeysWithCurrent()
 {
     $configurationManagerMock = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
     $configurationManagerMock->expects($this->once())->method('getConfigurationValueByPath')->with('EXT/extConf/testextensionkey')->will($this->returnValue(serialize(array('FE.' => array('enabled' => '1', 'saltedPWHashingMethod' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\SaltInterface_sha1'), 'CLI.' => array('enabled' => '0')))));
     $this->configurationItemRepository->injectConfigurationManager($configurationManagerMock);
     $defaultConfiguration = array('FE.enabled' => array('value' => '0'), 'FE.saltedPWHashingMethod' => array('value' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\Md5Salt'), 'BE.enabled' => array('value' => '1'), 'BE.saltedPWHashingMethod' => array('value' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\Md5Salt'));
     $expectedResult = array('FE.enabled' => array('value' => '1'), 'FE.saltedPWHashingMethod' => array('value' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\SaltInterface_sha1'), 'BE.enabled' => array('value' => '1'), 'BE.saltedPWHashingMethod' => array('value' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\Md5Salt'), 'CLI.enabled' => array('value' => '0'));
     $result = $this->configurationItemRepository->_call('mergeWithExistingConfiguration', $defaultConfiguration, array('key' => 'testextensionkey'));
     $this->assertEquals($expectedResult, $result);
 }
コード例 #19
0
 /**
  * @test
  */
 public function overrideConfigurationFromFlexFormChecksForDataIsArrayAndEmpty()
 {
     /** @var $flexFormService \TYPO3\CMS\Extbase\Service\FlexFormService|\PHPUnit_Framework_MockObject_MockObject */
     $flexFormService = $this->getMock('TYPO3\\CMS\\Extbase\\Service\\FlexFormService', array('convertFlexFormContentToArray'));
     $flexFormService->expects($this->never())->method('convertFlexFormContentToArray');
     $this->frontendConfigurationManager->_set('flexFormService', $flexFormService);
     $this->mockContentObject->data = array('pi_flexform' => array());
     $frameworkConfiguration = array('persistence' => array('storagePid' => '98'));
     $this->assertSame(array('persistence' => array('storagePid' => '98')), $this->frontendConfigurationManager->_call('overrideConfigurationFromFlexForm', $frameworkConfiguration));
 }
コード例 #20
0
 /**
  * @param string $currentDomain
  * @test
  * @dataProvider getSysDomainCacheDataProvider
  */
 public function getSysDomainCacheReturnsForcedDomainRecord($currentDomain)
 {
     $_SERVER['HTTP_HOST'] = $currentDomain;
     $domainRecords = array('typo3.org' => array('uid' => '1', 'pid' => '1', 'domainName' => 'typo3.org', 'forced' => 0), 'foo.bar' => array('uid' => '2', 'pid' => '1', 'domainName' => 'foo.bar', 'forced' => 1), 'example.com' => array('uid' => '3', 'pid' => '1', 'domainName' => 'example.com', 'forced' => 0));
     $GLOBALS['TYPO3_DB'] = $this->getMock(DatabaseConnection::class, array('exec_SELECTgetRows'));
     $GLOBALS['TYPO3_DB']->expects($this->any())->method('exec_SELECTgetRows')->willReturn($domainRecords);
     GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_runtime')->flush();
     $expectedResult = array($domainRecords[$currentDomain]['pid'] => $domainRecords['foo.bar']);
     $this->assertEquals($expectedResult, $this->subject->_call('getSysDomainCache'));
 }
コード例 #21
0
 /**
  * @test
  */
 public function processRedirectReferrerDomainsMatchesDomains()
 {
     $conf = array('redirectMode' => 'refererDomains', 'domains' => 'example.com');
     $this->accessibleFixture->_set('conf', $conf);
     $this->accessibleFixture->_set('logintype', 'login');
     $this->accessibleFixture->_set('referer', 'http://www.example.com/snafu');
     /** @var TypoScriptFrontendController $tsfe */
     $tsfe = $this->accessibleFixture->_get('frontendController');
     $tsfe->loginUser = TRUE;
     $this->assertSame(array('http://www.example.com/snafu'), $this->accessibleFixture->_call('processRedirect'));
 }
コード例 #22
0
 /**
  * Tests optimizing a CSS asset group.
  *
  * @test
  * @dataProvider compressCssFileContentDataProvider
  * @param string $cssFile
  * @param string $expected
  */
 public function compressCssFileContent($cssFile, $expected)
 {
     $cssContent = file_get_contents($cssFile);
     $compressedCss = $this->subject->_call('compressCssString', $cssContent);
     // we have to fix relative paths, if we aren't working on a file in our target directory
     $relativeFilename = str_replace(PATH_site, '', $cssFile);
     if (strpos($relativeFilename, $this->subject->_get('targetDirectory')) === false) {
         $compressedCss = $this->subject->_call('cssFixRelativeUrlPaths', $compressedCss, dirname($relativeFilename) . '/');
     }
     $this->assertEquals(file_get_contents($expected), $compressedCss, 'Group of file CSS assets optimized correctly.');
 }
コード例 #23
0
 /**
  * @test
  * @return void
  */
 public function mergeWithExistingConfigurationOverwritesDefaultKeysWithCurrent()
 {
     $localConfiguration = serialize(array('FE.' => array('enabled' => '1', 'saltedPWHashingMethod' => \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface_sha1::class), 'CLI.' => array('enabled' => '0')));
     $configurationManagerMock = $this->getMock(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
     $configurationManagerMock->expects($this->once())->method('getConfigurationValueByPath')->with('EXT/extConf/testextensionkey')->will($this->returnValue($localConfiguration));
     $this->injectedObjectManagerMock->expects($this->any())->method('get')->will($this->returnValue($configurationManagerMock));
     $defaultConfiguration = array('FE.enabled' => array('value' => '0'), 'FE.saltedPWHashingMethod' => array('value' => \TYPO3\CMS\Saltedpasswords\Salt\Md5Salt::class), 'BE.enabled' => array('value' => '1'), 'BE.saltedPWHashingMethod' => array('value' => \TYPO3\CMS\Saltedpasswords\Salt\Md5Salt::class));
     $expectedResult = array('FE.enabled' => array('value' => '1'), 'FE.saltedPWHashingMethod' => array('value' => \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface_sha1::class), 'BE.enabled' => array('value' => '1'), 'BE.saltedPWHashingMethod' => array('value' => \TYPO3\CMS\Saltedpasswords\Salt\Md5Salt::class), 'CLI.enabled' => array('value' => '0'));
     $actualResult = $this->configurationItemRepository->_call('mergeWithExistingConfiguration', $defaultConfiguration, 'testextensionkey');
     $this->assertEquals($expectedResult, $actualResult);
 }
コード例 #24
0
 /**
  * @test
  * @see http://forge.typo3.org/issues/21902
  */
 public function locateStatementWithExternalTableIsProperlyRemapped()
 {
     $selectFields = '*, CASE WHEN' . ' LOCATE(' . $this->subject->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', tx_templavoila_tmplobj.datastructure, 4)>0 THEN 2' . ' ELSE 1' . ' END AS scope';
     $fromTables = 'tx_templavoila_tmplobj';
     $whereClause = '1=1';
     $groupBy = '';
     $orderBy = '';
     $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
     $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
     $expected = 'SELECT *, CASE WHEN CHARINDEX(\'(fce)\', "tx_templavoila_tmplobj"."ds", 4) > 0 THEN 2 ELSE 1 END AS "scope" FROM "tx_templavoila_tmplobj" WHERE 1 = 1';
     $this->assertEquals($expected, $this->cleanSql($result));
 }
コード例 #25
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(PATH_site . 'evenMore/Specific/Layout/Default.html')->will($this->returnValue(false));
     $this->view->expects($this->at(1))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Layout/Default')->will($this->returnValue(false));
     $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'specific/Layout/Default.html')->will($this->returnValue(false));
     $this->view->expects($this->at(3))->method('testFileExistence')->with(PATH_site . 'specific/Layout/Default')->will($this->returnValue(false));
     $this->view->expects($this->at(4))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Default.html')->will($this->returnValue(false));
     $this->view->expects($this->at(5))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Default')->will($this->returnValue(true));
     $this->assertEquals(PATH_site . 'some/Default/Directory/Default', $this->view->_call('getLayoutPathAndFilename'));
 }
コード例 #26
0
 /**
  * @test
  * @see http://forge.typo3.org/issues/23087
  */
 public function findInSetFieldIsProperlyRemapped()
 {
     $selectFields = 'fe_group';
     $fromTables = 'tt_news';
     $whereClause = 'FIND_IN_SET(10, fe_group)';
     $groupBy = '';
     $orderBy = '';
     $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
     $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
     $expected = 'SELECT "usergroup" FROM "ext_tt_news" WHERE \',\'||"ext_tt_news"."usergroup"||\',\' LIKE \'%,10,%\'';
     $this->assertEquals($expected, $this->cleanSql($result));
 }
コード例 #27
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));
 }
コード例 #28
0
 /**
  * @test
  * @param string $linkParameter
  * @param string $expectedResult
  * @dataProvider detectLinkTypeFromLinkParameterDataProvider
  */
 public function detectLinkTypeFromLinkParameter($linkParameter, $expectedResult)
 {
     /** @var TemplateService|\PHPUnit_Framework_MockObject_MockObject $templateServiceObjectMock */
     $templateServiceObjectMock = $this->getMock(TemplateService::class, array('dummy'));
     $templateServiceObjectMock->setup = array('lib.' => array('parseFunc.' => $this->getLibParseFunc()));
     /** @var TypoScriptFrontendController|\PHPUnit_Framework_MockObject_MockObject $typoScriptFrontendControllerMockObject */
     $typoScriptFrontendControllerMockObject = $this->getMock(TypoScriptFrontendController::class, array(), array(), '', false);
     $typoScriptFrontendControllerMockObject->config = array('config' => array(), 'mainScript' => 'index.php');
     $typoScriptFrontendControllerMockObject->tmpl = $templateServiceObjectMock;
     $GLOBALS['TSFE'] = $typoScriptFrontendControllerMockObject;
     $this->subject->_set('typoScriptFrontendController', $typoScriptFrontendControllerMockObject);
     $this->assertEquals($expectedResult, $this->subject->_call('detectLinkTypeFromLinkParameter', $linkParameter));
 }
コード例 #29
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');
 }
コード例 #30
0
 /**
  * @test
  */
 public function prepareObjectsSliceReturnsCorrectPortionForArrayAndSecondPage()
 {
     $this->controller->_set('currentPage', 2);
     $objects = array();
     for ($i = 0; $i <= 55; $i++) {
         $item = new \stdClass();
         $objects[] = $item;
     }
     $this->controller->_set('objects', $objects);
     $expectedPortion = array();
     for ($j = 10; $j <= 19; $j++) {
         $expectedPortion = array_slice($objects, 10, 10);
     }
     $this->assertSame($expectedPortion, $this->controller->_call('prepareObjectsSlice', 10, 10));
 }