From 32a1e802cc682a00573c0ea24a7db916e52d2328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Mon, 27 Jan 2025 09:39:33 +0100 Subject: [PATCH] Remove PurgeDatabaseTrait usage --- .../src/Tests/Controller/BlogPostApiTest.php | 4 +-- .../src/Tests/Controller/BookApiTest.php | 12 ++++--- .../src/Tests/Controller/ComicBookApiTest.php | 4 +-- .../src/Tests/Controller/GedmoApiTest.php | 4 +-- .../Tests/Controller/PullRequestApiTest.php | 4 +-- .../Controller/SubscriptionJsonApiTest.php | 4 +-- .../Controller/SubscriptionXmlApiTest.php | 4 +-- tests/PurgeDatabaseTrait.php | 36 ------------------- 8 files changed, 20 insertions(+), 52 deletions(-) delete mode 100644 tests/PurgeDatabaseTrait.php diff --git a/tests/Application/src/Tests/Controller/BlogPostApiTest.php b/tests/Application/src/Tests/Controller/BlogPostApiTest.php index 3769a16a1..747b9d001 100644 --- a/tests/Application/src/Tests/Controller/BlogPostApiTest.php +++ b/tests/Application/src/Tests/Controller/BlogPostApiTest.php @@ -18,13 +18,13 @@ use Sylius\Bundle\ResourceBundle\ResourceBundleInterface; use Symfony\Component\HttpFoundation\Response; use Tests\ApiTestCase; -use Tests\PurgeDatabaseTrait; use Zenstruck\Foundry\Test\Factories; +use Zenstruck\Foundry\Test\ResetDatabase; final class BlogPostApiTest extends ApiTestCase { use Factories; - use PurgeDatabaseTrait; + use ResetDatabase; #[Test] public function it_allows_creating_a_blog_post(): void diff --git a/tests/Application/src/Tests/Controller/BookApiTest.php b/tests/Application/src/Tests/Controller/BookApiTest.php index 2e5c64467..a6958281c 100644 --- a/tests/Application/src/Tests/Controller/BookApiTest.php +++ b/tests/Application/src/Tests/Controller/BookApiTest.php @@ -21,13 +21,13 @@ use PHPUnit\Framework\Attributes\Test; use Symfony\Component\HttpFoundation\Response; use Tests\ApiTestCase; -use Tests\PurgeDatabaseTrait; use Zenstruck\Foundry\Test\Factories; +use Zenstruck\Foundry\Test\ResetDatabase; class BookApiTest extends ApiTestCase { use Factories; - use PurgeDatabaseTrait; + use ResetDatabase; #[Test] public function it_allows_creating_a_book(): void @@ -132,8 +132,7 @@ public function it_allows_removing_a_book(): void $this->assertResponseIsSuccessful(); $this->assertResponseStatusCodeSame(Response::HTTP_NO_CONTENT); - $deletedBook = $this->getContainer()->get('app.repository.book')->find($bookId); - $this->assertNull($deletedBook); + $this->assertEquals(0, $this->getContainer()->get('app.repository.book')->count([])); } #[Test] @@ -668,4 +667,9 @@ private function markAsSkippedIfNecessary(): void $this->markTestSkipped(); } } + + public function assert() + { + return $this->assertEquals(); + } } diff --git a/tests/Application/src/Tests/Controller/ComicBookApiTest.php b/tests/Application/src/Tests/Controller/ComicBookApiTest.php index db3ba3319..7eb01b59f 100644 --- a/tests/Application/src/Tests/Controller/ComicBookApiTest.php +++ b/tests/Application/src/Tests/Controller/ComicBookApiTest.php @@ -19,13 +19,13 @@ use PHPUnit\Framework\Attributes\Test; use Symfony\Component\HttpFoundation\Response; use Tests\ApiTestCase; -use Tests\PurgeDatabaseTrait; use Zenstruck\Foundry\Test\Factories; +use Zenstruck\Foundry\Test\ResetDatabase; final class ComicBookApiTest extends ApiTestCase { use Factories; - use PurgeDatabaseTrait; + use ResetDatabase; #[Test] public function it_allows_creating_a_comic_book(): void diff --git a/tests/Application/src/Tests/Controller/GedmoApiTest.php b/tests/Application/src/Tests/Controller/GedmoApiTest.php index 9dda4fe0b..acd058dab 100644 --- a/tests/Application/src/Tests/Controller/GedmoApiTest.php +++ b/tests/Application/src/Tests/Controller/GedmoApiTest.php @@ -16,11 +16,11 @@ use PHPUnit\Framework\Attributes\Test; use Symfony\Component\HttpFoundation\Response; use Tests\ApiTestCase; -use Tests\PurgeDatabaseTrait; +use Zenstruck\Foundry\Test\ResetDatabase; final class GedmoApiTest extends ApiTestCase { - use PurgeDatabaseTrait; + use ResetDatabase; #[Test] public function it_allows_creating_a_comic_book(): void diff --git a/tests/Application/src/Tests/Controller/PullRequestApiTest.php b/tests/Application/src/Tests/Controller/PullRequestApiTest.php index ec549f65d..473a53826 100644 --- a/tests/Application/src/Tests/Controller/PullRequestApiTest.php +++ b/tests/Application/src/Tests/Controller/PullRequestApiTest.php @@ -17,13 +17,13 @@ use PHPUnit\Framework\Attributes\Test; use Symfony\Component\HttpFoundation\Response; use Tests\ApiTestCase; -use Tests\PurgeDatabaseTrait; use Zenstruck\Foundry\Test\Factories; +use Zenstruck\Foundry\Test\ResetDatabase; final class PullRequestApiTest extends ApiTestCase { use Factories; - use PurgeDatabaseTrait; + use ResetDatabase; #[Test] public function it_allows_creating_a_pull_request(): void diff --git a/tests/Application/src/Tests/Controller/SubscriptionJsonApiTest.php b/tests/Application/src/Tests/Controller/SubscriptionJsonApiTest.php index c956f15d2..1d31fad98 100644 --- a/tests/Application/src/Tests/Controller/SubscriptionJsonApiTest.php +++ b/tests/Application/src/Tests/Controller/SubscriptionJsonApiTest.php @@ -19,13 +19,13 @@ use PHPUnit\Framework\Attributes\Test; use Symfony\Component\HttpFoundation\Response; use Tests\ApiTestCase; -use Tests\PurgeDatabaseTrait; use Zenstruck\Foundry\Test\Factories; +use Zenstruck\Foundry\Test\ResetDatabase; final class SubscriptionJsonApiTest extends ApiTestCase { use Factories; - use PurgeDatabaseTrait; + use ResetDatabase; #[Test] public function it_allows_showing_a_subscription(): void diff --git a/tests/Application/src/Tests/Controller/SubscriptionXmlApiTest.php b/tests/Application/src/Tests/Controller/SubscriptionXmlApiTest.php index 9653b79c1..bae8355c2 100644 --- a/tests/Application/src/Tests/Controller/SubscriptionXmlApiTest.php +++ b/tests/Application/src/Tests/Controller/SubscriptionXmlApiTest.php @@ -19,13 +19,13 @@ use PHPUnit\Framework\Attributes\Test; use Symfony\Component\HttpFoundation\Response; use Tests\ApiTestCase; -use Tests\PurgeDatabaseTrait; use Zenstruck\Foundry\Test\Factories; +use Zenstruck\Foundry\Test\ResetDatabase; final class SubscriptionXmlApiTest extends ApiTestCase { use Factories; - use PurgeDatabaseTrait; + use ResetDatabase; private static array $headersWithContentType = [ 'CONTENT_TYPE' => 'application/xml', diff --git a/tests/PurgeDatabaseTrait.php b/tests/PurgeDatabaseTrait.php deleted file mode 100644 index 13137f8c2..000000000 --- a/tests/PurgeDatabaseTrait.php +++ /dev/null @@ -1,36 +0,0 @@ -getContainer()->get(EntityManagerInterface::class); - $purger = new ORMPurger($entityManager); - $purger->purge(); - - $entityManager->clear(); - } -}