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:
parent
c99b073bf6
commit
834f69e173
2 changed files with 9 additions and 39 deletions
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue