Skip to content

Commit 7d515e5

Browse files
committed
clean up testFirstAggregate
1 parent 0d272bb commit 7d515e5

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

tests/system/Database/Live/ModelTest.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -254,33 +254,34 @@ public function testFirst()
254254
public function provideGroupBy()
255255
{
256256
return [
257-
[true],
258-
[false],
257+
[
258+
true,
259+
3,
260+
],
261+
[
262+
false,
263+
7,
264+
],
259265
];
260266
}
261267

262268
/**
263269
* @dataProvider provideGroupBy
264270
*/
265-
public function testFirstAggregate($groupBy)
271+
public function testFirstAggregate($groupBy, $total)
266272
{
267273
$model = new UserModel();
268274

269275
if ($groupBy)
270276
{
271-
$user = $model->select('SUM(id) as total')
272-
->where('id >', 2)
273-
->groupBy('id')
274-
->first();
275-
$this->assertEquals(3, $user->total);
276-
}
277-
else
278-
{
279-
$user = $model->select('SUM(id) as total')
280-
->where('id >', 2)
281-
->first();
282-
$this->assertEquals(7, $user->total);
277+
$model->groupBy('id');
283278
}
279+
280+
$user = $model->select('SUM(id) as total')
281+
->where('id >', 2)
282+
->first();
283+
284+
$this->assertEquals($total, $user->total);
284285
}
285286

286287
//--------------------------------------------------------------------

0 commit comments

Comments
 (0)