aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/TagControllerTest.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
index 20e60c32..80903b95 100644
--- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
@@ -211,6 +211,10 @@ class TagControllerTest extends WallabagCoreTestCase
211 $client->submit($form, $data); 211 $client->submit($form, $data);
212 $this->assertSame(302, $client->getResponse()->getStatusCode()); 212 $this->assertSame(302, $client->getResponse()->getStatusCode());
213 213
214 $crawler = $client->followRedirect();
215
216 $this->assertContains('flashes.tag.notice.tag_renamed', $crawler->filter('body')->extract(['_text'])[0]);
217
214 $freshEntry = $client->getContainer() 218 $freshEntry = $client->getContainer()
215 ->get('doctrine.orm.entity_manager') 219 ->get('doctrine.orm.entity_manager')
216 ->getRepository('WallabagCoreBundle:Entry') 220 ->getRepository('WallabagCoreBundle:Entry')
@@ -246,6 +250,60 @@ class TagControllerTest extends WallabagCoreTestCase
246 $this->assertTrue($newTag[0]->hasEntry($freshEntry2), 'New tag is assigned to the entry2.'); 250 $this->assertTrue($newTag[0]->hasEntry($freshEntry2), 'New tag is assigned to the entry2.');
247 } 251 }
248 252
253 public function testRenameTagWithSameLabel()
254 {
255 $tagLabel = 'same label';
256 $this->logInAs('admin');
257 $client = $this->getClient();
258
259 $tag = new Tag();
260 $tag->setLabel($tagLabel);
261
262 $entry = new Entry($this->getLoggedInUser());
263 $entry->setUrl('http://0.0.0.0/foobar');
264 $entry->addTag($tag);
265 $this->getEntityManager()->persist($entry);
266
267 $this->getEntityManager()->flush();
268 $this->getEntityManager()->clear();
269
270 // We make a first request to set an history and test redirection after tag deletion
271 $crawler = $client->request('GET', '/tag/list');
272 $form = $crawler->filter('#tag-' . $tag->getId() . ' form')->form();
273
274 $data = [
275 'tag[label]' => $tagLabel,
276 ];
277
278 $client->submit($form, $data);
279 $this->assertSame(302, $client->getResponse()->getStatusCode());
280 $this->assertNotContains('flashes.tag.notice.tag_renamed', $crawler->filter('body')->extract(['_text'])[0]);
281
282 $freshEntry = $client->getContainer()
283 ->get('doctrine.orm.entity_manager')
284 ->getRepository('WallabagCoreBundle:Entry')
285 ->find($entry->getId());
286
287 $tags = [];
288
289 $tagsFromEntry = $freshEntry->getTags()->toArray();
290 foreach ($tagsFromEntry as $key => $item) {
291 $tags[$key] = $item->getLabel();
292 }
293
294 $this->assertNotFalse(array_search($tag->getLabel(), $tags, true), 'Tag is still assigned to the entry.');
295
296 $newTag = $client->getContainer()
297 ->get('doctrine.orm.entity_manager')
298 ->getRepository('WallabagCoreBundle:Tag')
299 ->findByLabel($tagLabel);
300
301 $this->assertCount(1, $newTag);
302 $this->assertSame($tag->getId(), $newTag[0]->getId(), 'Tag is unchanged.');
303
304 $this->assertTrue($newTag[0]->hasEntry($freshEntry), 'Tag is still assigned to the entry.');
305 }
306
249 public function testAddUnicodeTagLabel() 307 public function testAddUnicodeTagLabel()
250 { 308 {
251 $this->logInAs('admin'); 309 $this->logInAs('admin');