2 declare(strict_types = 1);
22 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\Internal\ArrayValueInstruction;
23 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
32 protected const ENCRYPTION_KEY =
'4408d27a916d51e624b69af3554f516dbab61037a9f7b9fd6f81b4d3bedeccb6';
34 protected const TYPO3_CONF_VARS = [
40 'requireCacheHashPresenceParameters' => [
'value',
'testing[value]',
'tx_testing_link[value]'],
41 'excludedParameters' => [
'L',
'tx_testing_link[excludedValue]']
46 protected const LANGUAGE_PRESETS = [
47 'EN' => [
'id' => 0,
'title' =>
'English',
'locale' =>
'en_US.UTF8',
'iso' =>
'en',
'hrefLang' =>
'en-US',
'direction' =>
''],
48 'FR' => [
'id' => 1,
'title' =>
'French',
'locale' =>
'fr_FR.UTF8',
'iso' =>
'fr',
'hrefLang' =>
'fr-FR',
'direction' =>
''],
49 'FR-CA' => [
'id' => 2,
'title' =>
'Franco-Canadian',
'locale' =>
'fr_CA.UTF8',
'iso' =>
'fr',
'hrefLang' =>
'fr-CA',
'direction' =>
''],
50 'ES' => [
'id' => 3,
'title' =>
'Spanish',
'locale' =>
'es_ES.UTF8',
'iso' =>
'es',
'hrefLang' =>
'es-ES',
'direction' =>
''],
56 protected $coreExtensionsToLoad = [
'frontend',
'workspaces'];
61 protected $pathsToLinkInTestInstance = [
62 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/AdditionalConfiguration.php' =>
'typo3conf/AdditionalConfiguration.php',
69 protected function wrapInArray(array $array): array
83 protected function keysFromValues(array $array): array
85 return array_combine($array, $array);
103 protected function keysFromTemplate(array $array,
string $template, callable $callback =
null): array
105 $keys = array_unique(
107 function (array $values) use ($template, $callback) {
108 if ($callback !==
null) {
109 $values = call_user_func($callback, $values);
111 return vsprintf($template, $values);
117 if (count($keys) !== count($array)) {
118 throw new \LogicException(
119 'Amount of generated keys does not match to item count.',
124 return array_combine($keys, $array);
137 'Array was not empty as expected, but contained these items:' . LF
138 .
'* ' . implode(LF .
'* ', $items)
146 protected static function generateCacheHash(
string $uri): string
148 if (!isset(
$GLOBALS[
'TYPO3_CONF_VARS'])) {
152 $configuration =
$GLOBALS[
'TYPO3_CONF_VARS'];
155 static::TYPO3_CONF_VARS
158 $calculator =
new CacheHashCalculator();
159 $parameters = $calculator->getRelevantParameters(
160 parse_url($uri, PHP_URL_QUERY)
162 $cacheHash = $calculator->calculateCacheHash($parameters);
164 $GLOBALS[
'TYPO3_CONF_VARS'] = $configuration;
172 protected function createTypoLinkUrlInstruction(array $typoScript): ArrayValueInstruction
174 return (
new ArrayValueInstruction(LinkHandlingController::class))
178 'typolink.' => array_merge(
180 [
'returnLast' =>
'url']
190 protected function createHierarchicalMenuProcessorInstruction(array $typoScript): ArrayValueInstruction
192 return (
new ArrayValueInstruction(LinkHandlingController::class))
194 '10' =>
'FLUIDTEMPLATE',
196 'file' =>
'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/FluidJson.html',
197 'dataProcessing.' => [
198 '1' =>
'TYPO3\\CMS\\Frontend\\DataProcessing\\MenuProcessor',
212 protected function createLanguageMenuProcessorInstruction(array $typoScript): ArrayValueInstruction
214 return (
new ArrayValueInstruction(LinkHandlingController::class))
216 '10' =>
'FLUIDTEMPLATE',
218 'file' =>
'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/FluidJson.html',
219 'dataProcessing.' => [
220 '1' =>
'TYPO3\\CMS\\Frontend\\DataProcessing\\LanguageMenuProcessor',
237 protected function filterMenu(
239 array $keepNames = [
'title',
'link']
241 if (!in_array(
'children', $keepNames)) {
242 $keepNames[] =
'children';
245 function (array $menuItem) use ($keepNames) {
246 $menuItem = array_filter(
248 function (
string $name) use ($keepNames) {
249 return in_array($name, $keepNames);
253 if (is_array($menuItem[
'children'] ??
null)) {
254 $menuItem[
'children'] = $this->filterMenu(
255 $menuItem[
'children'],