/** * @test */ public function shouldReturnNothingUsingEqualToRestrictionWhenRestrictionDoesNotMatch() { //given Product::create(array('name' => 'tech')); //when $loadedProduct = Product::where(array('name' => Restrictions::equalTo('te')))->fetch(); //then $this->assertNull($loadedProduct); }
/** * @test */ public function shouldCreateProperSql() { //given $restriction = Restrictions::equalTo('value'); //when $sql = $restriction->toSql('key'); //then $this->assertEquals('key = ?', $sql); $this->assertEquals(array('value'), $restriction->getValues()); }
/** * @test */ public function shouldAcceptRestrictionsMixedWithValuesInWhere() { //given $product = Product::create(array('name' => 'tech', 'description' => 'desc')); //when $loadedProduct = Product::where(array('name' => Restrictions::equalTo('tech'), 'description' => 'desc'))->fetch(); //then $this->assertEquals($product, $loadedProduct); }
/** * @test */ public function shouldNotAddParenthesisToSingleOfRestriction() { // when $result = WhereClause::create(array('a' => Restrictions::equalTo('b'))); // then $this->assertInstanceOf('\\Ouzo\\Db\\WhereClause\\ArrayWhereClause', $result); $this->assertEquals('a = ?', $result->toSql()); }