public function testHowWellBadInputIsHandled() { $f = new OrFilter(array(array('property' => 'firstname'), array('value' => 'like:foo%'), array('property' => 'lastname', 'value' => 'foo'), array('property' => 'id', 'value' => 'eq:1'))); $this->assertFalse($f->isValid()); $filters = $f->getFilters(); $this->assertEquals(4, count($filters)); }
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)); }