@@ 82-99 (lines=18) @@ | ||
79 | $this->assertCount(3, $translations); |
|
80 | } |
|
81 | ||
82 | public function testTranslationFieldFilter() |
|
83 | { |
|
84 | $qb = $this->em->createQueryBuilder() |
|
85 | ->select('o') |
|
86 | ->from(self::ARTICLE, 'o'); |
|
87 | $builder = new ProxyQuery($qb); |
|
88 | ||
89 | $filter = new TranslationFieldFilter(); |
|
90 | $filter->initialize('title'); |
|
91 | ||
92 | $filter->filter($builder, 'o', 'title', array('type' => null, 'value' => 'foo')); |
|
93 | $this->assertEquals( |
|
94 | 'SELECT o FROM '.self::ARTICLE.' o LEFT JOIN o.translations tff' |
|
95 | ." WHERE (tff.field = 'title' AND tff.content LIKE '%foo%') OR o.title LIKE '%foo%'", |
|
96 | $builder->getDQL() |
|
97 | ); |
|
98 | $this->assertTrue($filter->isActive()); |
|
99 | } |
|
100 | ||
101 | public function testTranslationFieldFilterWithoutValue() |
|
102 | { |
|
@@ 101-117 (lines=17) @@ | ||
98 | $this->assertTrue($filter->isActive()); |
|
99 | } |
|
100 | ||
101 | public function testTranslationFieldFilterWithoutValue() |
|
102 | { |
|
103 | $qb = $this->em->createQueryBuilder() |
|
104 | ->select('o') |
|
105 | ->from(self::ARTICLE, 'o'); |
|
106 | $builder = new ProxyQuery($qb); |
|
107 | ||
108 | $filter = new TranslationFieldFilter(); |
|
109 | $filter->initialize('title'); |
|
110 | ||
111 | $filter->filter($builder, 'o', 'title', array('type' => null, 'value' => null)); |
|
112 | $this->assertEquals( |
|
113 | 'SELECT o FROM '.self::ARTICLE.' o', |
|
114 | $builder->getDQL() |
|
115 | ); |
|
116 | $this->assertFalse($filter->isActive()); |
|
117 | } |
|
118 | ||
119 | public function testTranslationFieldFilterIfAlreadyJoined() |
|
120 | { |
|
@@ 119-137 (lines=19) @@ | ||
116 | $this->assertFalse($filter->isActive()); |
|
117 | } |
|
118 | ||
119 | public function testTranslationFieldFilterIfAlreadyJoined() |
|
120 | { |
|
121 | $qb = $this->em->createQueryBuilder() |
|
122 | ->select('o') |
|
123 | ->from(self::ARTICLE, 'o') |
|
124 | ->leftJoin('o.translations', 'tff'); |
|
125 | $builder = new ProxyQuery($qb); |
|
126 | ||
127 | $filter = new TranslationFieldFilter(); |
|
128 | $filter->initialize('title'); |
|
129 | ||
130 | $filter->filter($builder, 'o', 'title', array('type' => null, 'value' => 'foo')); |
|
131 | $this->assertEquals( |
|
132 | 'SELECT o FROM '.self::ARTICLE.' o LEFT JOIN o.translations tff' |
|
133 | ." WHERE (tff.field = 'title' AND tff.content LIKE '%foo%') OR o.title LIKE '%foo%'", |
|
134 | $builder->getDQL() |
|
135 | ); |
|
136 | $this->assertTrue($filter->isActive()); |
|
137 | } |
|
138 | ||
139 | protected function getUsedEntityFixtures() |
|
140 | { |