From b04c199064a2ee4776ae9e954fec4881b6680a1c Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Fri, 15 Jun 2012 16:08:54 +1200 Subject: [PATCH] MINOR Fixing additional cases where DataList needs to be returned correctly when filtering --- forms/gridfield/GridFieldAddExistingAutocompleter.php | 4 ++-- tests/forms/gridfield/GridFieldExportButtonTest.php | 2 +- tests/model/MapTest.php | 9 +++------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/forms/gridfield/GridFieldAddExistingAutocompleter.php b/forms/gridfield/GridFieldAddExistingAutocompleter.php index 1f4cfe036..157eaa800 100755 --- a/forms/gridfield/GridFieldAddExistingAutocompleter.php +++ b/forms/gridfield/GridFieldAddExistingAutocompleter.php @@ -179,8 +179,8 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF $stmts[] .= sprintf('"%s" LIKE \'%s%%\'', $searchField, $request->param('ID')); } $results = $allList->where(implode(' OR ', $stmts))->subtract($gridField->getList()); - $results->sort($searchFields[0], 'ASC'); - + $results = $results->sort($searchFields[0], 'ASC'); + $json = array(); foreach($results as $result) { $json[$result->ID] = SSViewer::fromString($this->resultsFormat)->process($result); diff --git a/tests/forms/gridfield/GridFieldExportButtonTest.php b/tests/forms/gridfield/GridFieldExportButtonTest.php index 3eda8874a..476d53f80 100644 --- a/tests/forms/gridfield/GridFieldExportButtonTest.php +++ b/tests/forms/gridfield/GridFieldExportButtonTest.php @@ -17,7 +17,7 @@ class GridFieldExportButtonTest extends SapphireTest { parent::setUp(); $this->list = new DataList('GridFieldExportButtonTest_Team'); - $this->list->sort('Name'); + $this->list = $this->list->sort('Name'); $config = GridFieldConfig::create()->addComponent(new GridFieldExportButton()); $this->gridField = new GridField('testfield', 'testfield', $this->list, $config); } diff --git a/tests/model/MapTest.php b/tests/model/MapTest.php index b77eb39c2..821c88812 100755 --- a/tests/model/MapTest.php +++ b/tests/model/MapTest.php @@ -58,8 +58,7 @@ class SS_MapTest extends SapphireTest { } function testKeys() { - $list = DataObjectTest_TeamComment::get(); - $list->sort('Name'); + $list = DataObjectTest_TeamComment::get()->sort('Name'); $map = new SS_Map($list, 'Name', 'Comment'); $this->assertEquals(array( 'Bob', @@ -69,8 +68,7 @@ class SS_MapTest extends SapphireTest { } function testMethodAsValueField() { - $list = DataObjectTest_Team::get(); - $list->sort('Title'); + $list = DataObjectTest_Team::get()->sort('Title'); $map = new SS_Map($list, 'ID', 'MyTitle'); $this->assertEquals(array( 'Team Subteam 1', @@ -83,8 +81,7 @@ class SS_MapTest extends SapphireTest { } function testValues() { - $list = DataObjectTest_TeamComment::get(); - $list->sort('Name'); + $list = DataObjectTest_TeamComment::get()->sort('Name'); $map = new SS_Map($list, 'Name', 'Comment'); $this->assertEquals(array( 'This is a team comment by Bob',