From 531c8d0a5c55fa93438e227a7d349235fbd31d28 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 13 Jun 2017 18:48:10 +0200 Subject: Changed RSS to Atom feed and improve paging --- .../UsernameRssTokenConverterTest.php | 218 --------------------- 1 file changed, 218 deletions(-) delete mode 100644 tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php (limited to 'tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php') diff --git a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php deleted file mode 100644 index 800af5c9..00000000 --- a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php +++ /dev/null @@ -1,218 +0,0 @@ -assertFalse($converter->supports($params)); - } - - public function testSupportsWithNoRegistryManagers() - { - $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') - ->disableOriginalConstructor() - ->getMock(); - - $registry->expects($this->once()) - ->method('getManagers') - ->will($this->returnValue([])); - - $params = new ParamConverter([]); - $converter = new UsernameRssTokenConverter($registry); - - $this->assertFalse($converter->supports($params)); - } - - public function testSupportsWithNoConfigurationClass() - { - $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') - ->disableOriginalConstructor() - ->getMock(); - - $registry->expects($this->once()) - ->method('getManagers') - ->will($this->returnValue(['default' => null])); - - $params = new ParamConverter([]); - $converter = new UsernameRssTokenConverter($registry); - - $this->assertFalse($converter->supports($params)); - } - - public function testSupportsWithNotTheGoodClass() - { - $meta = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata') - ->disableOriginalConstructor() - ->getMock(); - - $meta->expects($this->once()) - ->method('getName') - ->will($this->returnValue('nothingrelated')); - - $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); - - $em->expects($this->once()) - ->method('getClassMetadata') - ->with('superclass') - ->will($this->returnValue($meta)); - - $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') - ->disableOriginalConstructor() - ->getMock(); - - $registry->expects($this->once()) - ->method('getManagers') - ->will($this->returnValue(['default' => null])); - - $registry->expects($this->once()) - ->method('getManagerForClass') - ->with('superclass') - ->will($this->returnValue($em)); - - $params = new ParamConverter(['class' => 'superclass']); - $converter = new UsernameRssTokenConverter($registry); - - $this->assertFalse($converter->supports($params)); - } - - public function testSupportsWithGoodClass() - { - $meta = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata') - ->disableOriginalConstructor() - ->getMock(); - - $meta->expects($this->once()) - ->method('getName') - ->will($this->returnValue('Wallabag\UserBundle\Entity\User')); - - $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); - - $em->expects($this->once()) - ->method('getClassMetadata') - ->with('WallabagUserBundle:User') - ->will($this->returnValue($meta)); - - $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') - ->disableOriginalConstructor() - ->getMock(); - - $registry->expects($this->once()) - ->method('getManagers') - ->will($this->returnValue(['default' => null])); - - $registry->expects($this->once()) - ->method('getManagerForClass') - ->with('WallabagUserBundle:User') - ->will($this->returnValue($em)); - - $params = new ParamConverter(['class' => 'WallabagUserBundle:User']); - $converter = new UsernameRssTokenConverter($registry); - - $this->assertTrue($converter->supports($params)); - } - - public function testApplyEmptyRequest() - { - $params = new ParamConverter([]); - $converter = new UsernameRssTokenConverter(); - - $res = $converter->apply(new Request(), $params); - - $this->assertFalse($res); - } - - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - * @expectedExceptionMessage User not found - */ - public function testApplyUserNotFound() - { - $repo = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository') - ->disableOriginalConstructor() - ->getMock(); - - $repo->expects($this->once()) - ->method('findOneByUsernameAndRsstoken') - ->with('test', 'test') - ->will($this->returnValue(null)); - - $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); - - $em->expects($this->once()) - ->method('getRepository') - ->with('WallabagUserBundle:User') - ->will($this->returnValue($repo)); - - $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') - ->disableOriginalConstructor() - ->getMock(); - - $registry->expects($this->once()) - ->method('getManagerForClass') - ->with('WallabagUserBundle:User') - ->will($this->returnValue($em)); - - $params = new ParamConverter(['class' => 'WallabagUserBundle:User']); - $converter = new UsernameRssTokenConverter($registry); - $request = new Request([], [], ['username' => 'test', 'token' => 'test']); - - $converter->apply($request, $params); - } - - public function testApplyUserFound() - { - $user = new User(); - - $repo = $this->getMockBuilder('Wallabag\UserBundle\Repository\UserRepository') - ->disableOriginalConstructor() - ->getMock(); - - $repo->expects($this->once()) - ->method('findOneByUsernameAndRsstoken') - ->with('test', 'test') - ->will($this->returnValue($user)); - - $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); - - $em->expects($this->once()) - ->method('getRepository') - ->with('WallabagUserBundle:User') - ->will($this->returnValue($repo)); - - $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry') - ->disableOriginalConstructor() - ->getMock(); - - $registry->expects($this->once()) - ->method('getManagerForClass') - ->with('WallabagUserBundle:User') - ->will($this->returnValue($em)); - - $params = new ParamConverter(['class' => 'WallabagUserBundle:User', 'name' => 'user']); - $converter = new UsernameRssTokenConverter($registry); - $request = new Request([], [], ['username' => 'test', 'token' => 'test']); - - $converter->apply($request, $params); - - $this->assertSame($user, $request->attributes->get('user')); - } -} -- cgit v1.2.3