ajout méthodes random,index dans la collection, ajout clause distinct, whereNull , whereNotNull dans le querybuilder

This commit is contained in:
Gregory Letellier
2023-11-02 10:27:06 +01:00
parent fe6d2f27b8
commit 84bf765b84
5 changed files with 79 additions and 3 deletions

View File

@@ -64,6 +64,14 @@ test("querybuilder", function() {
$rows = $qb->whereRaw("id = 1")->get();
expect($rows)->toBeInstanceOf(Collection::class);
expect(count($rows))->toBe(1);
$qb->reset();
$rows = $qb->distinct()->get();
expect(count($rows))->toBe(2);
$qb->reset();
$rows = $qb->whereNotNull("col1")->get();
expect(count($rows))->toBe(2);
});
test("order by", function(){
@@ -91,6 +99,8 @@ test("group by", function(){
expect($rows->first()->Nb)->toBe(1);
});
test("update row", function() {
$qb = new QueryBuilder("test","id");
$row = $qb->find(1);
@@ -144,6 +154,22 @@ test("where array", function() {
});
test("is null", function(){
$row4 = new Model();
$row4->setTable("test");
$row4->col1 = null;
$row4->date1 = new \DateTime();
$ret4 = $row4->save();
expect($ret4)->toBe(true);
$qb = new QueryBuilder("test");
$rows = $qb->whereNull("col1")->get();
expect($rows)->toBeInstanceOf(Collection::class);
expect(count($rows))->toBe(1);
expect($rows->first()->col1)->toBe(null);
});
test("second connection", function() {
$row = new Model();
$row->setConnection("contwo");