22
33declare (strict_types=1 );
44
5- namespace Doctrine \Tests \ORM \Query ;
5+ namespace Doctrine \Tests \ORM \Functional \ Ticket ;
66
77use Doctrine \Tests \Models \CMS \CmsUser ;
88use Doctrine \Tests \OrmFunctionalTestCase ;
9+ use PHPUnit \Framework \Attributes \Group ;
910
1011/**
1112 * Test cases for DQL expressions involving CASE, COALESCE, NULLIF, and arithmetic
1213 * especially when used with IN / NOT IN operators.
1314 */
14- class QueryBuilderInOperatorTest extends OrmFunctionalTestCase
15+ #[Group('GH-12178 ' )]
16+ class GH12178Test extends OrmFunctionalTestCase
1517{
1618 protected function setUp (): void
1719 {
18- parent :: setUp ( );
20+ $ this -> useModelSet ( ' cms ' );
1921
20- $ this ->setUpEntitySchema ([
21- CmsUser::class,
22- ]);
22+ parent ::setUp ();
2323 }
2424
2525 /**
@@ -38,7 +38,7 @@ public function testCaseWhenWithInOperator(): void
3838 $ query ->setParameter ('values ' , [0 , 1 ]);
3939
4040 $ sql = $ query ->getSQL ();
41- $ this -> assertNotEmpty ($ sql );
41+ self :: assertNotEmpty ($ sql );
4242 }
4343
4444 /**
@@ -54,22 +54,7 @@ public function testSimpleCaseWhenWithIn(): void
5454 $ query ->setParameter ('ids ' , [1 , 2 , 3 ]);
5555
5656 $ sql = $ query ->getSQL ();
57- $ this ->assertNotEmpty ($ sql );
58- }
59-
60- /**
61- * CASE expression with comparison operator
62- */
63- public function testCaseWhenWithEqualsOperator (): void
64- {
65- $ dql = 'SELECT u FROM ' . CmsUser::class . ' u
66- WHERE CASE WHEN u.id = 1 THEN 0 ELSE 1 END = :value ' ;
67-
68- $ query = $ this ->_em ->createQuery ($ dql );
69- $ query ->setParameter ('value ' , 0 );
70-
71- $ sql = $ query ->getSQL ();
72- $ this ->assertNotEmpty ($ sql );
57+ self ::assertNotEmpty ($ sql );
7358 }
7459
7560 /**
@@ -85,23 +70,7 @@ public function testCaseWhenWithNotIn(): void
8570 $ query ->setParameter ('values ' , [0 ]);
8671
8772 $ sql = $ query ->getSQL ();
88- $ this ->assertNotEmpty ($ sql );
89- }
90-
91- /**
92- * CASE in SELECT with IN in WHERE
93- */
94- public function testCaseInSelectWithInInWhere (): void
95- {
96- $ dql = 'SELECT u, CASE WHEN u.id = 1 THEN 1 ELSE 0 END AS isFirst
97- FROM ' . CmsUser::class . ' u
98- WHERE u.id IN (:ids) ' ;
99-
100- $ query = $ this ->_em ->createQuery ($ dql );
101- $ query ->setParameter ('ids ' , [1 , 2 , 3 ]);
102-
103- $ sql = $ query ->getSQL ();
104- $ this ->assertNotEmpty ($ sql );
73+ self ::assertNotEmpty ($ sql );
10574 }
10675
10776 /**
@@ -121,7 +90,7 @@ public function testNestedCaseWithIn(): void
12190 $ query ->setParameter ('values ' , [1 , 2 , 3 ]);
12291
12392 $ sql = $ query ->getSQL ();
124- $ this -> assertNotEmpty ($ sql );
93+ self :: assertNotEmpty ($ sql );
12594 }
12695
12796 /**
@@ -136,7 +105,7 @@ public function testCoalesceWithIn(): void
136105 $ query ->setParameter ('ids ' , [1 , 2 , 3 ]);
137106
138107 $ sql = $ query ->getSQL ();
139- $ this -> assertNotEmpty ($ sql );
108+ self :: assertNotEmpty ($ sql );
140109 }
141110
142111 /**
@@ -151,7 +120,7 @@ public function testArithmeticExpressionWithIn(): void
151120 $ query ->setParameter ('ids ' , [1 , 2 , 3 ]);
152121
153122 $ sql = $ query ->getSQL ();
154- $ this -> assertNotEmpty ($ sql );
123+ self :: assertNotEmpty ($ sql );
155124 }
156125
157126 /**
@@ -166,7 +135,7 @@ public function testParenthesizedExpressionWithNotIn(): void
166135 $ query ->setParameter ('ids ' , [2 , 3 , 4 ]);
167136
168137 $ sql = $ query ->getSQL ();
169- $ this -> assertNotEmpty ($ sql );
138+ self :: assertNotEmpty ($ sql );
170139 }
171140
172141 /**
@@ -181,7 +150,7 @@ public function testNullIfWithIn(): void
181150 $ query ->setParameter ('ids ' , [1 , 2 ]);
182151
183152 $ sql = $ query ->getSQL ();
184- $ this -> assertNotEmpty ($ sql );
153+ self :: assertNotEmpty ($ sql );
185154 }
186155
187156 /**
@@ -196,6 +165,6 @@ public function testNestedCoalesceWithIn(): void
196165 $ query ->setParameter ('ids ' , [0 , 1 , 2 ]);
197166
198167 $ sql = $ query ->getSQL ();
199- $ this -> assertNotEmpty ($ sql );
168+ self :: assertNotEmpty ($ sql );
200169 }
201170}
0 commit comments