/**
  * @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();
 }
 /**
  * @test
  */
 public function persistSessionTokenWritesTokensToSession()
 {
     $_SESSION['installToolFormToken'] = 'foo';
     $this->subject->_set('sessionToken', '881ffea2159ac72182557b79dc0c723f5a8d20136f9fab56cdd4f8b3a1dbcfcd');
     $this->subject->persistSessionToken();
     $this->assertEquals('881ffea2159ac72182557b79dc0c723f5a8d20136f9fab56cdd4f8b3a1dbcfcd', $_SESSION['installToolFormToken']);
 }
 /**
  * @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);
 }
 /**
  * @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());
 }
 /**
  * @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');
 }
 /**
  * Test for render()
  *
  * @param string $validation
  * @param string $expectedResult
  * @param bool $nativeValidationEnabled
  * @return void
  * @dataProvider renderReturnsStringDataProvider
  * @test
  */
 public function renderReturnsString($validation, $expectedResult, $nativeValidationEnabled)
 {
     $this->abstractValidationViewHelperMock->_set('settings', ['validation' => ['native' => $nativeValidationEnabled ? '1' : '0']]);
     $field = new Field();
     $field->setValidation($validation);
     $result = $this->abstractValidationViewHelperMock->_callRef('render', $field);
     $this->assertSame($expectedResult, $result);
 }
 /**
  * @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);
 }
 /**
  * @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();
 }
 /**
  * Test for render()
  *
  * @param array $settings
  * @param array $additionalAttributes
  * @param array $expectedResult
  * @return void
  * @dataProvider renderReturnsArrayDataProvider
  * @test
  */
 public function renderReturnsArray($settings, $additionalAttributes, $expectedResult)
 {
     $form = new Form();
     $form->_setProperty('uid', 123);
     $this->enableParsleyAndAjaxViewHelperMock->_set('addRedirectUri', false);
     $this->enableParsleyAndAjaxViewHelperMock->_set('settings', $settings);
     $result = $this->enableParsleyAndAjaxViewHelperMock->_callRef('render', $form, $additionalAttributes);
     $this->assertSame($expectedResult, $result);
 }
 /**
  * @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));
 }
 /**
  * @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));
 }
Esempio n. 12
0
 /**
  * @test
  * @expectedException \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotException
  */
 public function dispatchThrowsInvalidSlotExceptionIfObjectManagerOfSignalSlotDispatcherIsNotSet()
 {
     $this->signalSlotDispatcher->_set('isInitialized', true);
     $this->signalSlotDispatcher->_set('objectManager', null);
     $this->signalSlotDispatcher->_set('slots', array('ClassA' => array('emitSomeSignal' => array(array()))));
     $this->assertSame(null, $this->signalSlotDispatcher->dispatch('ClassA', 'emitSomeSignal'));
 }
 /**
  * @test
  */
 public function multipleExpressiosInWhereClauseAreBracedCorrectly()
 {
     $listMaxExpressions = 1000;
     $mockSpecificsOci8 = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\Specifics\\Oci8', array(), array(), '', FALSE);
     $mockSpecificsOci8->expects($this->any())->method('getSpecific')->will($this->returnValue($listMaxExpressions));
     $INitems = range(0, 1250);
     $NOTINItems = range(0, 1001);
     $where = 'uid = 1981 AND uid IN(' . implode(',', $INitems) . ') OR uid = 42 AND uid NOT IN(' . implode(',', $NOTINItems) . ')';
     $result = $this->subject->SELECTquery('uid, pid', 'tt_content', $where);
     $chunks = array_chunk($INitems, $listMaxExpressions);
     $INItemsWhereExpr = array();
     foreach ($chunks as $chunk) {
         $INItemsWhereExpr[] = '"uid" IN (' . implode(',', $chunk) . ')';
     }
     $chunks = array_chunk($NOTINItems, $listMaxExpressions);
     $NOTINItemsWhereExpr = array();
     foreach ($chunks as $chunk) {
         $NOTINItemsWhereExpr[] = '"uid" NOT IN (' . implode(',', $chunk) . ')';
     }
     /**
      * $expectedWhere:
      * "uid" = 1981 AND (
      *        "uid" IN (1,2,3,4,...,1000)
      *     OR "uid" IN (1001,1002,...,1250)
      * ) OR "uid" = 42 AND (
      *        "uid" NOT IN (1,2,3,4,...,1000)
      *    AND "uid" NOT IN (1001)
      * )
      */
     $expectedWhere = '"uid" = 1981 AND (' . implode(' OR ', $INItemsWhereExpr) . ') OR "uid" = 42 AND (' . implode(' AND ', $NOTINItemsWhereExpr) . ')';
     $expectedQuery = 'SELECT "uid", "pid" FROM "tt_content" WHERE ' . $expectedWhere;
     $this->assertEquals($expectedQuery, $this->cleanSql($result));
 }
 /**
  * Test for isClientValidationEnabled()
  *
  * @param array $settings
  * @param bool $expectedNativeResult
  * @param bool $expectedClientResult
  * @return void
  * @dataProvider isValidationEnabledReturnsBoolDataProvider
  * @test
  */
 public function isClientValidationEnabledReturnsBool($settings, $expectedNativeResult, $expectedClientResult)
 {
     unset($expectedNativeResult);
     $this->abstractValidationViewHelperMock->_set('settings', $settings);
     $result = $this->abstractValidationViewHelperMock->_callRef('isClientValidationEnabled');
     $this->assertSame($expectedClientResult, $result);
 }
