|
@@ 657-663 (lines=7) @@
|
| 654 |
|
/** |
| 655 |
|
* $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the age 21 |
| 656 |
|
*/ |
| 657 |
|
public function testFilterMultipleArray() { |
| 658 |
|
$list = DataObjectTest_TeamComment::get(); |
| 659 |
|
$list = $list->filter(array('Name'=>'Bob', 'Comment'=>'This is a team comment by Bob')); |
| 660 |
|
$list = $list->sort('Name', 'ASC'); |
| 661 |
|
$this->assertEquals(1, $list->count()); |
| 662 |
|
$this->assertEquals('Bob', $list->first()->Name, 'Only comment should be from Bob'); |
| 663 |
|
} |
| 664 |
|
|
| 665 |
|
public function testFilterMultipleWithTwoMatches() { |
| 666 |
|
$list = DataObjectTest_TeamComment::get(); |
|
@@ 765-771 (lines=7) @@
|
| 762 |
|
); |
| 763 |
|
} |
| 764 |
|
|
| 765 |
|
public function testFilterAnyMultipleWithArrayFilter() { |
| 766 |
|
$list = DataObjectTest_TeamComment::get(); |
| 767 |
|
$list = $list->filterAny(array('Name'=>array('Bob','Phil'))); |
| 768 |
|
$this->assertEquals(2, $list->count(), 'There should be two comments'); |
| 769 |
|
$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob'); |
| 770 |
|
$this->assertEquals('Phil', $list->last()->Name, 'Last comment should be from Phil'); |
| 771 |
|
} |
| 772 |
|
|
| 773 |
|
public function testFilterAnyArrayInArray() { |
| 774 |
|
$list = DataObjectTest_TeamComment::get(); |
|
@@ 797-808 (lines=12) @@
|
| 794 |
|
); |
| 795 |
|
} |
| 796 |
|
|
| 797 |
|
public function testFilterOnJoin() { |
| 798 |
|
$list = DataObjectTest_TeamComment::get() |
| 799 |
|
->leftJoin('DataObjectTest_Team', |
| 800 |
|
'"DataObjectTest_Team"."ID" = "DataObjectTest_TeamComment"."TeamID"' |
| 801 |
|
)->filter(array( |
| 802 |
|
'Title' => 'Team 1' |
| 803 |
|
)); |
| 804 |
|
|
| 805 |
|
$this->assertEquals(2, $list->count()); |
| 806 |
|
$values = $list->column('Name'); |
| 807 |
|
$this->assertEquals(array_intersect($values, array('Joe', 'Bob')), $values); |
| 808 |
|
} |
| 809 |
|
|
| 810 |
|
public function testFilterOnImplicitJoin() { |
| 811 |
|
// Many to many |