mirror of
https://github.com/wallabag/wallabag.git
synced 2025-10-10 19:32:07 +00:00
Merge pull request #1372 from wallabag/v2-assign-tags
assign tags to an entry
This commit is contained in:
commit
ec00964de2
9 changed files with 186 additions and 2 deletions
|
@ -15,4 +15,54 @@ class TagControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function testAddTagToEntry()
|
||||
{
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getClient();
|
||||
|
||||
$entry = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneByIsArchived(false);
|
||||
|
||||
$crawler = $client->request('GET', '/view/'.$entry->getId());
|
||||
|
||||
$form = $crawler->filter('button[id=tag_save]')->form();
|
||||
|
||||
$data = array(
|
||||
'tag[label]' => 'opensource',
|
||||
);
|
||||
|
||||
$client->submit($form, $data);
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
|
||||
$this->assertEquals(1, count($entry->getTags()));
|
||||
|
||||
# tag already exists and already assigned
|
||||
$client->submit($form, $data);
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
|
||||
$newEntry = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneById($entry->getId());
|
||||
|
||||
$this->assertEquals(1, count($newEntry->getTags()));
|
||||
|
||||
# tag already exists but still not assigned to this entry
|
||||
$data = array(
|
||||
'tag[label]' => 'foo',
|
||||
);
|
||||
|
||||
$client->submit($form, $data);
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
|
||||
$newEntry = $client->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
->getRepository('WallabagCoreBundle:Entry')
|
||||
->findOneById($entry->getId());
|
||||
|
||||
$this->assertEquals(2, count($newEntry->getTags()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue