From 575bb1a3f5bf3a3ee9eacba226cd9e047db52c2d Mon Sep 17 00:00:00 2001 From: Normann Lou Date: Tue, 11 Aug 2009 00:11:17 +0000 Subject: [PATCH] ENHANCEMENT: add more assertion in SearchFilterAapplyRelationTest to test more cases for many_many relation. MINOR: fine tuning using DataObjectSet::column('ID') to get the object's ID, instead of DataObjectSet::First()->ID git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84117 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- .../search/SearchFilterApplyRelationTest.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/search/SearchFilterApplyRelationTest.php b/tests/search/SearchFilterApplyRelationTest.php index 456c748c5..4e977f6ea 100644 --- a/tests/search/SearchFilterApplyRelationTest.php +++ b/tests/search/SearchFilterApplyRelationTest.php @@ -39,14 +39,14 @@ class SearchFilterApplyRelationTest extends SapphireTest{ ); $results = $context->getResults($params); $this->assertEquals(1, $results->count()); - $this->assertEquals(1, $results->First()->ID); + $this->assertEquals(array('1'), $results->column('ID')); $params = array( "Title" => "I am has_many object3", ); $results = $context->getResults($params); $this->assertEquals(1, $results->count()); - $this->assertEquals(2, $results->First()->ID); + $this->assertEquals(array('2'), $results->column('ID')); $params = array( "Title" => "I am has_many object", @@ -65,7 +65,7 @@ class SearchFilterApplyRelationTest extends SapphireTest{ $all = singleton("SearchFilterApplyRelationTest_DO"); $context = $all->getDefaultSearchContext(); - $filter = new PartialMatchFilter("SearchFilterApplyRelationTest_ManyManyGrantChildren.Title"); + $filter = new PartialMatchFilter("ManyManyGrantChildren.Title"); $context->setFilters(null); $context->addFilter($filter); $params = array( @@ -79,6 +79,18 @@ class SearchFilterApplyRelationTest extends SapphireTest{ ); $results = $context->getResults($params); $this->assertEquals(2, $results->count()); + + $params = array( + "Title" => "I am many_many object", + ); + $results = $context->getResults($params); + $this->assertEquals(2, $results->count()); + + $params = array( + "Title" => "not exist", + ); + $results = $context->getResults($params); + $this->assertEquals(0, $results->count()); } } @@ -92,7 +104,7 @@ class SearchFilterApplyRelationTest_DO extends DataObject implements TestOnly{ ); static $many_many = array( - 'SearchFilterApplyRelationTest_ManyManyGrantChildren' => 'SearchFilterApplyRelationTest_ManyManyGrantChild' + 'ManyManyGrantChildren' => 'SearchFilterApplyRelationTest_ManyManyGrantChild' ); } @@ -157,7 +169,7 @@ class SearchFilterApplyRelationTest_ManyManyGrantChild extends SearchFilterApply "GrantChildField" => "Varchar" ); static $belongs_many_many = array( - "SearchFilterApplyRelationTest_DOs" => "SearchFilterApplyRelationTest_DO" + "DOs" => "SearchFilterApplyRelationTest_DO" ); }