/** * @dataProvider cacheHashCalculationDataprovider * @test */ public function cacheHashCalculationWorks($params, $expected, $message) { if (!class_exists('t3lib_diff')) { $this->markTestSkipped('The current version of phpunit relies on t3lib_diff which is removed in 6.0 and thus this test fails. Move t3lib_diff to phpunit and reenable this test.'); } $this->assertEquals($expected, $this->fixture->calculateCacheHash($params), $message); }
/** * Calculates a hash string based on additional parameters in the url. * * Calculated hash is stored in $this->cHash_array. * This is used to cache pages with more parameters than just id and type. * * @return void * @see reqCHash() */ public function makeCacheHash() { // No need to test anything if caching was already disabled. if ($this->no_cache && !$this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) { return; } $GET = GeneralUtility::_GET(); if ($this->cHash && is_array($GET)) { $this->cHash_array = $this->cacheHash->getRelevantParameters(GeneralUtility::implodeArrayForUrl('', $GET)); $cHash_calc = $this->cacheHash->calculateCacheHash($this->cHash_array); if ($cHash_calc != $this->cHash) { if ($this->TYPO3_CONF_VARS['FE']['pageNotFoundOnCHashError']) { $this->pageNotFoundAndExit('Request parameters could not be validated (&cHash comparison failed)'); } else { $this->disableCache(); $this->getTimeTracker()->setTSlogMessage('The incoming cHash "' . $this->cHash . '" and calculated cHash "' . $cHash_calc . '" did not match, so caching was disabled. The fieldlist used was "' . implode(',', array_keys($this->cHash_array)) . '"', 2); } } } elseif (is_array($GET)) { // No cHash is set, check if that is correct if ($this->cacheHash->doParametersRequireCacheHash(GeneralUtility::implodeArrayForUrl('', $GET))) { $this->reqCHash(); } } }
/** * @dataProvider cacheHashCalculationDataprovider * @test */ public function cacheHashCalculationWorks($params, $expected) { $this->assertEquals($expected, $this->subject->calculateCacheHash($params)); }