mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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
This commit is contained in:
parent
95a8939c7e
commit
575bb1a3f5
@ -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"
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user