Fix the way to remove a tag from all user entries

This commit is contained in:
Jeremy Benoist
2015-12-29 15:08:33 +01:00
parent 1bb1939ab7
commit 4059a061c0
3 changed files with 53 additions and 10 deletions

View File

@ -310,5 +310,12 @@ class WallabagRestControllerTest extends WallabagApiTestCase
$this->assertArrayHasKey('label', $content);
$this->assertEquals($tag['label'], $content['label']);
$this->assertEquals($tag['slug'], $content['slug']);
$entries = $entry = $this->client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Entry')
->findAllByTagId($this->user->getId(), $tag['id']);
$this->assertCount(0, $entries);
}
}

View File

@ -12,6 +12,11 @@ abstract class WallabagApiTestCase extends WebTestCase
*/
protected $client = null;
/**
* @var \FOS\UserBundle\Model\UserInterface
*/
protected $user;
public function setUp()
{
$this->client = $this->createAuthorizedClient();
@ -31,8 +36,8 @@ abstract class WallabagApiTestCase extends WebTestCase
$loginManager = $container->get('fos_user.security.login_manager');
$firewallName = $container->getParameter('fos_user.firewall_name');
$user = $userManager->findUserBy(array('username' => 'admin'));
$loginManager->loginUser($firewallName, $user);
$this->user = $userManager->findUserBy(array('username' => 'admin'));
$loginManager->loginUser($firewallName, $this->user);
// save the login token into the session and put it in a cookie
$container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));