aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/TagControllerTest.php38
1 files changed, 31 insertions, 7 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
index 47c83a7b..20e60c32 100644
--- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
@@ -179,15 +179,24 @@ class TagControllerTest extends WallabagCoreTestCase
179 179
180 public function testRenameTagUsingTheFormInsideTagList() 180 public function testRenameTagUsingTheFormInsideTagList()
181 { 181 {
182 $newTagLabel = 'rename label';
183
182 $this->logInAs('admin'); 184 $this->logInAs('admin');
183 $client = $this->getClient(); 185 $client = $this->getClient();
184 186
185 $tag = new Tag(); 187 $tag = new Tag();
186 $tag->setLabel($this->tagName); 188 $tag->setLabel($this->tagName);
189
187 $entry = new Entry($this->getLoggedInUser()); 190 $entry = new Entry($this->getLoggedInUser());
188 $entry->setUrl('http://0.0.0.0/foo'); 191 $entry->setUrl('http://0.0.0.0/foo');
189 $entry->addTag($tag); 192 $entry->addTag($tag);
190 $this->getEntityManager()->persist($entry); 193 $this->getEntityManager()->persist($entry);
194
195 $entry2 = new Entry($this->getLoggedInUser());
196 $entry2->setUrl('http://0.0.0.0/bar');
197 $entry2->addTag($tag);
198 $this->getEntityManager()->persist($entry);
199
191 $this->getEntityManager()->flush(); 200 $this->getEntityManager()->flush();
192 $this->getEntityManager()->clear(); 201 $this->getEntityManager()->clear();
193 202
@@ -196,7 +205,7 @@ class TagControllerTest extends WallabagCoreTestCase
196 $form = $crawler->filter('#tag-' . $tag->getId() . ' form')->form(); 205 $form = $crawler->filter('#tag-' . $tag->getId() . ' form')->form();
197 206
198 $data = [ 207 $data = [
199 'tag[label]' => 'specific label', 208 'tag[label]' => $newTagLabel,
200 ]; 209 ];
201 210
202 $client->submit($form, $data); 211 $client->submit($form, $data);
@@ -207,19 +216,34 @@ class TagControllerTest extends WallabagCoreTestCase
207 ->getRepository('WallabagCoreBundle:Entry') 216 ->getRepository('WallabagCoreBundle:Entry')
208 ->find($entry->getId()); 217 ->find($entry->getId());
209 218
210 $tags = $freshEntry->getTags()->toArray(); 219 $freshEntry2 = $client->getContainer()
211 foreach ($tags as $key => $item) { 220 ->get('doctrine.orm.entity_manager')
221 ->getRepository('WallabagCoreBundle:Entry')
222 ->find($entry2->getId());
223
224 $tags = [];
225
226 $tagsFromEntry = $freshEntry->getTags()->toArray();
227 foreach ($tagsFromEntry as $key => $item) {
212 $tags[$key] = $item->getLabel(); 228 $tags[$key] = $item->getLabel();
213 } 229 }
214 230
215 $this->assertFalse(array_search($tag->getLabel(), $tags, true), 'Previous tag is not attach to entry anymore.'); 231 $tagsFromEntry2 = $freshEntry2->getTags()->toArray();
232 foreach ($tagsFromEntry2 as $key => $item) {
233 $tags[$key] = $item->getLabel();
234 }
235
236 $this->assertFalse(array_search($tag->getLabel(), $tags, true), 'Previous tag is not attach to entries anymore.');
216 237
217 $newTag = $client->getContainer() 238 $newTag = $client->getContainer()
218 ->get('doctrine.orm.entity_manager') 239 ->get('doctrine.orm.entity_manager')
219 ->getRepository('WallabagCoreBundle:Tag') 240 ->getRepository('WallabagCoreBundle:Tag')
220 ->findOneByLabel('specific label'); 241 ->findByLabel($newTagLabel);
221 $this->assertInstanceOf(Tag::class, $newTag, 'Tag "specific label" exists.'); 242
222 $this->assertTrue($newTag->hasEntry($freshEntry), 'Tag "specific label" is assigned to the entry.'); 243 $this->assertCount(1, $newTag, 'New tag exists.');
244
245 $this->assertTrue($newTag[0]->hasEntry($freshEntry), 'New tag is assigned to the entry.');
246 $this->assertTrue($newTag[0]->hasEntry($freshEntry2), 'New tag is assigned to the entry2.');
223 } 247 }
224 248
225 public function testAddUnicodeTagLabel() 249 public function testAddUnicodeTagLabel()