1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Migrate getRepository with entities

This commit is contained in:
Yassine Guedidi 2022-08-25 21:37:10 +02:00
parent 50a941d8b4
commit 8b7b4975d6
38 changed files with 226 additions and 202 deletions

View file

@ -10,6 +10,7 @@ use Wallabag\CoreBundle\Entity\SiteCredential;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Helper\ContentProxy;
use Wallabag\CoreBundle\Helper\CryptoProxy;
use Wallabag\UserBundle\Entity\User;
class EntryControllerTest extends WallabagCoreTestCase
{
@ -115,7 +116,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$em = $client->getContainer()
->get('doctrine.orm.entity_manager');
$entry = $em
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
$em->remove($entry);
$em->flush();
@ -165,7 +166,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
$author = $content->getPublishedBy();
@ -202,7 +203,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
$tags = $content->getTagsLabel();
@ -239,7 +240,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
@ -379,7 +380,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$em = $client->getContainer()
->get('doctrine.orm.entity_manager');
$entry = $em
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findOneByUrl($url);
$tags = $entry->getTagsLabel();
@ -408,7 +409,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->assertStringContainsString('/', $client->getResponse()->getTargetUrl());
$entry = $em
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findOneByUrl($url);
$tags = $entry->getTagsLabel();
@ -511,7 +512,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->assertSame(302, $client->getResponse()->getStatusCode());
$entry = $this->getEntityManager()
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->find($entry->getId());
$this->assertNotEmpty($entry->getContent());
@ -535,7 +536,7 @@ class EntryControllerTest extends WallabagCoreTestCase
// otherwise, retrieve the same entity will retrieve change from the previous request :0
$this->getEntityManager()->clear();
$newContent = $this->getEntityManager()
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->find($entry->getId());
$this->assertNotSame($client->getContainer()->getParameter('wallabag_core.fetching_error_message'), $newContent->getContent());
@ -645,7 +646,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->find($entry->getId());
$this->assertSame(1, $res->isArchived());
@ -668,7 +669,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findOneById($entry->getId());
$this->assertSame(1, $res->isStarred());
@ -710,7 +711,7 @@ class EntryControllerTest extends WallabagCoreTestCase
// add a new content to be removed later
$user = $em
->getRepository('WallabagUserBundle:User')
->getRepository(User::class)
->findOneByUserName('admin');
$content = new Entry($user);
@ -743,7 +744,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findOneByUsernameAndNotArchived('bob');
$client->request('GET', '/view/' . $content->getId());
@ -949,7 +950,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$em = $this->getClient()->getContainer()->get('doctrine.orm.entity_manager');
$user = $em
->getRepository('WallabagUserBundle:User')
->getRepository(User::class)
->findOneByUserName('admin');
$annotation = new Annotation($user);
@ -1210,7 +1211,7 @@ class EntryControllerTest extends WallabagCoreTestCase
->get('doctrine.orm.entity_manager');
$entry = $em
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry);
@ -1250,7 +1251,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$client->request('GET', '/delete/' . $content->getId());
@ -1529,7 +1530,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
@ -1580,7 +1581,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->assertStringContainsString('flashes.entry.notice.entry_saved', $crawler->filter('body')->extract(['_text'])[0]);
$content = $em
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
@ -1629,7 +1630,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->findByUrlAndUserId($url, $this->getLoggedInUserId());
$authors = $content->getPublishedBy();
@ -1643,7 +1644,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client = $this->getClient();
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
$entry = $em->getRepository('WallabagCoreBundle:Entry')->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
$entry = $em->getRepository(Entry::class)->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
$tag = $entry->getTags()[0];
$crawler = $client->request('GET', '/view/' . $entry->getId());
@ -1720,14 +1721,14 @@ class EntryControllerTest extends WallabagCoreTestCase
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->find($entry1->getId());
$this->assertSame(1, $res->isArchived());
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->find($entry2->getId());
$this->assertSame(1, $res->isArchived());
@ -1742,14 +1743,14 @@ class EntryControllerTest extends WallabagCoreTestCase
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->find($entry1->getId());
$this->assertSame(1, $res->isStarred());
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->find($entry2->getId());
$this->assertSame(1, $res->isStarred());
@ -1765,21 +1766,21 @@ class EntryControllerTest extends WallabagCoreTestCase
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->find($entry1->getId());
$this->assertContains('foo', $res->getTagsLabel());
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->find($entry2->getId());
$this->assertContains('foo', $res->getTagsLabel());
$res = $client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->getRepository(Entry::class)
->find($entry3->getId());
$this->assertNotContains('foo', $res->getTagsLabel());