Skip to content

Commit

Permalink
Added test for DataList filters with array and modifiers (see #8162)
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Jan 15, 2013
1 parent a93f884 commit 27d2f75
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/model/DataListTest.php
Expand Up @@ -439,7 +439,7 @@ public function testMultipleFilterWithNoMatch() {
$list = $list->filter(array('Name'=>'Bob', 'Comment'=>'Phil is a unique guy, and comments on team2')); $list = $list->filter(array('Name'=>'Bob', 'Comment'=>'Phil is a unique guy, and comments on team2'));
$this->assertEquals(0, $list->count()); $this->assertEquals(0, $list->count());
} }

/** /**
* $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the age 21 * $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the age 21
*/ */
Expand All @@ -465,6 +465,15 @@ public function testFilterMultipleWithArrayFilter() {
$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob'); $this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
$this->assertEquals('Phil', $list->last()->Name, 'Last comment should be from Phil'); $this->assertEquals('Phil', $list->last()->Name, 'Last comment should be from Phil');
} }

public function testFilterMultipleWithArrayFilterAndModifiers() {
$list = DataObjectTest_TeamComment::get();
$list = $list->filter(array('Name:StartsWith'=>array('Bo', 'Jo')));
$list = $list->sort('Name', 'ASC');
$this->assertEquals(2, $list->count());
$this->assertEquals('Bob', $list->first()->Name);
$this->assertEquals('Joe', $list->last()->Name);
}


/** /**
* $list->filter(array('Name'=>array('aziz','bob'), 'Age'=>array(21, 43))); * $list->filter(array('Name'=>array('aziz','bob'), 'Age'=>array(21, 43)));
Expand Down

0 comments on commit 27d2f75

Please sign in to comment.