Esempio n. 15
0
 /**
  * Test for render()
  *
  * @param array $settings
  * @param array $fieldProperties
  * @param array $additionalAttributes
  * @param mixed $iteration
  * @param array $expectedResult
  * @return void
  * @dataProvider renderReturnsArrayDataProvider
  * @test
  */
 public function renderReturnsArray($settings, $fieldProperties, $additionalAttributes, $iteration, $expectedResult)
 {
     $field = new Field();
     foreach ($fieldProperties as $propertyName => $propertyValue) {
         $field->_setProperty($propertyName, $propertyValue);
     }
     $this->abstractValidationViewHelperMock->_set('settings', $settings);
     $this->abstractValidationViewHelperMock->_set('extensionName', 'powermail');
     $controllerContext = new ControllerContext();
     $request = new Request();
     $request->setControllerExtensionName('powermail');
     $controllerContext->setRequest($request);
     $this->abstractValidationViewHelperMock->_set('controllerContext', $controllerContext);
     $result = $this->abstractValidationViewHelperMock->_callRef('render', $field, $additionalAttributes, $iteration);
     $this->assertSame($expectedResult, $result);
 }
Esempio n. 16
0
 /**
  * @test
  * @expectedException \RuntimeException
  */
 public function updateRootlineDataWithInvalidNewRootlineThrowsException()
 {
     $originalRootline = array(0 => array('uid' => 2, 'title' => 'originalTitle'), 1 => array('uid' => 3, 'title' => 'originalTitle2'));
     $newInvalidRootline = array(0 => array('uid' => 1, 'title' => 'newTitle'), 1 => array('uid' => 2, 'title' => 'newTitle2'));
     $this->templateServiceMock->_set('rootLine', $originalRootline);
     $this->templateServiceMock->updateRootlineData($newInvalidRootline);
 }
Esempio n. 17
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, ''));
 }
