From 09d8bb6fa26b881da478df4c7b97620cb7aea0d0 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 11 Mar 2016 17:56:41 +0100 Subject: Improve tests - add more tests for coverage - add a test on annotation deletion - fix post annontation with ranges --- .../Repository/AnnotationRepository.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php') diff --git a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php index c1c6e638..7f35373f 100644 --- a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php +++ b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php @@ -88,4 +88,21 @@ class AnnotationRepository extends EntityRepository ->getQuery() ->getOneOrNullResult(); } + + /** + * Used only in test case to get the right annotation associated to the right user. + * + * @param string $username + * + * @return Annotation + */ + public function findOneByUsername($username) + { + return $this->createQueryBuilder('a') + ->leftJoin('a.user', 'u') + ->where('u.username = :username')->setParameter('username', $username) + ->setMaxResults(1) + ->getQuery() + ->getSingleResult(); + } } -- cgit v1.2.3 From b95ffda2a105af4c6f4f86aca025a0bf967bc86a Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 12 Mar 2016 10:45:14 +0100 Subject: Fix hazardous bug with Postgres Instead of retrieving a random annotation, sort them to be sure they are all the same no matter the database used --- src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php') diff --git a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php index 7f35373f..5f7da70e 100644 --- a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php +++ b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php @@ -101,6 +101,7 @@ class AnnotationRepository extends EntityRepository return $this->createQueryBuilder('a') ->leftJoin('a.user', 'u') ->where('u.username = :username')->setParameter('username', $username) + ->orderBy('a.id', 'DESC') ->setMaxResults(1) ->getQuery() ->getSingleResult(); -- cgit v1.2.3