Skip to content

Commit

Permalink
[FIX] tests for TYPO3 13 @ 2024.07.09
Browse files Browse the repository at this point in the history
  • Loading branch information
dkd-kaehm committed Jul 9, 2024
1 parent 915e449 commit 9d05826
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 64 deletions.
22 changes: 22 additions & 0 deletions Classes/Domain/Index/Queue/UpdateHandler/AbstractUpdateHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use ApacheSolrForTypo3\Solr\System\Records\Pages\PagesRepository;
use ApacheSolrForTypo3\Solr\System\TCA\TCAService;
use Doctrine\DBAL\Exception as DBALException;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -279,4 +280,25 @@ protected function getQueryBuilderForTable(string $table): QueryBuilder

return $this->queryBuilders[$table];
}

/**
* Wraps {@link BackendUtility::getRecord()}
*
* Purpose: Unit-Tests
*/
protected function getRecord(
string $table,
int|string $uid,
string $fields = '*',
string $where = '',
bool $useDeleteClause = true,
): ?array {
return BackendUtility::getRecord(
$table,
$uid,
$fields,
$where,
$useDeleteClause,
);
}
}
22 changes: 0 additions & 22 deletions Classes/Domain/Index/Queue/UpdateHandler/DataUpdateHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use ApacheSolrForTypo3\Solr\Util;
use Doctrine\DBAL\Exception as DBALException;
use Throwable;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -548,25 +547,4 @@ protected function getSiteRepository(): SiteRepository
{
return GeneralUtility::makeInstance(SiteRepository::class);
}

/**
* Wraps {@link BackendUtility::getRecord()}
*
* Purpose: Unit-Tests
*/
protected function getRecord(
string $table,
int|string $uid,
string $fields = '*',
string $where = '',
bool $useDeleteClause = true,
): ?array {
return BackendUtility::getRecord(
$table,
$uid,
$fields,
$where,
$useDeleteClause,
);
}
}
8 changes: 7 additions & 1 deletion Classes/Domain/Index/Queue/UpdateHandler/GarbageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ public function performRecordGarbageCheck(
}

if ($table === 'pages') {
$this->deleteSubEntriesWhenRecursiveTriggerIsRecognized($table, $uid, $updatedFields);
// We need to get the full record to find out if this is a page translation
$fullRecord = $this->getRecord('pages', $uid);
$uidForRecursiveTriggers = $uid;
if (($fullRecord['sys_language_uid'] ?? null) > 0) {
$uidForRecursiveTriggers = (int)$fullRecord['l10n_parent'];
}
$this->deleteSubEntriesWhenRecursiveTriggerIsRecognized($table, $uidForRecursiveTriggers, $updatedFields);
}

$record = $this->tcaService->normalizeFrontendGroupField($table, $record);
Expand Down
42 changes: 7 additions & 35 deletions Tests/Integration/GarbageCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,41 +47,13 @@ class GarbageCollectorTest extends IntegrationTestBase
'../vendor/apache-solr-for-typo3/solr/Tests/Integration/Fixtures/Extensions/fake_extension',
];

/**
* @var RecordMonitor
*/
protected $recordMonitor;

/**
* @var DataHandler
*/
protected $dataHandler;

/**
* @var Queue
*/
protected $indexQueue;

/**
* @var GarbageCollector
*/
protected $garbageCollector;

/**
* @var Indexer
*/
protected $indexer;

/**
* @var ExtensionConfiguration
*/
protected $extensionConfiguration;

/**
* @var EventQueueItemRepository
*/
protected $eventQueue;

protected RecordMonitor $recordMonitor;
protected DataHandler $dataHandler;
protected Queue $indexQueue;
protected GarbageCollector $garbageCollector;
protected Indexer $indexer;
protected ExtensionConfiguration $extensionConfiguration;
protected EventQueueItemRepository $eventQueue;
protected BackendUserAuthentication $backendUser;

protected function setUp(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function setUp(): void
$this->pagesRepositoryMock,
$this->dataHandlerMock,
$this->loggerMock,
]
],
);
$this->dataUpdateHandler
->expects(self::any())
Expand Down
16 changes: 11 additions & 5 deletions Tests/Unit/Domain/Index/Queue/UpdateHandler/GarbageHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ class GarbageHandlerTest extends SetUpUpdateHandler
protected function setUp(): void
{
parent::setUp();
$this->garbageHandler = new GarbageHandler(
$this->recordServiceMock,
$this->frontendEnvironmentMock,
$this->tcaServiceMock,
$this->indexQueueMock
$this->garbageHandler = $this->getAccessibleMock(
GarbageHandler::class,
[
'getRecord',
],
[
$this->recordServiceMock,
$this->frontendEnvironmentMock,
$this->tcaServiceMock,
$this->indexQueueMock,
],
);
}

Expand Down

0 comments on commit 9d05826

Please sign in to comment.