]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
Improve tests
[github/wallabag/wallabag.git] / src / Wallabag / AnnotationBundle / Repository / AnnotationRepository.php
index c1c6e638984885e2e19608890cc24a64caefa865..7f35373f5b3853f03c5a52e7b3d71d9d1b32a8ba 100644 (file)
@@ -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();
+    }
 }