mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-21 18:36:13 +01:00

[TASK] Move a repository test from unit to functional

Unit tests for repositories are quite a hassle as we then need to
set up all dependencies in `setUp()` ourselves.

So convert the test to a functional tests where we can rely on the
container to create and initialize the subject for us.
This commit is contained in:
Oliver Klee 2024-10-03 12:35:09 +02:00
parent c99b073bf6
commit 834f69e173
No known key found for this signature in database
GPG key ID: E74BB46157AA8FDF
2 changed files with 9 additions and 39 deletions

View file

@ -8,6 +8,7 @@ use TTN\Tea\Domain\Model\Tea;
use TTN\Tea\Domain\Repository\TeaRepository;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
/**
@ -31,6 +32,14 @@ final class TeaRepositoryTest extends FunctionalTestCase
$this->subject = $this->get(TeaRepository::class);
}
/**
* @test
*/
public function isRepository(): void
{
self::assertInstanceOf(Repository::class, $this->subject);
}
/**
* @test
*/

View file

@ -1,39 +0,0 @@
<?php
declare(strict_types=1);
namespace TTN\Tea\Tests\Unit\Domain\Repository;
use TTN\Tea\Domain\Repository\TeaRepository;
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* @covers \TTN\Tea\Domain\Repository\TeaRepository
*/
final class TeaRepositoryTest extends UnitTestCase
{
private TeaRepository $subject;
protected function setUp(): void
{
parent::setUp();
if (\interface_exists(ObjectManagerInterface::class)) {
$objectManagerStub = $this->createStub(ObjectManagerInterface::class);
// @phpstan-ignore-next-line This line is 11LTS-specific, but we're running PHPStan on TYPO3 12.
$this->subject = new TeaRepository($objectManagerStub);
} else {
$this->subject = new TeaRepository();
}
}
/**
* @test
*/
public function isRepository(): void
{
self::assertInstanceOf(Repository::class, $this->subject);
}
}