Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions Tests/Functional/Caching/FlushViaDataHandlerChangesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<string,array{params:array}|array{params:array<string,string>}>
*/
public function possibleNoneTriggeringParams(): \Generator
public static function possibleNoneTriggeringParams(): \Generator
{
yield 'no table given' => [
'params' => [],
Expand All @@ -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);
}
}
4 changes: 4 additions & 0 deletions Tests/Functional/Fixtures/Frontend/Rendering.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ tt_content.template = TEXT
tt_content.template.value = <p>{data.bodytext -> f:format.html()}</p>

plugin.tx_variables.persistence.storagePid = 4

lib.parseFunc_RTE {
htmlSanitize = 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Frontend/BreaksOnInvalidHookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* @covers \Sinso\Variables\Service\VariablesService
*/
class BreaksOnInvalidHookTest extends AbstractProcessesMarkersTest
class BreaksOnInvalidHookTest extends AbstractProcessesMarkersTestCase
{
protected array $configurationToUseInTestInstance = [
'EXTCONF' => [
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Frontend/ProcessesMarkersHookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* @covers \Sinso\Variables\Hooks\ContentProcessor
*/
class ProcessesMarkersHookTest extends AbstractProcessesMarkersTest
class ProcessesMarkersHookTest extends AbstractProcessesMarkersTestCase
{
protected array $configurationToUseInTestInstance = [
'EXTCONF' => [
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Frontend/ProcessesMarkersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @covers \Sinso\Variables\Hooks\ContentProcessor
*/
class ProcessesMarkersTest extends AbstractProcessesMarkersTest
class ProcessesMarkersTest extends AbstractProcessesMarkersTestCase
{
public function testNoMarkerAppliedAsNoneExist(): void
{
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down