/** * @test */ public function shouldCreateSql() { //given $restriction = Restrictions::isNull(); //when $sql = $restriction->toSql('category_id'); //then $this->assertEquals('category_id IS NULL', $sql); }
/** * @test */ public function shouldReturnModelUsingIsNullRestriction() { //given Product::create(array('name' => 'tech', 'description' => 'some desc')); $product = Product::create(array('name' => 'tech')); //when $loadedProduct = Product::where(array('description' => Restrictions::isNull()))->fetch(); //then Assert::thatModel($loadedProduct)->isEqualTo($product); }
public function __construct($where, $operator = 'AND') { foreach ($where as $column => $value) { if ($value === null) { $where[$column] = Restrictions::isNull(); } } $this->where = $where; $this->values = Arrays::flatten(array_values($where)); $this->operator = $operator; }