add static method to get inherited class querybuilder from model, add isset method in model
This commit is contained in:
@@ -91,7 +91,21 @@ test("querybuilder", function() {
|
||||
|
||||
$qb->reset();
|
||||
$rows = $qb->whereNotNull("col1")->get();
|
||||
expect(count($rows))->toBe(2);
|
||||
expect(count($rows))->toBe(2);
|
||||
});
|
||||
|
||||
test("extending model",function()
|
||||
{
|
||||
$class = "Test";
|
||||
$code = "class $class extends \Kletellier\PdoWrapper\Model {}";
|
||||
eval($code);
|
||||
|
||||
$qbs = Test::q();
|
||||
expect($qbs)->toBeInstanceOf(QueryBuilder::class);
|
||||
|
||||
$row = $qbs->find(1);
|
||||
expect($row->id)->toBe(1);
|
||||
expect($row->col1)->toBe("test");
|
||||
});
|
||||
|
||||
test("order by", function(){
|
||||
@@ -119,7 +133,18 @@ test("group by", function(){
|
||||
expect($rows->first()->Nb)->toBe(1);
|
||||
});
|
||||
|
||||
test("isset",function()
|
||||
{
|
||||
$q = new QueryBuilder("test");
|
||||
$row = $q->where("id",1)->get()->first();
|
||||
|
||||
expect($row->id)->toBe(1);
|
||||
expect($row->col1)->toBe("test");
|
||||
|
||||
expect(isset($row->col1))->toBe(true);
|
||||
expect(isset($row->col2))->toBe(false);
|
||||
expect(isset($row->find))->toBe(true);
|
||||
});
|
||||
|
||||
test("update row", function() {
|
||||
$qb = new QueryBuilder("test","id");
|
||||
|
||||
Reference in New Issue
Block a user