From 67c359a6ddd08bac86bf8a5ad9c5cf9615a3a69b Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Mon, 17 Mar 2025 22:59:49 +0100 Subject: [PATCH] Replace entity manager clear by creating a new client --- .../Api/EntryRestControllerTest.php | 16 ++++++++----- .../Controller/Api/TagRestControllerTest.php | 3 ++- tests/Controller/ConfigControllerTest.php | 3 ++- tests/Controller/EntryControllerTest.php | 15 ++++++++---- tests/Controller/TagControllerTest.php | 24 ++++++++++++------- 5 files changed, 40 insertions(+), 21 deletions(-) diff --git a/tests/Controller/Api/EntryRestControllerTest.php b/tests/Controller/Api/EntryRestControllerTest.php index 1dc95c331..33c6fa6c7 100644 --- a/tests/Controller/Api/EntryRestControllerTest.php +++ b/tests/Controller/Api/EntryRestControllerTest.php @@ -541,7 +541,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $em->persist($entry); $em->flush(); - $em->clear(); + $this->client = $this->createAuthorizedClient(); $e = [ 'title' => $entry->getTitle(), @@ -574,7 +574,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $em->persist($entry); $em->flush(); - $em->clear(); + $this->client = $this->createAuthorizedClient(); $id = $entry->getId(); @@ -666,7 +666,8 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry->addTag((new Tag())->setLabel('apple')); $em->persist($entry); $em->flush(); - $em->clear(); + + $this->client = $this->createAuthorizedClient(); $this->client->request('POST', '/api/entries.json', [ 'url' => 'https://www.20minutes.fr/sport/jo_2024/4095122-20240712-jo-paris-2024-saut-ange-bombe-comment-anne-hidalgo-va-plonger-seine-si-fait-vraiment', @@ -1361,7 +1362,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $em->persist($entry); $em->flush(); - $em->clear(); + $this->client = $this->createAuthorizedClient(); $list = [ [ @@ -1425,7 +1426,9 @@ class EntryRestControllerTest extends WallabagApiTestCase $em->persist((new Entry($em->getReference(User::class, $this->getUserId())))->setUrl('http://0.0.0.0/test-entry1')); $em->flush(); - $em->clear(); + + $this->client = $this->createAuthorizedClient(); + $list = [ 'http://0.0.0.0/test-entry1', 'http://0.0.0.0/test-entry-not-exist', @@ -1487,7 +1490,8 @@ class EntryRestControllerTest extends WallabagApiTestCase $entry->setPublishedAt(new \DateTime('2017-06-26T07:46:02+0200')); $em->persist($entry); $em->flush(); - $em->clear(); + + $this->client = $this->createAuthorizedClient(); $this->client->request('POST', '/api/entries.json', [ 'url' => 'https://www.lemonde.fr/m-perso/article/2017/06/25/antoine-de-caunes-je-veux-avoir-le-droit-de-tatonner_5150728_4497916.html', diff --git a/tests/Controller/Api/TagRestControllerTest.php b/tests/Controller/Api/TagRestControllerTest.php index 615d34a23..71115f4a3 100644 --- a/tests/Controller/Api/TagRestControllerTest.php +++ b/tests/Controller/Api/TagRestControllerTest.php @@ -49,7 +49,8 @@ class TagRestControllerTest extends WallabagApiTestCase $em->persist($entry); $em->flush(); - $em->clear(); + + $this->client = $this->createAuthorizedClient(); $this->client->request('DELETE', '/api/tags/' . $tag->getId() . '.json'); diff --git a/tests/Controller/ConfigControllerTest.php b/tests/Controller/ConfigControllerTest.php index 4596418a0..3e097994c 100644 --- a/tests/Controller/ConfigControllerTest.php +++ b/tests/Controller/ConfigControllerTest.php @@ -80,7 +80,8 @@ class ConfigControllerTest extends WallabagTestCase $this->getEntityManager()->persist($entry); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); $crawler = $client->request('GET', '/unread/list'); $form = $crawler->filter('button[id=submit-filter]')->form(); diff --git a/tests/Controller/EntryControllerTest.php b/tests/Controller/EntryControllerTest.php index d9a1e4539..40b9f25f7 100644 --- a/tests/Controller/EntryControllerTest.php +++ b/tests/Controller/EntryControllerTest.php @@ -538,7 +538,8 @@ class EntryControllerTest extends WallabagTestCase $entry->setContent(''); $this->getEntityManager()->persist($entry); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); $client->request('GET', '/reload/' . $entry->getId()); @@ -670,7 +671,8 @@ class EntryControllerTest extends WallabagTestCase $entry->setUrl($this->url); $this->getEntityManager()->persist($entry); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); $client->request('GET', '/archive/' . $entry->getId()); @@ -693,7 +695,8 @@ class EntryControllerTest extends WallabagTestCase $entry->setUrl($this->url); $this->getEntityManager()->persist($entry); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); $client->request('GET', '/star/' . $entry->getId()); @@ -1200,7 +1203,8 @@ class EntryControllerTest extends WallabagTestCase $content->setUrl($this->url); $this->getEntityManager()->persist($content); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); // no uid $client->request('GET', '/share/' . $content->getUid()); @@ -1791,7 +1795,8 @@ class EntryControllerTest extends WallabagTestCase $this->getEntityManager()->persist($entry3); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); $entries = []; $entries[] = $entry1->getId(); diff --git a/tests/Controller/TagControllerTest.php b/tests/Controller/TagControllerTest.php index 40051b7fa..782cbc127 100644 --- a/tests/Controller/TagControllerTest.php +++ b/tests/Controller/TagControllerTest.php @@ -35,7 +35,8 @@ class TagControllerTest extends WallabagTestCase $entry->setUrl('http://0.0.0.0/foo'); $this->getEntityManager()->persist($entry); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); $crawler = $client->request('GET', '/view/' . $entry->getId()); @@ -120,7 +121,8 @@ class TagControllerTest extends WallabagTestCase $entry->addTag($tag); $this->getEntityManager()->persist($entry); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); // We make a first request to set an history and test redirection after tag deletion $crawler = $client->request('GET', '/view/' . $entry->getId()); @@ -166,7 +168,8 @@ class TagControllerTest extends WallabagTestCase $entry2->addTag($tag); $this->getEntityManager()->persist($entry2); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); $crawler = $client->request('GET', '/tag/list'); $link = $crawler->filter('a[id="delete-' . $tag->getSlug() . '"]')->link(); @@ -254,7 +257,8 @@ class TagControllerTest extends WallabagTestCase $this->getEntityManager()->persist($entry2); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); // We make a first request to set an history and test redirection after tag deletion $crawler = $client->request('GET', '/tag/list'); @@ -321,7 +325,8 @@ class TagControllerTest extends WallabagTestCase $this->getEntityManager()->persist($entry); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); // We make a first request to set an history and test redirection after tag deletion $crawler = $client->request('GET', '/tag/list'); @@ -376,7 +381,8 @@ class TagControllerTest extends WallabagTestCase $this->getEntityManager()->persist($entry); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); // We make a first request to set an history and test redirection after tag deletion $crawler = $client->request('GET', '/tag/list'); @@ -446,7 +452,8 @@ class TagControllerTest extends WallabagTestCase $this->getEntityManager()->persist($entry2); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); // We make a first request to set an history and test redirection after tag deletion $crawler = $client->request('GET', '/tag/list'); @@ -496,7 +503,8 @@ class TagControllerTest extends WallabagTestCase $entry->setUrl('http://0.0.0.0/tag-caché'); $this->getEntityManager()->persist($entry); $this->getEntityManager()->flush(); - $this->getEntityManager()->clear(); + + $client = $this->getTestClient(); $crawler = $client->request('GET', '/view/' . $entry->getId());