public function testHowWellItWorksWithMixedFilters()
 {
     $input = array(array('property' => 'orderTotal', 'value' => array('eq:10', 'eq:20')), array(array('property' => 'user.firstname', 'value' => 'like:Se%'), array('property' => 'user.lastname', 'value' => 'like:Li%')));
     $filters = new Filters($input);
     $this->assertEquals(2, count($filters));
     $this->assertInstanceOf(Filter::clazz(), $filters[0]);
     $this->assertInstanceOf(OrFilter::clazz(), $filters[1]);
     $this->assertEquals('orderTotal', $filters[0]->getProperty());
     $this->assertNull($filters[0]->getComparator());
     $this->assertSame(array(array('comparator' => 'eq', 'value' => '10'), array('comparator' => 'eq', 'value' => '20')), $filters[0]->getValue());
     /* @var Filter[] $subFilters */
     $subFilters = $filters[1]->getFilters();
     $this->assertTrue(is_array($subFilters));
     $this->assertEquals(2, count($subFilters));
 }
 public function testHowWellItWorksWithValidInput()
 {
     $f = new OrFilter(array(array('property' => 'user.firstname', 'value' => 'like:Se%'), array('property' => 'user.lastname', 'value' => 'like:Li%')));
     $this->assertTrue($f->isValid());
     $filters = $f->getFilters();
     $this->assertEquals(2, count($filters));
     $this->assertInstanceOf(Filter::clazz(), $filters[0]);
     $this->assertInstanceOf(Filter::clazz(), $filters[1]);
     $this->assertEquals('user.firstname', $filters[0]->getProperty());
     $this->assertEquals('like', $filters[0]->getComparator());
     $this->assertEquals('Se%', $filters[0]->getValue());
     $this->assertEquals('user.lastname', $filters[1]->getProperty());
     $this->assertEquals('like', $filters[1]->getComparator());
     $this->assertEquals('Li%', $filters[1]->getValue());
     $compiled = $f->compile();
     $this->assertTrue(is_array($compiled));
 }
 public function testCreate()
 {
     $f = Filter::create('price', Filter::COMPARATOR_GREATER_THAN, 500);
     $this->assertInstanceOf(Filter::clazz(), $f);
     $this->assertEquals('price', $f->getProperty());
     $this->assertEquals(Filter::COMPARATOR_GREATER_THAN, $f->getComparator());
     $this->assertEquals(500, $f->getValue());
     // ---
     $f = Filter::create('shippedAt', Filter::COMPARATOR_IS_NULL);
     $this->assertInstanceOf(Filter::clazz(), $f);
     $this->assertEquals('shippedAt', $f->getProperty());
     $this->assertEquals(Filter::COMPARATOR_IS_NULL, $f->getComparator());
     $this->assertNull($f->getValue());
 }