Skip to content
This repository
Browse code

MINOR Use shorthand {class}::get() syntax instead of DataList::create()

in core code.
  • Loading branch information...
commit c3eabffcb97927f57d5b5dba7c282d8967eb4437 1 parent 71256ea
Sean Harvey authored May 28, 2012
6  admin/code/SecurityAdmin.php
@@ -70,7 +70,7 @@ public function getEditForm($id = null, $fields = null) {
70 70
 		$memberList = GridField::create(
71 71
 			'Members',
72 72
 			false,
73  
-			DataList::create('Member'),
  73
+			Member::get(),
74 74
 			$memberListConfig = GridFieldConfig_RecordEditor::create()
75 75
 				->addComponent(new GridFieldExportButton())
76 76
 		)->addExtraClass("members_grid");
@@ -79,7 +79,7 @@ public function getEditForm($id = null, $fields = null) {
79 79
 		$groupList = GridField::create(
80 80
 			'Groups',
81 81
 			false,
82  
-			DataList::create('Group'),
  82
+			Group::get(),
83 83
 			GridFieldConfig_RecordEditor::create()
84 84
 		);
85 85
 		$columns = $groupList->getConfig()->getComponentByType('GridFieldDataColumns');
@@ -131,7 +131,7 @@ public function getEditForm($id = null, $fields = null) {
131 131
 		if(Permission::check('APPLY_ROLES')) {
132 132
 			$rolesField = GridField::create('Roles',
133 133
 				false,
134  
-				DataList::create('PermissionRole'),
  134
+				PermissionRole::get(),
135 135
 				GridFieldConfig_RecordEditor::create()
136 136
 			);
137 137
 
11  core/Object.php
@@ -87,23 +87,22 @@ public function config() {
87 87
 	 * or calling on Object and passing the class name as the first parameter. The following
88 88
 	 * are equivalent:
89 89
 	 *    $list = DataList::create('SiteTree');
90  
-	 *    $list = DataList::create('SiteTree');
  90
+	 *	  $list = SiteTree::get();
91 91
 	 *
92 92
 	 * @param string $class the class name
93 93
 	 * @param mixed $arguments,... arguments to pass to the constructor
94 94
 	 * @return Object
95 95
 	 */
96 96
 	public static function create() {
97  
-		$args  = func_get_args();
  97
+		$args = func_get_args();
98 98
 
99 99
 		// Class to create should be the calling class if not Object,
100 100
 		// otherwise the first parameter
101 101
 		$class = get_called_class();
102  
-		if($class == 'Object')
103  
-			$class = array_shift($args);
104  
-		
  102
+		if($class == 'Object') $class = array_shift($args);
  103
+
105 104
 		$class = self::getCustomClass($class);
106  
-		
  105
+
107 106
 		return Injector::inst()->createWithArgs($class, $args);
108 107
 	}
109 108
 	
2  forms/DropdownField.php
@@ -13,7 +13,7 @@
13 13
  * 
14 14
  * 	public function getCMSFields() {
15 15
  * 		$fields = parent::getCMSFields();
16  
- * 		$field = new DropdownField('GalleryID', 'Gallery', DataList::create('Gallery')->map('ID', 'Title'));
  16
+ * 		$field = new DropdownField('GalleryID', 'Gallery', Gallery::get()->map('ID', 'Title'));
17 17
  * 		$field->setEmptyString('(Select one)');
18 18
  * 		$fields->addFieldToTab('Root.Content', $field, 'Content');
19 19
  * </code>
4  forms/HtmlEditorField.php
@@ -498,7 +498,7 @@ public function viewfile($request) {
498 498
 			} else {
499 499
 				$url = Director::makeRelative($request->getVar('FileURL'));
500 500
 				$url = preg_replace('/_resampled\/[^-]+-/', '', $url);
501  
-				$file = DataList::create('File')->filter('Filename', $url)->first();	
  501
+				$file = File::get()->filter('Filename', $url)->first();	
502 502
 				if(!$file) $file = new File(array(
503 503
 					'Title' => basename($url),
504 504
 					'Filename' => $url
@@ -720,7 +720,7 @@ protected function getFiles($parentID = null) {
720 720
 		$wheres = array();
721 721
 		foreach($exts as $ext) $wheres[] = '"Filename" LIKE \'%.' . $ext . '\'';
722 722
 
723  
-		$files = DataList::create('File')->where(implode(' OR ', $wheres));
  723
+		$files = File::get()->where(implode(' OR ', $wheres));
724 724
 		
725 725
 		// Limit by folder (if required)
726 726
 		if($parentID) $files->filter('ParentID', $parentID);
2  forms/UploadField.php
@@ -528,7 +528,7 @@ public function attach($request) {
528 528
 
529 529
 		$return = array();
530 530
 
531  
-		$files = DataList::create('File')->byIDs($request->postVar('ids'));
  531
+		$files = File::get()->byIDs($request->postVar('ids'));
532 532
 		foreach($files as $file) {
533 533
 			$this->attachFile($file);
534 534
 			$file =  $this->customiseFile($file);
87  model/Versioned.php
@@ -60,7 +60,7 @@ class Versioned extends DataExtension {
60 60
 		"Version" => "Int",
61 61
 		"WasPublished" => "Boolean",
62 62
 		"AuthorID" => "Int",
63  
-		"PublisherID" => "Int"				
  63
+		"PublisherID" => "Int"
64 64
 	);
65 65
 	
66 66
 	/**
@@ -138,8 +138,8 @@ function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null) {
138 138
 		switch($dataQuery->getQueryParam('Versioned.mode')) {
139 139
 		// Noop
140 140
 		case '':
141  
-		    break;
142  
-		    
  141
+			break;
  142
+
143 143
 		// Reading a specific data from the archive
144 144
 		case 'archive':
145 145
 			$date = $dataQuery->getQueryParam('Versioned.date');
@@ -186,31 +186,30 @@ function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null) {
186 186
 		// Return all version instances	
187 187
 		case 'all_versions':
188 188
 		case 'latest_versions':
189  
-    		foreach($query->getFrom() as $alias => $join) {
190  
-    		    if($alias != $baseTable) {
191  
-    		        $query->setJoinFilter($alias, "\"$alias\".\"RecordID\" = \"{$baseTable}_versions\".\"RecordID\" AND \"$alias\".\"Version\" = \"{$baseTable}_versions\".\"Version\"");
192  
-		        }
193  
-    			$query->renameTable($alias, $alias . '_versions');
194  
-    		}
  189
+			foreach($query->getFrom() as $alias => $join) {
  190
+				if($alias != $baseTable) {
  191
+					$query->setJoinFilter($alias, "\"$alias\".\"RecordID\" = \"{$baseTable}_versions\".\"RecordID\" AND \"$alias\".\"Version\" = \"{$baseTable}_versions\".\"Version\"");
  192
+				}
  193
+				$query->renameTable($alias, $alias . '_versions');
  194
+			}
195 195
 		
196  
-    		// Add all <basetable>_versions columns
197  
-    		foreach(self::$db_for_versions_table as $name => $type) {
198  
-    			$query->selectField(sprintf('"%s_versions"."%s"', $baseTable, $name), $name);
199  
-    		}
200  
-    		$query->selectField(sprintf('"%s_versions"."%s"', $baseTable, 'RecordID'), "ID");
201  
-    		
202  
-    		// latest_version has one more step
203  
-    	    // Return latest version instances, regardless of whether they are on a particular stage
204  
-		    // This provides "show all, including deleted" functonality
205  
-            if($dataQuery->getQueryParam('Versioned.mode') == 'latest_versions') {
206  
-    		    $archiveTable = self::requireArchiveTempTable($baseTable);
207  
-    		    $query->addInnerJoin($archiveTable, "\"$archiveTable\".\"ID\" = \"{$baseTable}_versions\".\"RecordID\" AND \"$archiveTable\".\"Version\" = \"{$baseTable}_versions\".\"Version\"");
208  
-		    }
  196
+			// Add all <basetable>_versions columns
  197
+			foreach(self::$db_for_versions_table as $name => $type) {
  198
+				$query->selectField(sprintf('"%s_versions"."%s"', $baseTable, $name), $name);
  199
+			}
  200
+			$query->selectField(sprintf('"%s_versions"."%s"', $baseTable, 'RecordID'), "ID");
  201
+			
  202
+			// latest_version has one more step
  203
+			// Return latest version instances, regardless of whether they are on a particular stage
  204
+			// This provides "show all, including deleted" functonality
  205
+			if($dataQuery->getQueryParam('Versioned.mode') == 'latest_versions') {
  206
+				$archiveTable = self::requireArchiveTempTable($baseTable);
  207
+				$query->addInnerJoin($archiveTable, "\"$archiveTable\".\"ID\" = \"{$baseTable}_versions\".\"RecordID\" AND \"$archiveTable\".\"Version\" = \"{$baseTable}_versions\".\"Version\"");
  208
+			}
209 209
 
210  
-            break;
211  
-            
212  
-        default:
213  
-            throw new InvalidArgumentException("Bad value for query parameter Versioned.mode: " . $dataQuery->getQueryParam('Versioned.mode'));
  210
+			break;
  211
+		default:
  212
+			throw new InvalidArgumentException("Bad value for query parameter Versioned.mode: " . $dataQuery->getQueryParam('Versioned.mode'));
214 213
 		}
215 214
 	}
216 215
 	
@@ -686,7 +685,7 @@ function stagesDiffer($stage1, $stage2) {
686 685
 		if(!is_numeric($this->owner->ID)) {
687 686
 			return true;
688 687
 		}
689  
-            
  688
+
690 689
 		// We test for equality - if one of the versions doesn't exist, this will be false
691 690
 		//TODO: DB Abstraction: if statement here:
692 691
 		$stagesAreEqual = DB::query("SELECT CASE WHEN \"$table1\".\"Version\"=\"$table2\".\"Version\" THEN 1 ELSE 0 END FROM \"$table1\" INNER JOIN \"$table2\" ON \"$table1\".\"ID\" = \"$table2\".\"ID\" AND \"$table1\".\"ID\" = {$this->owner->ID}")->value();
@@ -875,10 +874,10 @@ static function reading_archived_date($date) {
875 874
 	 * @return DataObject
876 875
 	 */
877 876
 	static function get_one_by_stage($class, $stage, $filter = '', $cache = true, $sort = '') {
878  
-	    // TODO: No identity cache operating
879  
-	    $items = self::get_by_stage($class, $stage, $filter, $sort, null, 1);
880  
-	    return $items->First();
881  
-    }
  877
+		// TODO: No identity cache operating
  878
+		$items = self::get_by_stage($class, $stage, $filter, $sort, null, 1);
  879
+		return $items->First();
  880
+	}
882 881
 	
883 882
 	/**
884 883
 	 * Gets the current version number of a specific record.
@@ -992,9 +991,9 @@ function doRollbackTo($version) {
992 991
 	 */
993 992
 	static function get_latest_version($class, $id) {
994 993
 		$baseClass = ClassInfo::baseDataClass($class);
995  
-	    $list = DataList::create($class)->where("\"$baseClass\".\"RecordID\" = $id");
996  
-	    $list->dataQuery()->setQueryParam("Versioned.mode", "latest_versions");
997  
-        return $list->First();
  994
+		$list = DataList::create($class)->where("\"$baseClass\".\"RecordID\" = $id");
  995
+		$list->dataQuery()->setQueryParam("Versioned.mode", "latest_versions");
  996
+		return $list->First();
998 997
 	}
999 998
 	
1000 999
 	/**
@@ -1020,9 +1019,9 @@ function isLatestVersion() {
1020 1019
 	 * In particular, this will query deleted records as well as active ones.
1021 1020
 	 */
1022 1021
 	static function get_including_deleted($class, $filter = "", $sort = "") {
1023  
-	    $list = DataList::create($class)->where($filter)->sort($sort);
1024  
-	    $list->dataQuery()->setQueryParam("Versioned.mode", "latest_versions");
1025  
-	    return $list;
  1022
+		$list = DataList::create($class)->where($filter)->sort($sort);
  1023
+		$list->dataQuery()->setQueryParam("Versioned.mode", "latest_versions");
  1024
+		return $list;
1026 1025
 	}
1027 1026
 	
1028 1027
 	/**
@@ -1031,9 +1030,9 @@ static function get_including_deleted($class, $filter = "", $sort = "") {
1031 1030
 	 */
1032 1031
 	static function get_version($class, $id, $version) {
1033 1032
 		$baseClass = ClassInfo::baseDataClass($class);
1034  
-	    $list = DataList::create($class)->where("\"$baseClass\".\"RecordID\" = $id")->where("\"$baseClass\".\"Version\" = " . (int)$version);
1035  
-	    $list->dataQuery()->setQueryParam('Versioned.mode', 'all_versions');
1036  
-        return $list->First();
  1033
+		$list = DataList::create($class)->where("\"$baseClass\".\"RecordID\" = $id")->where("\"$baseClass\".\"Version\" = " . (int)$version);
  1034
+		$list->dataQuery()->setQueryParam('Versioned.mode', 'all_versions');
  1035
+		return $list->First();
1037 1036
 	}
1038 1037
 
1039 1038
 	/**
@@ -1041,10 +1040,10 @@ static function get_version($class, $id, $version) {
1041 1040
 	 * @return DataList
1042 1041
 	 */
1043 1042
 	static function get_all_versions($class, $id) {
1044  
-        $baseClass = ClassInfo::baseDataClass($class);
1045  
-	    $list = DataList::create($class)->where("\"$baseClass\".\"RecordID\" = $id");
1046  
-	    $list->dataQuery()->setQueryParam('Versioned.mode', 'all_versions');
1047  
-	    return $list;
  1043
+		$baseClass = ClassInfo::baseDataClass($class);
  1044
+		$list = DataList::create($class)->where("\"$baseClass\".\"RecordID\" = $id");
  1045
+		$list->dataQuery()->setQueryParam('Versioned.mode', 'all_versions');
  1046
+		return $list;
1048 1047
 	}
1049 1048
 	
1050 1049
 	function contentcontrollerInit($controller) {
8  security/Group.php
@@ -68,7 +68,7 @@ public function getCMSFields() {
68 68
 					new TextField("Title", $this->fieldLabel('Title')),
69 69
 					$parentidfield = DropdownField::create(						'ParentID', 
70 70
 						$this->fieldLabel('Parent'), 
71  
-						DataList::create('Group')->exclude('ID', $this->ID)->map('ID', 'Breadcrumbs')
  71
+						Group::get()->exclude('ID', $this->ID)->map('ID', 'Breadcrumbs')
72 72
 					)->setEmptyString(' ')
73 73
 				),
74 74
 
@@ -240,7 +240,7 @@ public function Members($filter = "", $sort = "", $join = "", $limit = "") {
240 240
 		// Filters are conjunctive in DataQuery by default, so this filter would otherwise overrule any less specific ones.
241 241
 		$result->dataQuery()->removeFilterOn('Group_Members');
242 242
 		// Now set all children groups as a new foreign key
243  
-		$groups = DataList::create("Group")->byIDs($this->collateFamilyIDs());
  243
+		$groups = Group::get()->byIDs($this->collateFamilyIDs());
244 244
 		$result = $result->forForeignID($groups->column('ID'))->where($filter)->sort($sort)->limit($limit);
245 245
 		if($join) $result = $result->join($join);
246 246
 
@@ -257,7 +257,7 @@ public function DirectMembers() {
257 257
 	public static function map($filter = "", $sort = "", $blank="") {
258 258
 		Deprecation::notice('3.0', 'Use DataList::("Group")->map()');
259 259
 
260  
-		$list = DataList::create("Group")->where($filter)->sort($sort);
  260
+		$list = Group::get()->where($filter)->sort($sort);
261 261
 		$map = $list->map();
262 262
 
263 263
 		if($blank) $map->unshift(0, $blank);
@@ -284,7 +284,7 @@ public function collateFamilyIDs() {
284 284
 			
285 285
 			// Get the children of *all* the groups identified in the previous chunk.
286 286
 			// This minimises the number of SQL queries necessary			
287  
-			$chunkToAdd = DataList::create('Group')->where("\"ParentID\" IN ($idList)")->column('ID');
  287
+			$chunkToAdd = Group::get()->where("\"ParentID\" IN ($idList)")->column('ID');
288 288
 		}
289 289
 		
290 290
 		return $familyIDs;
6  security/Member.php
@@ -963,7 +963,7 @@ public function DirectGroups() {
963 963
 	public static function map($filter = "", $sort = "", $blank="") {
964 964
 		Deprecation::notice('3.0', 'Use DataList::("Member")->map()');
965 965
 
966  
-		$list = DataList::create("Member")->where($filter)->sort($sort);
  966
+		$list = Member::get()->where($filter)->sort($sort);
967 967
 		$map = $list->map();
968 968
 		
969 969
 		if($blank) $map->unshift(0, $blank);
@@ -1062,7 +1062,7 @@ public static function mapInCMSGroups($groups = null) {
1062 1062
 			? "\"GroupID\" IN (" . implode( ',', $groupIDList ) . ")"
1063 1063
 			: "";
1064 1064
 			
1065  
-		return DataList::create("Member")->where($filterClause)->sort("\"Surname\", \"FirstName\"")
  1065
+		return Member::get()->where($filterClause)->sort("\"Surname\", \"FirstName\"")
1066 1066
 			->innerJoin("Group_Members", "\"MemberID\"=\"Member\".\"ID\"")
1067 1067
 			->innerJoin("Group", "\"Group\".\"ID\"=\"GroupID\"")
1068 1068
 			->map();
@@ -1148,7 +1148,7 @@ public function getCMSFields() {
1148 1148
 		$fields->removeByName('Groups');
1149 1149
 
1150 1150
 		if(Permission::check('EDIT_PERMISSIONS')) {
1151  
-			$groupsMap = DataList::create('Group')->map('ID', 'Breadcrumbs')->toArray();
  1151
+			$groupsMap = Group::get()->map('ID', 'Breadcrumbs')->toArray();
1152 1152
 			asort($groupsMap);
1153 1153
 			$fields->addFieldToTab('Root.Main',
1154 1154
 				ListboxField::create('DirectGroups', singleton('Group')->i18n_plural_name())
8  tests/forms/GridFieldTest.php
@@ -69,7 +69,7 @@ public function testGridFieldSetCustomConfig() {
69 69
 	 * @covers GridField::setModelClass
70 70
 	 */
71 71
 	public function testGridFieldModelClass() {
72  
-		$obj = new GridField('testfield', 'testfield', DataList::create('Member'));
  72
+		$obj = new GridField('testfield', 'testfield', Member::get());
73 73
 		$this->assertEquals('Member', $obj->getModelClass(), 'Should return Member');
74 74
 		$obj->setModelClass('DataModel');
75 75
 		$this->assertEquals('DataModel', $obj->getModelClass(), 'Should return Member');
@@ -89,7 +89,7 @@ public function testGridFieldModelClassThrowsException() {
89 89
 	 * @covers GridField::getList
90 90
 	 */
91 91
 	public function testSetAndGetList() {
92  
-		$list = DataList::create('Member');
  92
+		$list = Member::get();
93 93
 		$arrayList = ArrayList::create(array(1,2,3));
94 94
 		$obj = new GridField('testfield', 'testfield', $list);
95 95
 		$this->assertEquals($list, $obj->getList());
@@ -110,7 +110,7 @@ public function testGetState() {
110 110
 	 * @covers GridField::getColumns
111 111
 	 */
112 112
 	public function testGetColumns(){
113  
-		$obj = new GridField('testfield', 'testfield', DataList::create('Member'));
  113
+		$obj = new GridField('testfield', 'testfield', Member::get());
114 114
 		$expected = array (
115 115
 			0 => 'FirstName',
116 116
 			1 => 'Surname',
@@ -123,7 +123,7 @@ public function testGetColumns(){
123 123
 	 * @covers GridField::getColumnCount
124 124
 	 */
125 125
 	public function testGetColumnCount() {
126  
-		$obj = new GridField('testfield', 'testfield', DataList::create('Member'));
  126
+		$obj = new GridField('testfield', 'testfield', Member::get());
127 127
 		$this->assertEquals(3, $obj->getColumnCount());
128 128
 	}
129 129
 
6  tests/forms/gridfield/GridFieldDataColumnsTest.php
@@ -5,7 +5,7 @@ class GridFieldDataColumnsTest extends SapphireTest {
5 5
 	 * @covers GridFieldDataColumns::getDisplayFields
6 6
 	 */
7 7
 	public function testGridFieldGetDefaultDisplayFields() {
8  
-		$obj = new GridField('testfield', 'testfield', DataList::create('Member'));
  8
+		$obj = new GridField('testfield', 'testfield', Member::get());
9 9
 		$expected = singleton('Member')->summaryFields();
10 10
 		$columns = $obj->getConfig()->getComponentByType('GridFieldDataColumns');
11 11
 		$this->assertEquals($expected, $columns->getDisplayFields($obj));
@@ -16,7 +16,7 @@ public function testGridFieldGetDefaultDisplayFields() {
16 16
 	 * @covers GridFieldDataColumns::getDisplayFields
17 17
 	 */
18 18
 	public function testGridFieldCustomDisplayFields() {
19  
-		$obj = new GridField('testfield', 'testfield', DataList::create('Member'));
  19
+		$obj = new GridField('testfield', 'testfield', Member::get());
20 20
 		$expected = array('Email' => 'Email');
21 21
 		$columns = $obj->getConfig()->getComponentByType('GridFieldDataColumns');
22 22
 		$columns->setDisplayFields($expected);
@@ -29,7 +29,7 @@ public function testGridFieldCustomDisplayFields() {
29 29
 	 */
30 30
 	public function testGridFieldDisplayFieldsWithBadArguments() {
31 31
 		$this->setExpectedException('InvalidArgumentException');
32  
-		$obj = new GridField('testfield', 'testfield', DataList::create('Member'));
  32
+		$obj = new GridField('testfield', 'testfield', Member::get());
33 33
 		$columns = $obj->getConfig()->getComponentByType('GridFieldDataColumns');
34 34
 		$columns->setDisplayFields(new stdClass());
35 35
 	}
14  tests/forms/gridfield/GridFieldDetailFormTest.php
@@ -11,7 +11,7 @@ class GridFieldDetailFormTest extends FunctionalTest {
11 11
 
12 12
 	function testAddForm() {
13 13
 		$this->logInWithPermission('ADMIN');
14  
-		$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
  14
+		$group = GridFieldDetailFormTest_PeopleGroup::get()
15 15
 			->filter('Name', 'My Group')
16 16
 			->sort('Name')
17 17
 			->First();
@@ -40,7 +40,7 @@ function testAddForm() {
40 40
 		);
41 41
 		$this->assertFalse($response->isError());
42 42
 
43  
-		$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
  43
+		$group = GridFieldDetailFormTest_PeopleGroup::get()
44 44
 			->filter('Name', 'My Group')
45 45
 			->sort('Name')
46 46
 			->First();
@@ -69,7 +69,7 @@ public function testViewForm() {
69 69
 
70 70
 	function testEditForm() {
71 71
 		$this->logInWithPermission('ADMIN');
72  
-		$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
  72
+		$group = GridFieldDetailFormTest_PeopleGroup::get()
73 73
 			->filter('Name', 'My Group')
74 74
 			->sort('Name')
75 75
 			->First();
@@ -99,7 +99,7 @@ function testEditForm() {
99 99
 		);
100 100
 		$this->assertFalse($response->isError());
101 101
 
102  
-		$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
  102
+		$group = GridFieldDetailFormTest_PeopleGroup::get()
103 103
 			->filter('Name', 'My Group')
104 104
 			->sort('Name')
105 105
 			->First();
@@ -249,7 +249,7 @@ class GridFieldDetailFormTest_Controller extends Controller implements TestOnly
249 249
 	protected $template = 'BlankPage';
250 250
 
251 251
 	function Form() {
252  
-		$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
  252
+		$group = GridFieldDetailFormTest_PeopleGroup::get()
253 253
 			->filter('Name', 'My Group')
254 254
 			->sort('Name')
255 255
 			->First();
@@ -269,7 +269,7 @@ class GridFieldDetailFormTest_GroupController extends Controller implements Test
269 269
 	protected $template = 'BlankPage';
270 270
 
271 271
 	function Form() {
272  
-		$field = new GridField('testfield', 'testfield', DataList::create('GridFieldDetailFormTest_PeopleGroup')->sort('Name'));
  272
+		$field = new GridField('testfield', 'testfield', GridFieldDetailFormTest_PeopleGroup::get()->sort('Name'));
273 273
 		$field->getConfig()->addComponent($gridFieldForm = new GridFieldDetailForm($this, 'Form'));
274 274
 		$field->getConfig()->addComponent(new GridFieldToolbarHeader());
275 275
 		$field->getConfig()->addComponent(new GridFieldAddNewButton('toolbar-header-right'));
@@ -279,4 +279,4 @@ function Form() {
279 279
 }
280 280
 
281 281
 class GridFieldDetailFormTest_ItemRequest extends GridFieldDetailForm_ItemRequest implements TestOnly {
282  
-}
  282
+}
112  tests/model/DataListTest.php
@@ -18,22 +18,22 @@ class DataListTest extends SapphireTest {
18 18
 	);
19 19
 	
20 20
 	public function testSubtract(){
21  
-		$subtractList = DataList::create("DataObjectTest_TeamComment")->filter('ID',1);
22  
-		$fullList = DataList::create("DataObjectTest_TeamComment");
  21
+		$subtractList = DataObjectTest_TeamComment::get()->filter('ID', 1);
  22
+		$fullList = DataObjectTest_TeamComment::get();
23 23
 		$newList = $fullList->subtract($subtractList);
24 24
 		$this->assertEquals(2, $newList->Count(), 'List should only contain two objects after subtraction');
25 25
 	}
26 26
 	
27 27
 	public function testSubtractBadDataclassThrowsException(){
28 28
 		$this->setExpectedException('InvalidArgumentException');
29  
-		$teamsComments = DataList::create("DataObjectTest_TeamComment");
30  
-		$teams = DataList::create("DataObjectTest_Team");
  29
+		$teamsComments = DataObjectTest_TeamComment::get();
  30
+		$teams = DataObjectTest_Team::get();
31 31
 		$teamsComments->subtract($teams);
32 32
 	}
33 33
 	
34 34
 	function testListCreationSortAndLimit() {
35 35
 		// By default, a DataList will contain all items of that class
36  
-		$list = DataList::create('DataObjectTest_TeamComment')->sort('ID');
  36
+		$list = DataObjectTest_TeamComment::get()->sort('ID');
37 37
 		
38 38
 		// We can iterate on the DataList
39 39
 		$names = array();
@@ -54,37 +54,37 @@ function testListCreationSortAndLimit() {
54 54
 	}
55 55
 	
56 56
 	function testDataClass() {
57  
-		$list = DataList::create('DataObjectTest_TeamComment');
  57
+		$list = DataObjectTest_TeamComment::get();
58 58
 		$this->assertEquals('DataObjectTest_TeamComment',$list->dataClass());
59 59
 	}
60 60
 	
61 61
 	function testClone() {
62  
-		$list = DataList::create('DataObjectTest_TeamComment');
  62
+		$list = DataObjectTest_TeamComment::get();
63 63
 		$this->assertEquals($list, clone($list));
64 64
 	}
65 65
 	
66 66
 	function testSql() {
67  
-		$list = DataList::create('DataObjectTest_TeamComment');
  67
+		$list = DataObjectTest_TeamComment::get();
68 68
 		$expected = 'SELECT DISTINCT "DataObjectTest_TeamComment"."ClassName", "DataObjectTest_TeamComment"."Created", "DataObjectTest_TeamComment"."LastEdited", "DataObjectTest_TeamComment"."Name", "DataObjectTest_TeamComment"."Comment", "DataObjectTest_TeamComment"."TeamID", "DataObjectTest_TeamComment"."ID", CASE WHEN "DataObjectTest_TeamComment"."ClassName" IS NOT NULL THEN "DataObjectTest_TeamComment"."ClassName" ELSE \'DataObjectTest_TeamComment\' END AS "RecordClassName" FROM "DataObjectTest_TeamComment"';
69 69
 		$this->assertEquals($expected, $list->sql());
70 70
 	}
71 71
 	
72 72
 	function testInnerJoin() {
73  
-		$list = DataList::create('DataObjectTest_TeamComment');
  73
+		$list = DataObjectTest_TeamComment::get();
74 74
 		$list->innerJoin('DataObjectTest_Team', '"DataObjectTest_Team"."ID" = "DataObjectTest_TeamComment"."TeamID"', 'Team');
75 75
 		$expected = 'SELECT DISTINCT "DataObjectTest_TeamComment"."ClassName", "DataObjectTest_TeamComment"."Created", "DataObjectTest_TeamComment"."LastEdited", "DataObjectTest_TeamComment"."Name", "DataObjectTest_TeamComment"."Comment", "DataObjectTest_TeamComment"."TeamID", "DataObjectTest_TeamComment"."ID", CASE WHEN "DataObjectTest_TeamComment"."ClassName" IS NOT NULL THEN "DataObjectTest_TeamComment"."ClassName" ELSE \'DataObjectTest_TeamComment\' END AS "RecordClassName" FROM "DataObjectTest_TeamComment" INNER JOIN "DataObjectTest_Team" AS "Team" ON "DataObjectTest_Team"."ID" = "DataObjectTest_TeamComment"."TeamID"';
76 76
 		$this->assertEquals($expected, $list->sql());
77 77
 	}
78 78
 	
79 79
 	function testLeftJoin() {
80  
-		$list = DataList::create('DataObjectTest_TeamComment');
  80
+		$list = DataObjectTest_TeamComment::get();
81 81
 		$list->leftJoin('DataObjectTest_Team', '"DataObjectTest_Team"."ID" = "DataObjectTest_TeamComment"."TeamID"', 'Team');
82 82
 		$expected = 'SELECT DISTINCT "DataObjectTest_TeamComment"."ClassName", "DataObjectTest_TeamComment"."Created", "DataObjectTest_TeamComment"."LastEdited", "DataObjectTest_TeamComment"."Name", "DataObjectTest_TeamComment"."Comment", "DataObjectTest_TeamComment"."TeamID", "DataObjectTest_TeamComment"."ID", CASE WHEN "DataObjectTest_TeamComment"."ClassName" IS NOT NULL THEN "DataObjectTest_TeamComment"."ClassName" ELSE \'DataObjectTest_TeamComment\' END AS "RecordClassName" FROM "DataObjectTest_TeamComment" LEFT JOIN "DataObjectTest_Team" AS "Team" ON "DataObjectTest_Team"."ID" = "DataObjectTest_TeamComment"."TeamID"';
83 83
 		$this->assertEquals($expected, $list->sql());
84 84
 	}
85 85
 	
86 86
 	function testToNestedArray() {
87  
-		$list = DataList::create('DataObjectTest_TeamComment')->sort('ID');
  87
+		$list = DataObjectTest_TeamComment::get()->sort('ID');
88 88
 		$nestedArray = $list->toNestedArray();
89 89
 		$expected = array(
90 90
 			0=>
@@ -116,7 +116,7 @@ function testToNestedArray() {
116 116
 	}
117 117
 	
118 118
 	function testMap() {
119  
-		$map = DataList::create('DataObjectTest_TeamComment')->map()->toArray();
  119
+		$map = DataObjectTest_TeamComment::get()->map()->toArray();
120 120
 		$expected = array(
121 121
 			$this->idFromFixture('DataObjectTest_TeamComment', 'comment1') => 'Joe',
122 122
 			$this->idFromFixture('DataObjectTest_TeamComment', 'comment2') => 'Bob',
@@ -124,7 +124,7 @@ function testMap() {
124 124
 		);
125 125
 	
126 126
 		$this->assertEquals($expected, $map);
127  
-		$otherMap = DataList::create('DataObjectTest_TeamComment')->map('Name', 'TeamID')->toArray();
  127
+		$otherMap = DataObjectTest_TeamComment::get()->map('Name', 'TeamID')->toArray();
128 128
 		$otherExpected = array(
129 129
 			'Joe' => $this->objFromFixture('DataObjectTest_TeamComment', 'comment1')->TeamID,
130 130
 			'Bob' => $this->objFromFixture('DataObjectTest_TeamComment', 'comment2')->TeamID,
@@ -141,7 +141,7 @@ function testFilter() {
141 141
 	function testWhere() {
142 142
 		// We can use raw SQL queries with where.  This is only recommended for advanced uses;
143 143
 		// if you can, you should use filter().
144  
-		$list = DataList::create('DataObjectTest_TeamComment');
  144
+		$list = DataObjectTest_TeamComment::get();
145 145
 		
146 146
 		// where() returns a new DataList, like all the other modifiers, so it can be chained.
147 147
 		$list2 = $list->where('"Name" = \'Joe\'');
@@ -158,7 +158,7 @@ function testWhere() {
158 158
 	function testByID() {
159 159
 		// We can get a single item by ID.
160 160
 		$id = $this->idFromFixture('DataObjectTest_Team','team2');
161  
-		$team = DataList::create("DataObjectTest_Team")->byID($id);
  161
+		$team = DataObjectTest_Team::get()->byID($id);
162 162
 		
163 163
 		// byID() returns a DataObject, rather than a DataList
164 164
 		$this->assertInstanceOf('DataObjectTest_Team', $team);
@@ -169,7 +169,7 @@ function testByID() {
169 169
 	 * Test DataList->removeByID()
170 170
 	 */
171 171
 	function testRemoveByID() {
172  
-		$list = DataList::create("DataObjectTest_Team");
  172
+		$list = DataObjectTest_TeamComment::get();
173 173
 		$id = $this->idFromFixture('DataObjectTest_Team','team2');
174 174
 		
175 175
 		$this->assertNotNull($list->byID($id));
@@ -182,18 +182,18 @@ function testRemoveByID() {
182 182
 	 */
183 183
 	function testCanSortBy() {
184 184
 		// Basic check
185  
-		$team = DataList::create("DataObjectTest_Team");
  185
+		$team = DataObjectTest_Team::get();
186 186
 		$this->assertTrue($team->canSortBy("Title"));
187 187
 		$this->assertFalse($team->canSortBy("SomethingElse"));
188 188
 	
189 189
 		// Subclasses
190  
-		$subteam = DataList::create("DataObjectTest_SubTeam");
  190
+		$subteam = DataObjectTest_SubTeam::get();
191 191
 		$this->assertTrue($subteam->canSortBy("Title"));
192 192
 		$this->assertTrue($subteam->canSortBy("SubclassDatabaseField"));
193 193
 	}
194 194
 	
195 195
 	function testDataListArrayAccess() {
196  
-		$list = DataList::create("DataObjectTest_Team")->sort("Title");
  196
+		$list = DataObjectTest_Team::get()->sort('Title');
197 197
 	
198 198
 		// We can use array access to refer to single items in the DataList, as if it were an array
199 199
 		$this->assertEquals("Subteam 1", $list[0]->Title);
@@ -202,13 +202,13 @@ function testDataListArrayAccess() {
202 202
 	}
203 203
 	
204 204
 	function testFind() {
205  
-		$list = DataList::create("DataObjectTest_Team");
  205
+		$list = DataObjectTest_Team::get();
206 206
 		$record = $list->find('Title', 'Team 1');
207 207
 		$this->assertEquals($this->idFromFixture('DataObjectTest_Team', 'team1'), $record->ID);
208 208
 	}
209 209
 	
210 210
 	function testFindById() {
211  
-		$list = DataList::create("DataObjectTest_Team");
  211
+		$list = DataObjectTest_Team::get();
212 212
 		$record = $list->find('ID', $this->idFromFixture('DataObjectTest_Team', 'team1'));
213 213
 		$this->assertEquals('Team 1', $record->Title);
214 214
 		// Test that you can call it twice on the same list
@@ -217,63 +217,63 @@ function testFindById() {
217 217
 	}
218 218
 	
219 219
 	public function testSimpleSort() {
220  
-		$list = DataList::create("DataObjectTest_TeamComment");
  220
+		$list = DataObjectTest_TeamComment::get();
221 221
 		$list->sort('Name');
222 222
 		$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
223 223
 		$this->assertEquals('Phil', $list->last()->Name, 'Last comment should be from Phil');
224 224
 	}
225 225
 	
226 226
 	public function testSimpleSortOneArgumentASC() {
227  
-		$list = DataList::create("DataObjectTest_TeamComment");
  227
+		$list = DataObjectTest_TeamComment::get();
228 228
 		$list->sort('Name ASC');
229 229
 		$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
230 230
 		$this->assertEquals('Phil', $list->last()->Name, 'Last comment should be from Phil');
231 231
 	}
232 232
 	
233 233
 	public function testSimpleSortOneArgumentDESC() {
234  
-		$list = DataList::create("DataObjectTest_TeamComment");
  234
+		$list = DataObjectTest_TeamComment::get();
235 235
 		$list->sort('Name DESC');
236 236
 		$this->assertEquals('Phil', $list->first()->Name, 'Last comment should be from Phil');
237 237
 		$this->assertEquals('Bob', $list->last()->Name, 'First comment should be from Bob');
238 238
 	}
239 239
 	
240 240
 	public function testSortOneArgumentMultipleColumns() {
241  
-		$list = DataList::create("DataObjectTest_TeamComment");
  241
+		$list = DataObjectTest_TeamComment::get();
242 242
 		$list->sort('TeamID ASC, Name DESC');
243 243
 		$this->assertEquals('Joe', $list->first()->Name, 'First comment should be from Bob');
244 244
 		$this->assertEquals('Phil', $list->last()->Name, 'Last comment should be from Phil');
245 245
 	}
246 246
 	
247 247
 	public function testSimpleSortASC() {
248  
-		$list = DataList::create("DataObjectTest_TeamComment");
  248
+		$list = DataObjectTest_TeamComment::get();
249 249
 		$list->sort('Name', 'asc');
250 250
 		$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
251 251
 		$this->assertEquals('Phil', $list->last()->Name, 'Last comment should be from Phil');
252 252
 	}
253 253
 	
254 254
 	public function testSimpleSortDESC() {
255  
-		$list = DataList::create("DataObjectTest_TeamComment");
  255
+		$list = DataObjectTest_TeamComment::get();
256 256
 		$list->sort('Name', 'desc');
257 257
 		$this->assertEquals('Phil', $list->first()->Name, 'Last comment should be from Phil');
258 258
 		$this->assertEquals('Bob', $list->last()->Name, 'First comment should be from Bob');
259 259
 	}
260 260
 	
261 261
 	public function testSortWithArraySyntaxSortASC() {
262  
-		$list = DataList::create("DataObjectTest_TeamComment");
  262
+		$list = DataObjectTest_TeamComment::get();
263 263
 		$list->sort(array('Name'=>'asc'));
264 264
 		$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
265 265
 		$this->assertEquals('Phil', $list->last()->Name, 'Last comment should be from Phil');
266 266
 	}
267 267
 	
268 268
 	public function testSortWithArraySyntaxSortDESC() {
269  
-		$list = DataList::create("DataObjectTest_TeamComment");
  269
+		$list = DataObjectTest_TeamComment::get();
270 270
 		$list->sort(array('Name'=>'desc'));
271 271
 		$this->assertEquals('Phil', $list->first()->Name, 'Last comment should be from Phil');
272 272
 		$this->assertEquals('Bob', $list->last()->Name, 'First comment should be from Bob');
273 273
 	}
274 274
 	
275 275
 	public function testSortWithMultipleArraySyntaxSort() {
276  
-		$list = DataList::create("DataObjectTest_TeamComment");
  276
+		$list = DataObjectTest_TeamComment::get();
277 277
 		$list->sort(array('TeamID'=>'asc','Name'=>'desc'));
278 278
 		$this->assertEquals('Joe', $list->first()->Name, 'First comment should be from Bob');
279 279
 		$this->assertEquals('Phil', $list->last()->Name, 'Last comment should be from Phil');
@@ -283,7 +283,7 @@ public function testSortWithMultipleArraySyntaxSort() {
283 283
 	 * $list->filter('Name', 'bob'); // only bob in the list
284 284
 	 */
285 285
 	public function testSimpleFilter() {
286  
-		$list = DataList::create("DataObjectTest_Team");
  286
+		$list = DataObjectTest_Team::get();
287 287
 		$list->filter('Title','Team 2');
288 288
 		$this->assertEquals(1, $list->count());
289 289
 		$this->assertEquals('Team 2', $list->first()->Title, 'List should only contain Team 2');
@@ -291,28 +291,28 @@ public function testSimpleFilter() {
291 291
 	}
292 292
 	
293 293
 	public function testSimpleFilterEndsWith() {
294  
-		$list = DataList::create("DataObjectTest_TeamComment");
  294
+		$list = DataObjectTest_TeamComment::get();
295 295
 		$list->filter('Name:EndsWith', 'b');
296 296
 		$this->assertEquals(1, $list->count());
297 297
 		$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
298 298
 	}
299 299
 
300 300
 	public function testSimpleFilterExactMatchFilter() {
301  
-		$list = DataList::create("DataObjectTest_TeamComment");
  301
+		$list = DataObjectTest_TeamComment::get();
302 302
 		$list->filter('Name:ExactMatch', 'Bob');
303 303
 		$this->assertEquals(1, $list->count());
304 304
 		$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
305 305
 	}
306 306
 
307 307
 	public function testSimpleFilterGreaterThanFilter() {
308  
-		$list = DataList::create("DataObjectTest_TeamComment");
  308
+		$list = DataObjectTest_TeamComment::get();
309 309
 		$list->filter('TeamID:GreaterThan', $this->idFromFixture('DataObjectTest_Team', 'team1'));
310 310
 		$this->assertEquals(1, $list->count());
311 311
 		$this->assertEquals('Phil', $list->first()->Name, 'First comment should be from Bob');
312 312
 	}
313 313
 
314 314
 	// public function testSimpleFilterLessThanFilter() {
315  
-	// 	$list = DataList::create("DataObjectTest_TeamComment");
  315
+	// 	$list = DataObjectTest_TeamComment::get();
316 316
 	// 	$list = $list->filter('TeamID:LessThan', $this->idFromFixture('DataObjectTest_TeamComment', 'comment2'))->sort('Name');
317 317
 	// 	$this->assertEquals(2, $list->count());
318 318
 	// 	$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
@@ -320,14 +320,14 @@ public function testSimpleFilterGreaterThanFilter() {
320 320
 	// }
321 321
 
322 322
 	public function testSimpleNegationFilter() {
323  
-		$list = DataList::create("DataObjectTest_TeamComment");
  323
+		$list = DataObjectTest_TeamComment::get();
324 324
 		$list->filter('TeamID:Negation', $this->idFromFixture('DataObjectTest_Team', 'team1'));
325 325
 		$this->assertEquals(1, $list->count());
326 326
 		$this->assertEquals('Phil', $list->first()->Name, 'First comment should be from Bob');
327 327
 	}
328 328
 
329 329
 	public function testSimplePartialMatchFilter() {
330  
-		$list = DataList::create("DataObjectTest_TeamComment");
  330
+		$list = DataObjectTest_TeamComment::get();
331 331
 		$list->filter('Name:PartialMatch', 'o')->sort('Name');
332 332
 		$this->assertEquals(2, $list->count());
333 333
 		$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
@@ -335,7 +335,7 @@ public function testSimplePartialMatchFilter() {
335 335
 	}
336 336
 
337 337
 	public function testSimpleFilterStartsWith() {
338  
-		$list = DataList::create("DataObjectTest_TeamComment");
  338
+		$list = DataObjectTest_TeamComment::get();
339 339
 		$list->filter('Name:StartsWith', 'B');
340 340
 		$this->assertEquals(1, $list->count());
341 341
 		$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
@@ -343,7 +343,7 @@ public function testSimpleFilterStartsWith() {
343 343
 
344 344
 	public function testSimpleFilterWithNonExistingComparisator() {
345 345
 		$this->setExpectedException('InvalidArgumentException');
346  
-		$list = DataList::create("DataObjectTest_TeamComment");
  346
+		$list = DataObjectTest_TeamComment::get();
347 347
 		$list->filter('Comment:Bogus', 'team comment');
348 348
 	}
349 349
 
@@ -351,7 +351,7 @@ public function testSimpleFilterWithNonExistingComparisator() {
351 351
 	 * $list->filter('Name', array('aziz', 'bob'); // aziz and bob in list
352 352
 	 */
353 353
 	public function testSimpleFilterWithMultiple() {
354  
-		$list = DataList::create("DataObjectTest_TeamComment");
  354
+		$list = DataObjectTest_TeamComment::get();
355 355
 		$list->filter('Name', array('Bob','Phil'));
356 356
 		$this->assertEquals(2, $list->count());
357 357
 		$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
@@ -359,7 +359,7 @@ public function testSimpleFilterWithMultiple() {
359 359
 	}
360 360
 	
361 361
 	public function testMultipleFilterWithNoMatch() {
362  
-		$list = DataList::create("DataObjectTest_TeamComment");
  362
+		$list = DataObjectTest_TeamComment::get();
363 363
 		$list->filter(array('Name'=>'Bob', 'Comment'=>'Phil is a unique guy, and comments on team2'));
364 364
 		$this->assertEquals(0, $list->count());
365 365
 	}
@@ -368,20 +368,20 @@ public function testMultipleFilterWithNoMatch() {
368 368
 	 *  $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the age 21
369 369
 	 */
370 370
 	public function testFilterMultipleArray() {
371  
-		$list = DataList::create("DataObjectTest_TeamComment");
  371
+		$list = DataObjectTest_TeamComment::get();
372 372
 		$list->filter(array('Name'=>'Bob', 'Comment'=>'This is a team comment by Bob'));
373 373
 		$this->assertEquals(1, $list->count());
374 374
 		$this->assertEquals('Bob', $list->first()->Name, 'Only comment should be from Bob');
375 375
 	}
376 376
 	
377 377
 	public function testFilterMultipleWithTwoMatches() {
378  
-		$list = DataList::create("DataObjectTest_TeamComment");
  378
+		$list = DataObjectTest_TeamComment::get();
379 379
 		$list->filter(array('TeamID'=>$this->idFromFixture('DataObjectTest_Team', 'team1')));
380 380
 		$this->assertEquals(2, $list->count());
381 381
 	}
382 382
 	
383 383
 	public function testFilterMultipleWithArrayFilter() {
384  
-		$list = DataList::create("DataObjectTest_TeamComment");
  384
+		$list = DataObjectTest_TeamComment::get();
385 385
 		$list->filter(array('Name'=>array('Bob','Phil')));
386 386
 		$this->assertEquals(2, $list->count(), 'There should be two comments');
387 387
 		$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
@@ -392,7 +392,7 @@ public function testFilterMultipleWithArrayFilter() {
392 392
 	 * $list->filter(array('Name'=>array('aziz','bob'), 'Age'=>array(21, 43)));
393 393
 	 */
394 394
 	public function testFilterArrayInArray() {
395  
-		$list = DataList::create("DataObjectTest_TeamComment");
  395
+		$list = DataObjectTest_TeamComment::get();
396 396
 		$list->filter(array('Name'=>array('Bob','Phil'), 'TeamID'=>array($this->idFromFixture('DataObjectTest_Team', 'team1'))));
397 397
 		$this->assertEquals(1, $list->count(), 'There should be one comments');
398 398
 		$this->assertEquals('Bob', $list->first()->Name, 'Only comment should be from Bob');
@@ -402,7 +402,7 @@ public function testFilterArrayInArray() {
402 402
 	 * $list->exclude('Name', 'bob'); // exclude bob from list
403 403
 	 */
404 404
 	public function testSimpleExclude() {
405  
-		$list = DataList::create("DataObjectTest_TeamComment");
  405
+		$list = DataObjectTest_TeamComment::get();
406 406
 		$list->exclude('Name', 'Bob');
407 407
 		$list->sort('Name');
408 408
 		$this->assertEquals(2, $list->count());
@@ -414,7 +414,7 @@ public function testSimpleExclude() {
414 414
 	 * $list->exclude('Name', array('aziz', 'bob'); // exclude aziz and bob from list
415 415
 	 */
416 416
 	public function testSimpleExcludeWithMultiple() {
417  
-		$list = DataList::create("DataObjectTest_TeamComment");
  417
+		$list = DataObjectTest_TeamComment::get();
418 418
 		$list->exclude('Name', array('Joe','Phil'));
419 419
 		$this->assertEquals(1, $list->count());
420 420
 		$this->assertEquals('Bob', $list->first()->Name, 'First comment should be from Bob');
@@ -424,7 +424,7 @@ public function testSimpleExcludeWithMultiple() {
424 424
 	 * $list->exclude(array('Name'=>'bob, 'Age'=>21)); // negative version
425 425
 	 */
426 426
 	public function testMultipleExcludeWithMiss() {
427  
-		$list = DataList::create("DataObjectTest_TeamComment");
  427
+		$list = DataObjectTest_TeamComment::get();
428 428
 		$list->exclude(array('Name'=>'Bob', 'Comment'=>'Does not match any comments'));
429 429
 		$this->assertEquals(3, $list->count());
430 430
 	}
@@ -433,7 +433,7 @@ public function testMultipleExcludeWithMiss() {
433 433
 	 * $list->exclude(array('Name'=>'bob, 'Age'=>21)); // exclude bob that has Age 21
434 434
 	 */
435 435
 	public function testMultipleExclude() {
436  
-		$list = DataList::create("DataObjectTest_TeamComment");
  436
+		$list = DataObjectTest_TeamComment::get();
437 437
 		$list->exclude(array('Name'=>'Bob', 'Comment'=>'This is a team comment by Bob'));
438 438
 		$this->assertEquals(2, $list->count());
439 439
 	}
@@ -442,7 +442,7 @@ public function testMultipleExclude() {
442 442
 	 * $list->exclude(array('Name'=>'bob, 'Age'=>array(21, 43))); // exclude bob with Age 21 or 43
443 443
 	 */
444 444
 	public function testMultipleExcludeWithMultipleThatCheersEitherTeam() {
445  
-		$list = DataList::create("DataObjectTest_TeamComment");
  445
+		$list = DataObjectTest_TeamComment::get();
446 446
 		$list->exclude(array('Name'=>'Bob', 'TeamID'=>array(
447 447
 			$this->idFromFixture('DataObjectTest_Team', 'team1'),
448 448
 			$this->idFromFixture('DataObjectTest_Team', 'team2')
@@ -457,7 +457,7 @@ public function testMultipleExcludeWithMultipleThatCheersEitherTeam() {
457 457
 	 * $list->exclude(array('Name'=>'bob, 'Age'=>array(21, 43))); // negative version
458 458
 	 */
459 459
 	public function testMultipleExcludeWithMultipleThatCheersOnNonExistingTeam() {
460  
-		$list = DataList::create("DataObjectTest_TeamComment");
  460
+		$list = DataObjectTest_TeamComment::get();
461 461
 		$list->exclude(array('Name'=>'Bob', 'TeamID'=>array(3)));
462 462
 		$this->assertEquals(3, $list->count());
463 463
 	}
@@ -466,7 +466,7 @@ public function testMultipleExcludeWithMultipleThatCheersOnNonExistingTeam() {
466 466
 	 * $list->exclude(array('Name'=>array('bob','phil'), 'Age'=>array(21, 43))); //negative version
467 467
 	 */
468 468
 	public function testMultipleExcludeWithNoExclusion() {
469  
-		$list = DataList::create("DataObjectTest_TeamComment");
  469
+		$list = DataObjectTest_TeamComment::get();
470 470
 		$list->exclude(array('Name'=>array('Bob','Joe'), 'Comment' => 'Phil is a unique guy, and comments on team2'));
471 471
 		$this->assertEquals(3, $list->count());
472 472
 	}
@@ -475,7 +475,7 @@ public function testMultipleExcludeWithNoExclusion() {
475 475
 	 *  $list->exclude(array('Name'=>array('bob','phil'), 'Age'=>array(21, 43))); 
476 476
 	 */
477 477
 	public function testMultipleExcludeWithTwoArray() {
478  
-		$list = DataList::create("DataObjectTest_TeamComment");
  478
+		$list = DataObjectTest_TeamComment::get();
479 479
 		$list->exclude(array('Name' => array('Bob','Joe'), 'TeamID' => array(
480 480
 			$this->idFromFixture('DataObjectTest_Team', 'team1'),
481 481
 			$this->idFromFixture('DataObjectTest_Team', 'team2')
@@ -488,7 +488,7 @@ public function testMultipleExcludeWithTwoArray() {
488 488
 	 *  $list->exclude(array('Name'=>array('bob','phil'), 'Age'=>array(21, 43))); 
489 489
 	 */
490 490
 	public function testMultipleExcludeWithTwoArrayOneTeam() {
491  
-		$list = DataList::create("DataObjectTest_TeamComment");
  491
+		$list = DataObjectTest_TeamComment::get();
492 492
 		$list->exclude(array('Name' => array('Bob', 'Phil'), 'TeamID' => array($this->idFromFixture('DataObjectTest_Team', 'team1'))));
493 493
 		$list->sort('Name');
494 494
 		$this->assertEquals(2, $list->count());
@@ -500,7 +500,7 @@ public function testMultipleExcludeWithTwoArrayOneTeam() {
500 500
 	 * 
501 501
 	 */
502 502
 	public function testSortByRelation() {
503  
-		$list = DataList::create("DataObjectTest_TeamComment");
  503
+		$list = DataObjectTest_TeamComment::get();
504 504
 		$list = $list->sort(array('Team.Title' => 'DESC'));
505 505
 		$this->assertEquals(3, $list->count());
506 506
 		$this->assertEquals($this->idFromFixture('DataObjectTest_Team', 'team2'), $list->first()->TeamID, 'First comment should be for Team 2');
@@ -508,7 +508,7 @@ public function testSortByRelation() {
508 508
 	}
509 509
 	
510 510
 	public function testReverse() {
511  
-		$list = DataList::create("DataObjectTest_TeamComment");
  511
+		$list = DataObjectTest_TeamComment::get();
512 512
 		$list->sort('Name');
513 513
 		$list->reverse();
514 514
 		
2  tests/model/ManyManyListTest.php
@@ -85,7 +85,7 @@ public function testAddingWithMultipleForeignKeys() {
85 85
 		$team1 = $this->objFromFixture('DataObjectTest_Team', 'team1');
86 86
 		$team2 = $this->objFromFixture('DataObjectTest_Team', 'team2');
87 87
 
88  
-		$playersTeam1Team2 = DataList::create('DataObjectTest_Team')->relation('Players')->setForeignID(array($team1->ID, $team2->ID));
  88
+		$playersTeam1Team2 = DataObjectTest_Team::get()->relation('Players')->setForeignID(array($team1->ID, $team2->ID));
89 89
 		$playersTeam1Team2->add($newPlayer);
90 90
 		$this->assertEquals(
91 91
 			array($team1->ID, $team2->ID),
18  tests/model/MapTest.php
@@ -17,14 +17,14 @@ class SS_MapTest extends SapphireTest {
17 17
 	);
18 18
 	
19 19
 	function testArrayAccess() {
20  
-		$list = DataList::create("DataObjectTest_TeamComment");
  20
+		$list = DataObjectTest_TeamComment::get();
21 21
 		$map = new SS_Map($list, 'Name', 'Comment');
22 22
 		$this->assertEquals('This is a team comment by Joe', $map['Joe']);
23 23
 		$this->assertNull($map['DoesntExist']);
24 24
 	}
25 25
 
26 26
 	function testIteration() {
27  
-		$list = DataList::create("DataObjectTest_TeamComment")->sort('ID');
  27
+		$list = DataObjectTest_TeamComment::get()->sort('ID');
28 28
 		$map = new SS_Map($list, 'Name', 'Comment');
29 29
 		$text = "";
30 30
 		foreach($map as $k => $v) {
@@ -36,13 +36,13 @@ function testIteration() {
36 36
 	}
37 37
 	
38 38
 	function testDefaultConfigIsIDAndTitle() {
39  
-		$list = DataList::create("DataObjectTest_Team");
  39
+		$list = DataObjectTest_Team::get();
40 40
 		$map = new SS_Map($list);
41 41
 		$this->assertEquals('Team 1', $map[$this->idFromFixture('DataObjectTest_Team', 'team1')]);
42 42
 	}
43 43
 	
44 44
 	function testSetKeyFieldAndValueField() {
45  
-		$list = DataList::create("DataObjectTest_TeamComment");
  45
+		$list = DataObjectTest_TeamComment::get();
46 46
 		$map = new SS_Map($list);
47 47
 		$map->setKeyField('Name');
48 48
 		$map->setValueField('Comment');
@@ -50,7 +50,7 @@ function testSetKeyFieldAndValueField() {
50 50
 	}
51 51
 	
52 52
 	function testToArray() {
53  
-		$list = DataList::create("DataObjectTest_TeamComment");
  53
+		$list = DataObjectTest_TeamComment::get();
54 54
 		$map = new SS_Map($list, 'Name', 'Comment');
55 55
 		$this->assertEquals(array("Joe" => "This is a team comment by Joe",
56 56
 			"Bob" => "This is a team comment by Bob",
@@ -58,7 +58,7 @@ function testToArray() {
58 58
 	}
59 59
 
60 60
 	function testKeys() {
61  
-		$list = DataList::create('DataObjectTest_TeamComment');
  61
+		$list = DataObjectTest_TeamComment::get();
62 62
 		$list->sort('Name');
63 63
 		$map = new SS_Map($list, 'Name', 'Comment');
64 64
 		$this->assertEquals(array(
@@ -69,7 +69,7 @@ function testKeys() {
69 69
 	}
70 70
 
71 71
 	function testMethodAsValueField() {
72  
-		$list = DataList::create('DataObjectTest_Team');
  72
+		$list = DataObjectTest_Team::get();
73 73
 		$list->sort('Title');
74 74
 		$map = new SS_Map($list, 'ID', 'MyTitle');
75 75
 		$this->assertEquals(array(
@@ -83,7 +83,7 @@ function testMethodAsValueField() {
83 83
 	}
84 84
 
85 85
 	function testValues() {
86  
-		$list = DataList::create('DataObjectTest_TeamComment');
  86
+		$list = DataObjectTest_TeamComment::get();
87 87
 		$list->sort('Name');
88 88
 		$map = new SS_Map($list, 'Name', 'Comment');
89 89
 		$this->assertEquals(array(
@@ -94,7 +94,7 @@ function testValues() {
94 94
 	}
95 95
 
96 96
 	function testUnshift() {
97  
-		$list = DataList::create("DataObjectTest_TeamComment");
  97
+		$list = DataObjectTest_TeamComment::get();
98 98
 		$map = new SS_Map($list, 'Name', 'Comment');
99 99
 
100 100
 		$map->unshift(-1, '(All)');

0 notes on commit c3eabff

Please sign in to comment.
Something went wrong with that request. Please try again.