/** * 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 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); }
/** * 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); }
/** * @test * @return void */ public function extractInformationForConfigFieldsOfTypeOptionsWithLabelsAndValuesAddsGenericTypeAndLabelInformation() { $option = array('cat' => 'basic', 'subcat_name' => 'enable', 'subcat' => 'a/enable/100z', 'type' => 'options[Minimal (Most features disabled. Administrator needs to enable them using TypoScript. For advanced administrators only.)=MINIMAL,Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.) = TYPICAL,Demo (Show-off configuration. Includes pre-configured styles. Not for production environments.)=DEMO]', 'label' => 'Default configuration settings', 'name' => 'defaultConfiguration', 'value' => 'Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.)', 'default_value' => 'Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.)', 'genericComparisonValue' => array('Minimal (Most features disabled. Administrator needs to enable them using TypoScript. For advanced administrators only.)' => 'MINIMAL', 'Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.)' => 'TYPICAL', 'Demo (Show-off configuration. Includes pre-configured styles. Not for production environments.)' => 'DEMO'), 'typeComparisonValue' => 'options'); $optionModified = $this->configurationItemRepository->_callRef('extractInformationForConfigFieldsOfTypeOptions', $option); $this->assertArrayHasKey('generic', $optionModified); $this->assertArrayHasKey('type', $optionModified); $this->assertArrayHasKey('label', $optionModified); $this->assertEquals($option['genericComparisonValue'], $optionModified['generic']); $this->assertEquals($option['typeComparisonValue'], $optionModified['type']); }
/** * @test */ public function removeDefaultControllerAndActionRemovesControllerAndActionIfBothAreEqualToTheDefault() { $this->mockExtensionService->expects($this->atLeastOnce())->method('getDefaultControllerNameByPlugin')->with('ExtensionName', 'PluginName')->will($this->returnValue('DefaultController')); $this->mockExtensionService->expects($this->atLeastOnce())->method('getDefaultActionNameByPluginAndController')->with('ExtensionName', 'PluginName', 'DefaultController')->will($this->returnValue('defaultAction')); $arguments = array('controller' => 'DefaultController', 'action' => 'defaultAction', 'foo' => 'bar'); $extensionName = 'ExtensionName'; $pluginName = 'PluginName'; $expectedResult = array('foo' => 'bar'); $actualResult = $this->uriBuilder->_callRef('removeDefaultControllerAndAction', $arguments, $extensionName, $pluginName); $this->assertEquals($expectedResult, $actualResult); }
/** * @test * @see http://forge.typo3.org/issues/23374 */ public function questionMarkParametersMayBeSafelyReplaced() { $sql = 'SELECT * FROM pages WHERE pid = ? AND timestamp < ? AND title != \'How to test?\''; $parameterValues = array(12, 1281782690); $components = $this->subject->_callRef('parseSELECT', $sql); for ($i = 0; $i < count($components['parameters']['?']); $i++) { $components['parameters']['?'][$i][0] = $parameterValues[$i]; } $result = $this->subject->_callRef('compileSELECT', $components); $expected = 'SELECT * FROM pages WHERE pid = 12 AND timestamp < 1281782690 AND title != \'How to test?\''; $this->assertEquals($expected, $this->cleanSql($result)); }
/** * @test */ public function convertRawConfigurationToArrayReturnsSortedHierarchicArray() { $configRaw = '# cat=basic/enable/10; type=string; label=Item 1: This is the first configuration item item1 = one # cat=basic/enable/20; type=int+; label=Integer Value: Please insert a positive integer value integerValue = 1 # cat=advanced/file/10; type=boolean; label=enableJquery: Insert jQuery plugin enableJquery = 1'; $extension = array(); $expectedArray = array('basic' => array('enable' => array('item1' => array('cat' => 'basic', 'subcat_name' => 'enable', 'subcat' => 'a/enable/10z', 'type' => 'string', 'label' => 'Item 1: This is the first configuration item', 'name' => 'item1', 'value' => 'one', 'default_value' => 'one', 'labels' => array(0 => 'Item 1', 1 => 'This is the first configuration item')), 'integerValue' => array('cat' => 'basic', 'subcat_name' => 'enable', 'subcat' => 'a/enable/20z', 'type' => 'int+', 'label' => 'Integer Value: Please insert a positive integer value', 'name' => 'integerValue', 'value' => '1', 'default_value' => '1', 'labels' => array(0 => 'Integer Value', 1 => 'Please insert a positive integer value')))), 'advanced' => array('file' => array('enableJquery' => array('cat' => 'advanced', 'subcat_name' => 'file', 'subcat' => 'c/file/10z', 'type' => 'boolean', 'label' => 'enableJquery: Insert jQuery plugin', 'name' => 'enableJquery', 'value' => '1', 'default_value' => '1', 'labels' => array(0 => 'enableJquery', 1 => 'Insert jQuery plugin'))))); $this->assertSame($expectedArray, $this->configurationItemRepository->_callRef('convertRawConfigurationToArray', $configRaw, $extension)); }
/** * Test for render() * * @param bool $extensionTableExists * @param bool $isNewerVersionAvailable * @param bool $currentVersionInExtensionTableExists * @param bool $isCurrentVersionUnsecure * @param int $expectedResult * @return void * @dataProvider renderReturnsIntDataProvider * @test */ public function renderReturnsInt($extensionTableExists, $isNewerVersionAvailable, $currentVersionInExtensionTableExists, $isCurrentVersionUnsecure, $expectedResult) { $this->abstractValidationViewHelperMock->_set('checkFromDatabase', false); $this->abstractValidationViewHelperMock->_callRef('setExtensionTableExists', $extensionTableExists); $this->abstractValidationViewHelperMock->_callRef('setIsNewerVersionAvailable', $isNewerVersionAvailable); $this->abstractValidationViewHelperMock->_callRef('setCurrentVersionInExtensionTableExists', $currentVersionInExtensionTableExists); $this->abstractValidationViewHelperMock->_callRef('setIsCurrentVersionUnsecure', $isCurrentVersionUnsecure); $result = $this->abstractValidationViewHelperMock->_callRef('render'); $this->assertSame($expectedResult, $result); }
/** * 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); }
/** * @test * @see http://forge.typo3.org/issues/21718 */ public function cachingFrameworkQueryIsRemapped() { $currentTime = time(); $table = 'cachingframework_cache_hash_tags'; $where = 'identifier IN (' . $this->subject->SELECTsubquery('identifier', 'cachingframework_cache_pages', 'crdate + lifetime < ' . $currentTime . ' AND lifetime > 0') . ')'; // Perform remapping (as in method exec_DELETEquery) $tableArray = $this->subject->_call('map_needMapping', $table); // Where clause: $whereParts = $this->subject->SQLparser->parseWhereClause($where); $this->subject->_callRef('map_sqlParts', $whereParts, $tableArray[0]['table']); $where = $this->subject->SQLparser->compileWhereClause($whereParts, FALSE); // Table name: if ($this->subject->mapping[$table]['mapTableName']) { $table = $this->subject->mapping[$table]['mapTableName']; } $result = $this->subject->DELETEquery($table, $where); $expected = 'DELETE FROM "cf_cache_hash_tags" WHERE "identifier" IN ('; $expected .= 'SELECT "identifier" FROM "cf_cache_pages" WHERE "crdate"+"lifetime" < ' . $currentTime . ' AND "lifetime" > 0'; $expected .= ')'; $this->assertEquals($expected, $this->cleanSql($result)); }
/** * Test for removePowermailAllParagraphTagWrap() * * @param string $content * @param string $expectedResult * @return void * @dataProvider removePowermailAllParagraphTagWrapReturnsStringDataProvider * @test */ public function removePowermailAllParagraphTagWrapReturnsString($content, $expectedResult) { $result = $this->abstractValidationViewHelperMock->_callRef('removePowermailAllParagraphTagWrap', $content); $this->assertSame($expectedResult, $result); }
/** * Test for render() * * @param string $type * @param array $settings * @param string $configurationType * @param array $expectedResult * @return void * @dataProvider getExcludedValuesReturnArrayDataProvider * @test */ public function getExcludedValuesReturnArray($type, $settings, $configurationType, $expectedResult) { $result = $this->isNotExcludedFromPowermailAllViewHelperMock->_callRef('getExcludedValues', $type, $settings, $configurationType); $this->assertSame($expectedResult, $result); }
/** * Test for render() * * @param array $answers Array with answeres * @param string $field Fieldname (key of answers array) * @param string $glue * @param bool $urlEncode * @param string $expectedResult * @return void * @dataProvider renderReturnsStringDataProvider * @test */ public function renderReturnsString($answers, $field, $glue, $urlEncode, $expectedResult) { $result = $this->abstractValidationViewHelperMock->_callRef('render', $answers, $field, $glue, $urlEncode); $this->assertSame($expectedResult, $result); }
/** * Test for removeDuplicatedWhitespace() * * @param string $string * @param string $expectedResult * @return void * @dataProvider removeDuplicatedWhitespaceReturnsStringDataProvider * @test */ public function removeDuplicatedWhitespaceReturnsString($string, $expectedResult) { $this->assertSame($expectedResult, $this->trimViewHelperMock->_callRef('removeDuplicatedWhitespace', $string)); }
/** * Test for getFromTypoScriptRaw() * * @param array $settings * @param string $marker * @param string $expectedResult * @dataProvider getFromTypoScriptRawReturnsStringDataProvider * @test */ public function getFromTypoScriptRawReturnsString(array $settings, $marker, $expectedResult) { $this->abstractValidationViewHelperMock->_set('settings', $settings); $this->abstractValidationViewHelperMock->_set('marker', $marker); $this->assertSame($expectedResult, $this->abstractValidationViewHelperMock->_callRef('getFromTypoScriptRaw')); }
/** * @test * @dataProvider canonicalizeAndCheckFolderIdentifierCanonicalizesFolderIdentifierDataProvider * @param string $expectedPath * @param string $identifier */ public function canonicalizeAndCheckFolderIdentifierCanonicalizesFolderIdentifier($expectedPath, $identifier) { $this->assertSame($expectedPath, $this->subject->_callRef('canonicalizeAndCheckFolderIdentifier', $identifier)); }
/** * Test for getDottedListOfExtensions() * * @param string $string * @param string $expectedResult * @return void * @dataProvider getDottedListOfExtensionsReturnsStringDataProvider * @test */ public function getDottedListOfExtensionsReturnsString($string, $expectedResult) { $result = $this->abstractValidationViewHelperMock->_callRef('getDottedListOfExtensions', $string); $this->assertSame($expectedResult, $result); }
/** * @test */ public function roundTripCryptStringAppliedTwoTimesReturnsOriginalString() { $clearText = 'Hello world!'; $refValue = $this->fixture->_callRef('roundTripCryptString', $clearText); $this->assertEquals($clearText, $this->fixture->_callRef('roundTripCryptString', $refValue)); }
/** * @test * @dataProvider parseSQLDataProvider * @param string $sql The SQL to trim * @param array $expected The expected trimmed SQL with single space at the end */ public function parseSQL($sql, $expected) { $result = $this->subject->_callRef('parseSQL', $sql); $this->assertSame($expected, $result); }