mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-24 14:16:15 +01:00

[TASK] Move a repository test from unit to functional (#1484)

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-06 20:50:24 +02:00 committed by GitHub
parent f93c998a92
commit 9446d14b77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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);
}
}