Skip to content

Commit

Permalink
[TASK] Check for SingletonInterface of FileRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
nhovratov committed Mar 8, 2024
1 parent 5ad31ba commit f42072a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Tests/Unit/Helper/InlineHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use MASK\Mask\Tests\Unit\StorageRepositoryCreatorTrait;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\TestingFramework\Core\BaseTestCase;

Expand Down Expand Up @@ -125,8 +126,11 @@ public function addFilesToData(array $json, string $key, array $data, string $ta
$fileRepositoryMock = $this->createMock(FileRepository::class);
$fileReference = $this->createMock(FileReference::class);
$fileRepositoryMock->method('findByRelation')->willReturn([$fileReference]);
GeneralUtility::setSingletonInstance(FileRepository::class, $fileRepositoryMock);

if ($fileRepositoryMock instanceof SingletonInterface) {
GeneralUtility::setSingletonInstance(FileRepository::class, $fileRepositoryMock);
} else {
GeneralUtility::addInstance(FileRepository::class, $fileRepositoryMock);
}
$inlineHelper = new InlineHelper(TableDefinitionCollection::createFromArray($json), $backendLayoutRepositoryMock);
$inlineHelper->addFilesToData($data, $table);

Expand Down

0 comments on commit f42072a

Please sign in to comment.