diff --git a/Tests/Functional/Caching/FlushViaDataHandlerChangesTest.php b/Tests/Functional/Caching/FlushViaDataHandlerChangesTest.php index 1a76d07..928c921 100644 --- a/Tests/Functional/Caching/FlushViaDataHandlerChangesTest.php +++ b/Tests/Functional/Caching/FlushViaDataHandlerChangesTest.php @@ -27,6 +27,8 @@ use Prophecy\PhpUnit\ProphecyTrait; use Sinso\Variables\Hooks\DataHandler; use TYPO3\CMS\Core\Cache\CacheManager; +use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Core\DataHandling\DataHandler as Typo3DataHandler; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -35,36 +37,26 @@ */ class FlushViaDataHandlerChangesTest extends FunctionalTestCase { - use ProphecyTrait; - - public function testCanBeCreated(): void - { - $subject = new DataHandler(); - - self::assertInstanceOf( - DataHandler::class, - $subject - ); - } - /** * @dataProvider possibleNoneTriggeringParams */ public function testDoesNotInteractWithCacheManagerOnUnkownData(array $params): void { - $cacheManager = $this->prophesize(CacheManager::class); - GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManager->reveal()); - - $subject = new DataHandler(); - $subject->clearCachePostProc($params); - - $cacheManager->flushCachesInGroupByTag('pages', Argument::type('array'))->shouldNotBeCalled(); + $connectionPool = self::createMock(ConnectionPool::class); + $cacheManager = self::createMock(CacheManager::class); + $cacheManager + ->expects(self::never()) + ->method('flushCachesInGroupByTag') + ; + + $subject = new DataHandler($connectionPool, $cacheManager); + $subject->clearCachePostProc($params, self::createStub(Typo3DataHandler::class)); } /** * @return Generator}> */ - public function possibleNoneTriggeringParams(): \Generator + public static function possibleNoneTriggeringParams(): \Generator { yield 'no table given' => [ 'params' => [], @@ -85,16 +77,28 @@ public function possibleNoneTriggeringParams(): \Generator public function testFlushCachesByGroupForMarker(): void { - $cacheManager = $this->prophesize(CacheManager::class); - GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManager->reveal()); + $connectionPool = self::createMock(ConnectionPool::class); + $cacheManager = self::createMock(CacheManager::class); + $cacheManager + ->expects(self::once()) + ->method('flushCachesInGroupByTag') + ->with('pages', $this->stringStartsWith('tx_variables_key_hash_')) + ; + + $dataHandler = self::createStub(Typo3DataHandler::class); + $dataHandler->datamap = [ + 'tx_variables_marker' => [ + 1 => [ + 'marker' => 'TEST', + ], + ], + ]; - $subject = new DataHandler(); + $subject = new DataHandler($connectionPool, $cacheManager); $subject->clearCachePostProc([ 'table' => 'tx_variables_marker', 'uid' => '1', 'marker' => 'TEST' - ]); - - $cacheManager->flushCachesInGroupByTag('pages', 'tx_variables_key_hash_033bd94b1168d7e4f0d644c3c95e35bf')->shouldBeCalledOnce(); + ], $dataHandler); } } diff --git a/Tests/Functional/Fixtures/Frontend/Rendering.typoscript b/Tests/Functional/Fixtures/Frontend/Rendering.typoscript index 277f23d..3e97985 100644 --- a/Tests/Functional/Fixtures/Frontend/Rendering.typoscript +++ b/Tests/Functional/Fixtures/Frontend/Rendering.typoscript @@ -6,3 +6,7 @@ tt_content.template = TEXT tt_content.template.value =

{data.bodytext -> f:format.html()}

plugin.tx_variables.persistence.storagePid = 4 + +lib.parseFunc_RTE { + htmlSanitize = 1 +} diff --git a/Tests/Functional/Frontend/AbstractProcessesMarkersTest.php b/Tests/Functional/Frontend/AbstractProcessesMarkersTestCase.php similarity index 76% rename from Tests/Functional/Frontend/AbstractProcessesMarkersTest.php rename to Tests/Functional/Frontend/AbstractProcessesMarkersTestCase.php index 332e646..5e45150 100644 --- a/Tests/Functional/Frontend/AbstractProcessesMarkersTest.php +++ b/Tests/Functional/Frontend/AbstractProcessesMarkersTestCase.php @@ -23,10 +23,12 @@ namespace Sinso\Variables\Tests\Functional\Frontend; +use TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend; +use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; -abstract class AbstractProcessesMarkersTest extends FunctionalTestCase +abstract class AbstractProcessesMarkersTestCase extends FunctionalTestCase { protected array $testExtensionsToLoad = [ 'typo3conf/ext/variables', @@ -38,6 +40,18 @@ abstract class AbstractProcessesMarkersTest extends FunctionalTestCase protected function setUp(): void { + ArrayUtility::mergeRecursiveWithOverrule($this->configurationToUseInTestInstance, [ + 'SYS' => [ + 'caching' => [ + 'cacheConfigurations' => [ + 'pages' => [ + 'backend' => Typo3DatabaseBackend::class, + ], + ], + ], + ], + ]); + parent::setUp(); $this->importDataSet('EXT:variables/Tests/Functional/Fixtures/Frontend/Content.xml'); diff --git a/Tests/Functional/Frontend/BreaksOnInvalidHookTest.php b/Tests/Functional/Frontend/BreaksOnInvalidHookTest.php index 25cd61f..9d2ae96 100644 --- a/Tests/Functional/Frontend/BreaksOnInvalidHookTest.php +++ b/Tests/Functional/Frontend/BreaksOnInvalidHookTest.php @@ -28,7 +28,7 @@ /** * @covers \Sinso\Variables\Service\VariablesService */ -class BreaksOnInvalidHookTest extends AbstractProcessesMarkersTest +class BreaksOnInvalidHookTest extends AbstractProcessesMarkersTestCase { protected array $configurationToUseInTestInstance = [ 'EXTCONF' => [ diff --git a/Tests/Functional/Frontend/ProcessesMarkersHookTest.php b/Tests/Functional/Frontend/ProcessesMarkersHookTest.php index 22f0d7c..7e21f82 100644 --- a/Tests/Functional/Frontend/ProcessesMarkersHookTest.php +++ b/Tests/Functional/Frontend/ProcessesMarkersHookTest.php @@ -28,7 +28,7 @@ /** * @covers \Sinso\Variables\Hooks\ContentProcessor */ -class ProcessesMarkersHookTest extends AbstractProcessesMarkersTest +class ProcessesMarkersHookTest extends AbstractProcessesMarkersTestCase { protected array $configurationToUseInTestInstance = [ 'EXTCONF' => [ diff --git a/Tests/Functional/Frontend/ProcessesMarkersTest.php b/Tests/Functional/Frontend/ProcessesMarkersTest.php index cf07b3e..dd9dc92 100644 --- a/Tests/Functional/Frontend/ProcessesMarkersTest.php +++ b/Tests/Functional/Frontend/ProcessesMarkersTest.php @@ -26,7 +26,7 @@ /** * @covers \Sinso\Variables\Hooks\ContentProcessor */ -class ProcessesMarkersTest extends AbstractProcessesMarkersTest +class ProcessesMarkersTest extends AbstractProcessesMarkersTestCase { public function testNoMarkerAppliedAsNoneExist(): void { diff --git a/composer.json b/composer.json index 41830c7..7caa296 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,6 @@ "require-dev": { "rector/rector": "^0.12.23", "typo3/testing-framework": "^7.0", - "phpspec/prophecy-phpunit": "^2.0", "symplify/easy-coding-standard": "^12.3" }, "extra": {