diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2019-05-29 11:14:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-29 11:14:00 +0200 |
commit | 73ec68b1ffafb792265a3805833e5cd84c966aed (patch) | |
tree | 33c6040c050f85c537f8dbf5e91d8c281db092cd /tests/Wallabag/CoreBundle/Controller/TagControllerTest.php | |
parent | 2ba365c7c49556cd23b444dc3bb8d4a8cf08809d (diff) | |
parent | 2cbee36a0184786644470a84fdd8c720cfcac58e (diff) | |
download | wallabag-73ec68b1ffafb792265a3805833e5cd84c966aed.tar.gz wallabag-73ec68b1ffafb792265a3805833e5cd84c966aed.tar.zst wallabag-73ec68b1ffafb792265a3805833e5cd84c966aed.zip |
Merge pull request #3984 from wallabag/2.4
Merge 2.4 into master
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller/TagControllerTest.php')
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/TagControllerTest.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php index 768f4c07..be17dcf5 100644 --- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php | |||
@@ -176,4 +176,49 @@ class TagControllerTest extends WallabagCoreTestCase | |||
176 | $em->remove($tag); | 176 | $em->remove($tag); |
177 | $em->flush(); | 177 | $em->flush(); |
178 | } | 178 | } |
179 | |||
180 | public function testRenameTagUsingTheFormInsideTagList() | ||
181 | { | ||
182 | $this->logInAs('admin'); | ||
183 | $client = $this->getClient(); | ||
184 | |||
185 | $tag = new Tag(); | ||
186 | $tag->setLabel($this->tagName); | ||
187 | $entry = new Entry($this->getLoggedInUser()); | ||
188 | $entry->setUrl('http://0.0.0.0/foo'); | ||
189 | $entry->addTag($tag); | ||
190 | $this->getEntityManager()->persist($entry); | ||
191 | $this->getEntityManager()->flush(); | ||
192 | $this->getEntityManager()->clear(); | ||
193 | |||
194 | // We make a first request to set an history and test redirection after tag deletion | ||
195 | $crawler = $client->request('GET', '/tag/list'); | ||
196 | $form = $crawler->filter('#tag-' . $tag->getId() . ' form')->form(); | ||
197 | |||
198 | $data = [ | ||
199 | 'tag[label]' => 'specific label', | ||
200 | ]; | ||
201 | |||
202 | $client->submit($form, $data); | ||
203 | $this->assertSame(302, $client->getResponse()->getStatusCode()); | ||
204 | |||
205 | $freshEntry = $client->getContainer() | ||
206 | ->get('doctrine.orm.entity_manager') | ||
207 | ->getRepository('WallabagCoreBundle:Entry') | ||
208 | ->find($entry->getId()); | ||
209 | |||
210 | $tags = $freshEntry->getTags()->toArray(); | ||
211 | foreach ($tags as $key => $item) { | ||
212 | $tags[$key] = $item->getLabel(); | ||
213 | } | ||
214 | |||
215 | $this->assertFalse(array_search($tag->getLabel(), $tags, true), 'Previous tag is not attach to entry anymore.'); | ||
216 | |||
217 | $newTag = $client->getContainer() | ||
218 | ->get('doctrine.orm.entity_manager') | ||
219 | ->getRepository('WallabagCoreBundle:Tag') | ||
220 | ->findOneByLabel('specific label'); | ||
221 | $this->assertInstanceOf(Tag::class, $newTag, 'Tag "specific label" exists.'); | ||
222 | $this->assertTrue($newTag->hasEntry($freshEntry), 'Tag "specific label" is assigned to the entry.'); | ||
223 | } | ||
179 | } | 224 | } |