like() public static method

public static like ( $value )
Example #1
0
 /**
  * @test
  */
 public function shouldReturnNothingUsingLikeRestrictionWhenRestrictionDoesNotMatch()
 {
     //given
     Product::create(array('name' => 'tech'));
     //when
     $loadedProduct = Product::where(array('name' => Restrictions::like('te')))->fetch();
     //then
     $this->assertNull($loadedProduct);
 }
Example #2
0
 /**
  * @test
  */
 public function shouldCreateProperSql()
 {
     //given
     $restriction = Restrictions::like('value');
     //when
     $sql = $restriction->toSql('key');
     //then
     $this->assertEquals('key LIKE ?', $sql);
     $this->assertEquals(array('value'), $restriction->getValues());
 }
Example #3
0
 /**
  * @test
  */
 public function shouldSearchAnyOfAndWhereValues()
 {
     //given
     $category = Category::create(array('name' => 'shop'));
     $product1 = Product::create(array('name' => 'notebook', 'description' => 'notebook desc', 'id_category' => $category->getId()));
     $product2 = Product::create(array('name' => 'tablet', 'description' => 'tablet desc', 'id_category' => $category->getId()));
     Product::create(array('name' => 'pc', 'description' => 'pc desc'));
     //when
     $products = Product::where(Any::of(array('name' => 'tablet', 'description' => Restrictions::like('%desc'))))->where(array('id_category' => $category->getId()))->fetchAll();
     //then
     Assert::thatArray($products)->hasSize(2)->onProperty('id')->containsExactly($product1->getId(), $product2->getId());
 }