From 9446d14b77fc93f71689c6f3f9cb36f62b918e45 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Sun, 6 Oct 2024 20:50:24 +0200 Subject: [PATCH] [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. --- .../Domain/Repository/TeaRepositoryTest.php | 9 +++++ .../Domain/Repository/TeaRepositoryTest.php | 39 ------------------- 2 files changed, 9 insertions(+), 39 deletions(-) delete mode 100644 Tests/Unit/Domain/Repository/TeaRepositoryTest.php diff --git a/Tests/Functional/Domain/Repository/TeaRepositoryTest.php b/Tests/Functional/Domain/Repository/TeaRepositoryTest.php index d781747..08f6558 100644 --- a/Tests/Functional/Domain/Repository/TeaRepositoryTest.php +++ b/Tests/Functional/Domain/Repository/TeaRepositoryTest.php @@ -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 */ diff --git a/Tests/Unit/Domain/Repository/TeaRepositoryTest.php b/Tests/Unit/Domain/Repository/TeaRepositoryTest.php deleted file mode 100644 index c7e9e8b..0000000 --- a/Tests/Unit/Domain/Repository/TeaRepositoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -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); - } -}