Skip to content

Commit 4844fec

Browse files
committed
Fix usage of backend utility in unit tests
1 parent b694971 commit 4844fec

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

Classes/Hooks/DataHandlerHook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function processDatamap_afterDatabaseOperations( // @codingStandardsIgnor
8282
private function getBackendRecordField(int $uid, string $field)
8383
{
8484
if (!isset(self::$records[$uid])) {
85-
self::$records[$uid] = BackendUtility::getRecord('tt_content', $uid);
85+
self::$records[$uid] = BackendUtility::getRecord('tt_content', $uid); // @codeCoverageIgnore
8686
}
8787
return self::$records[$uid][$field] ?? null;
8888
}

Tests/Unit/Hooks/DataHandlerHookTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ class DataHandlerHookTest extends UnitTestCase
2323
'NEW123456' => 123456,
2424
];
2525

26+
public function setUp()
27+
{
28+
parent::setUp();
29+
// default record has no bodytext
30+
\Closure::bind(function () {
31+
self::$records[123456] = ['bodytext' => ''];
32+
}, null, DataHandlerHook::class)->call(new DataHandlerHook());
33+
}
34+
2635
public function tearDown()
2736
{
2837
parent::tearDown();
@@ -145,13 +154,6 @@ public function datamapWithFileReferenceProvider(): array
145154
'references' => [456],
146155
'updateTriggered' => true,
147156
'updateParams' => ['tt_content', 123456, ['bodytext' => 'spreadsheet://456']],
148-
'closure' => function () {
149-
self::$records[123456] = [
150-
'CType' => 'spreadsheets_table',
151-
'tx_spreadsheets_assets' => 1,
152-
'bodytext' => '',
153-
];
154-
},
155157
],
156158
];
157159
}

0 commit comments

Comments
 (0)