Code Duplication    Length = 9-12 lines in 12 locations

tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php 12 locations

@@ 108-119 (lines=12) @@
105
        self::assertEquals('SELECT u.*, p.* FROM users u RIGHT JOIN phones p ON p.user_id = u.id', (string) $qb);
106
    }
107
108
    public function testSelectWithAndWhereConditions()
109
    {
110
        $qb   = new QueryBuilder($this->conn);
111
        $expr = $qb->expr();
112
113
        $qb->select('u.*', 'p.*')
114
           ->from('users', 'u')
115
           ->where('u.username = ?')
116
           ->andWhere('u.name = ?');
117
118
        self::assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) AND (u.name = ?)', (string) $qb);
119
    }
120
121
    public function testSelectWithOrWhereConditions()
122
    {
@@ 121-132 (lines=12) @@
118
        self::assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) AND (u.name = ?)', (string) $qb);
119
    }
120
121
    public function testSelectWithOrWhereConditions()
122
    {
123
        $qb   = new QueryBuilder($this->conn);
124
        $expr = $qb->expr();
125
126
        $qb->select('u.*', 'p.*')
127
           ->from('users', 'u')
128
           ->where('u.username = ?')
129
           ->orWhere('u.name = ?');
130
131
        self::assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb);
132
    }
133
134
    public function testSelectWithOrOrWhereConditions()
135
    {
@@ 134-145 (lines=12) @@
131
        self::assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb);
132
    }
133
134
    public function testSelectWithOrOrWhereConditions()
135
    {
136
        $qb   = new QueryBuilder($this->conn);
137
        $expr = $qb->expr();
138
139
        $qb->select('u.*', 'p.*')
140
           ->from('users', 'u')
141
           ->orWhere('u.username = ?')
142
           ->orWhere('u.name = ?');
143
144
        self::assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb);
145
    }
146
147
    public function testSelectWithAndOrWhereConditions()
148
    {
@@ 162-172 (lines=11) @@
159
        self::assertEquals('SELECT u.*, p.* FROM users u WHERE (((u.username = ?) AND (u.username = ?)) OR (u.name = ?)) AND (u.name = ?)', (string) $qb);
160
    }
161
162
    public function testSelectGroupBy()
163
    {
164
        $qb   = new QueryBuilder($this->conn);
165
        $expr = $qb->expr();
166
167
        $qb->select('u.*', 'p.*')
168
           ->from('users', 'u')
169
           ->groupBy('u.id');
170
171
        self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id', (string) $qb);
172
    }
173
174
    public function testSelectEmptyGroupBy()
175
    {
@@ 198-209 (lines=12) @@
195
        self::assertEquals('SELECT u.*, p.* FROM users u', (string) $qb);
196
    }
197
198
    public function testSelectAddGroupBy()
199
    {
200
        $qb   = new QueryBuilder($this->conn);
201
        $expr = $qb->expr();
202
203
        $qb->select('u.*', 'p.*')
204
           ->from('users', 'u')
205
           ->groupBy('u.id')
206
           ->addGroupBy('u.foo');
207
208
        self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo', (string) $qb);
209
    }
210
211
    public function testSelectAddGroupBys()
212
    {
@@ 224-235 (lines=12) @@
221
        self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo, u.bar', (string) $qb);
222
    }
223
224
    public function testSelectHaving()
225
    {
226
        $qb   = new QueryBuilder($this->conn);
227
        $expr = $qb->expr();
228
229
        $qb->select('u.*', 'p.*')
230
           ->from('users', 'u')
231
           ->groupBy('u.id')
232
           ->having('u.name = ?');
233
234
        self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb);
235
    }
236
237
    public function testSelectAndHaving()
238
    {
@@ 237-248 (lines=12) @@
234
        self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb);
235
    }
236
237
    public function testSelectAndHaving()
238
    {
239
        $qb   = new QueryBuilder($this->conn);
240
        $expr = $qb->expr();
241
242
        $qb->select('u.*', 'p.*')
243
           ->from('users', 'u')
244
           ->groupBy('u.id')
245
           ->andHaving('u.name = ?');
246
247
        self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb);
248
    }
249
250
    public function testSelectHavingAndHaving()
251
    {
@@ 307-317 (lines=11) @@
304
        self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING ((u.name = ?) OR (u.username = ?)) AND (u.username = ?)', (string) $qb);
305
    }
306
307
    public function testSelectOrderBy()
308
    {
309
        $qb   = new QueryBuilder($this->conn);
310
        $expr = $qb->expr();
311
312
        $qb->select('u.*', 'p.*')
313
           ->from('users', 'u')
314
           ->orderBy('u.name');
315
316
        self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC', (string) $qb);
317
    }
318
319
    public function testSelectAddOrderBy()
320
    {
@@ 375-386 (lines=12) @@
372
        self::assertEquals(QueryBuilder::SELECT, $qb->getType());
373
    }
374
375
    public function testSelectMultipleFrom()
376
    {
377
        $qb   = new QueryBuilder($this->conn);
378
        $expr = $qb->expr();
379
380
        $qb->select('u.*')
381
           ->addSelect('p.*')
382
           ->from('users', 'u')
383
           ->from('phonenumbers', 'p');
384
385
        self::assertEquals('SELECT u.*, p.* FROM users u, phonenumbers p', (string) $qb);
386
    }
387
388
    public function testUpdate()
389
    {
@@ 388-397 (lines=10) @@
385
        self::assertEquals('SELECT u.*, p.* FROM users u, phonenumbers p', (string) $qb);
386
    }
387
388
    public function testUpdate()
389
    {
390
        $qb   = new QueryBuilder($this->conn);
391
        $qb->update('users', 'u')
392
           ->set('u.foo', '?')
393
           ->set('u.bar', '?');
394
395
        self::assertEquals(QueryBuilder::UPDATE, $qb->getType());
396
        self::assertEquals('UPDATE users u SET u.foo = ?, u.bar = ?', (string) $qb);
397
    }
398
399
    public function testUpdateWithoutAlias()
400
    {
@@ 409-417 (lines=9) @@
406
        self::assertEquals('UPDATE users SET foo = ?, bar = ?', (string) $qb);
407
    }
408
409
    public function testUpdateWhere()
410
    {
411
        $qb   = new QueryBuilder($this->conn);
412
        $qb->update('users', 'u')
413
           ->set('u.foo', '?')
414
           ->where('u.foo = ?');
415
416
        self::assertEquals('UPDATE users u SET u.foo = ? WHERE u.foo = ?', (string) $qb);
417
    }
418
419
    public function testEmptyUpdate()
420
    {
@@ 576-585 (lines=10) @@
573
        self::assertEQuals(10, $qb->getFirstResult());
574
    }
575
576
    public function testResetQueryPart()
577
    {
578
        $qb   = new QueryBuilder($this->conn);
579
580
        $qb->select('u.*')->from('users', 'u')->where('u.name = ?');
581
582
        self::assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string)$qb);
583
        $qb->resetQueryPart('where');
584
        self::assertEquals('SELECT u.* FROM users u', (string)$qb);
585
    }
586
587
    public function testResetQueryParts()
588
    {