public function testTranslatableWhereOnCollectionWithArray() { $category1 = new Category(); $category1->setId(1); $category2 = new Category(); $category2->setId(2); $whereCategories = array($category1, $category2); $qb = new QueryBuilder($this->_em); $qb->select('a'); $qb->from(self::ARTICLE, 'a'); $qb->addTranslatableWhere('a', 'categories', $whereCategories); $this->assertEquals($this->normalizeDql(sprintf(' SELECT a FROM %s a LEFT JOIN a.categories acategoriesjoin WHERE acategoriesjoin IN(:acategoriesval)', self::ARTICLE)), $qb->getDQL()); $this->assertEquals($whereCategories, $qb->getParameter('acategoriesval')->getValue()); $qb->getQuery()->execute(); }
public function addCategory(Category $category) { $this->categories[] = $category; $category->addArticle($this); }
private function fillDataForFindTranslatable() { /** @var \FSi\DoctrineExtensions\Translatable\Entity\Repository\TranslatableRepository $repository */ $repository = $this->_em->getRepository(self::ARTICLE); $article1 = new Article(); $this->_em->persist($article1); $article1->setDate(new \DateTime('2014-01-01 00:00:00')); $translationEn = $repository->getTranslation($article1, $this->_languageEn); $translationEn->setTitle(self::ENGLISH_TITLE_1); $translationEn->setIntroduction(self::ENGLISH_TEASER); $translationEn->setContents(self::ENGLISH_CONTENTS_1); $this->_em->persist($translationEn); $article2 = new Article(); $this->_em->persist($article2); $article2->setDate(new \DateTime('2014-02-02 00:00:00')); $translationPl = $repository->getTranslation($article2, $this->_languagePl); $translationPl->setTitle(self::POLISH_TITLE_1); $translationPl->setIntroduction(self::POLISH_TEASER); $translationPl->setContents(self::POLISH_CONTENTS_1); $this->_em->persist($translationPl); $category1 = new Category(); $category1->setTitle(self::CATEGORY_1); $article1->addCategory($category1); $article2->addCategory($category1); $this->_em->persist($category1); $section = new Section(); $section->setTitle(self::SECTION_1); $article1->setSection($section); $article2->setSection($section); $this->_em->persist($section); $comment = new Comment(); $comment->setContent('Lorem'); $comment->setDate(new \DateTime()); $comment->setArticleTranslation($translationPl); $this->_em->persist($comment); $comment = new Comment(); $comment->setContent('Ipsum'); $comment->setDate(new \DateTime()); $comment->setArticleTranslation($translationPl); $this->_em->persist($comment); $this->_em->flush(); $this->_em->refresh($article1); $this->_em->refresh($article2); }