Esempio n. 18
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']);
 }
 /**
  * @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);
 }
Esempio n. 20
0
 /**
  * @test
  */
 public function getAdditionalInformationRespectsArguments()
 {
     $this->task->_set('commandIdentifier', 'foo');
     $this->task->_set('defaults', array('bar' => 'baz'));
     $this->task->_set('arguments', array('qux' => 'quux'));
     $this->assertSame('foo qux=quux', $this->task->getAdditionalInformation());
 }
 /**
  * @test
  */
 public function initializeBasicErrorReportingExcludesDeprecated()
 {
     $backupReporting = error_reporting();
     $this->fixture->_call('initializeBasicErrorReporting');
     $actualReporting = error_reporting();
     error_reporting($backupReporting);
     $this->assertEquals(0, $actualReporting & E_DEPRECATED);
 }
 /**
  * @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);
 }
Esempio n. 23
0
 /**
  * @test
  * @author Robert Lemke <*****@*****.**>
  */
 public function booleanOptionsCanHaveOnlyCertainValuesIfTheValueIsAssignedWithoutEqualSign()
 {
     $methodParameters = array('b1' => array('optional' => TRUE, 'type' => 'boolean'), 'b2' => array('optional' => TRUE, 'type' => 'boolean'), 'b3' => array('optional' => TRUE, 'type' => 'boolean'), 'b4' => array('optional' => TRUE, 'type' => 'boolean'), 'b5' => array('optional' => TRUE, 'type' => 'boolean'), 'b6' => array('optional' => TRUE, 'type' => 'boolean'));
     $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
     $expectedArguments = array('b1' => TRUE, 'b2' => TRUE, 'b3' => TRUE, 'b4' => FALSE, 'b5' => FALSE, 'b6' => FALSE);
     $request = $this->requestBuilder->build('some_extension_name:default:list --b2 y --b1 1 --b3 true --b4 false --b5 n --b6 0');
     $this->assertEquals($expectedArguments, $request->getArguments());
 }
 /**
  * @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);
 }
Esempio n. 25
0
 /**
  * @test
  */
 public function magicCallMethodReturnsNullInFindOneBySomethingIfQueryReturnsEmptyRawResult()
 {
     $queryResultArray = array();
     $this->mockQuery->expects($this->once())->method('equals')->with('foo', 'bar')->will($this->returnValue('matchCriteria'));
     $this->mockQuery->expects($this->once())->method('matching')->with('matchCriteria')->will($this->returnValue($this->mockQuery));
     $this->mockQuery->expects($this->once())->method('setLimit')->with(1)->will($this->returnValue($this->mockQuery));
     $this->mockQuery->expects($this->once())->method('execute')->will($this->returnValue($queryResultArray));
     $this->assertNull($this->repository->findOneByFoo('bar'));
 }
 /**
  * @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 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'));
 }
Esempio n. 28
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);
 }
Esempio n. 29
0
 /**
  * @test
  */
 public function buildSetsDefaultActionNameIfSpecifiedActionIsNotAllowedAndCallDefaultActionIfActionCantBeResolvedIsSet()
 {
     $this->configuration['mvc']['callDefaultActionIfActionCantBeResolved'] = 1;
     $this->injectDependencies();
     $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
     $_GET = array('tx_myextension_pi1' => array('controller' => 'TheThirdController', 'action' => 'someInvalidAction'));
     $this->mockRequest->expects($this->once())->method('setControllerName')->with('TheThirdController');
     $this->mockRequest->expects($this->once())->method('setControllerActionName')->with('delete');
     $this->requestBuilder->build();
 }
Esempio n. 30
0
 /**
  * @test
  */
 public function enableFieldsDoesNotHideVersionedRecordsWhenCheckingVersionOverlays()
 {
     $table = $this->getUniqueId('aTable');
     $GLOBALS['TCA'] = array($table => array('ctrl' => array('versioningWS' => 2)));
     $this->pageSelectObject->versioningPreview = TRUE;
     $this->pageSelectObject->init(FALSE);
     $conditions = $this->pageSelectObject->enableFields($table, -1, array(), TRUE);
     $this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND ' . $table . '.t3ver_state<=0')), 'No versioning placeholders');
     $this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND ' . $table . '.pid<>-1')), 'No ecords from page -1');
 }