Skip to content
This repository
Browse code

Added default sort to test data for better cross-db performance.

  • Loading branch information...
commit f6334dd01774d36e1e3453ccafb7db69b8a2f30d 1 parent 5c6707d
Sam Minnée authored August 21, 2012
17  tests/model/DataObjectLazyLoadingTest.php
@@ -28,8 +28,10 @@ function testQueriedColumnsID() {
28 28
 		$expected = 'SELECT DISTINCT "DataObjectTest_Team"."ClassName", "DataObjectTest_Team"."Created", ' .
29 29
 			'"DataObjectTest_Team"."LastEdited", "DataObjectTest_Team"."ID", CASE WHEN '.
30 30
 			'"DataObjectTest_Team"."ClassName" IS NOT NULL THEN "DataObjectTest_Team"."ClassName" ELSE ' .
31  
-			$db->prepStringForDB('DataObjectTest_Team').' END AS "RecordClassName" FROM "DataObjectTest_Team" WHERE ' .
32  
-			'("DataObjectTest_Team"."ClassName" IN ('.$db->prepStringForDB('DataObjectTest_SubTeam').'))';
  31
+			$db->prepStringForDB('DataObjectTest_Team').' END AS "RecordClassName", "DataObjectTest_Team"."Title" '.
  32
+			'FROM "DataObjectTest_Team" ' .
  33
+			'WHERE ("DataObjectTest_Team"."ClassName" IN ('.$db->prepStringForDB('DataObjectTest_SubTeam').'))' .
  34
+			' ORDER BY "DataObjectTest_Team"."Title" ASC';
33 35
 		$this->assertEquals($expected, $playerList->sql());
34 36
 	}
35 37
 
@@ -43,7 +45,8 @@ function testQueriedColumnsFromBaseTableAndSubTable() {
43 45
 			'"DataObjectTest_Team"."ClassName" IS NOT NULL THEN "DataObjectTest_Team"."ClassName" ELSE ' .
44 46
 			$db->prepStringForDB('DataObjectTest_Team').' END AS "RecordClassName" FROM "DataObjectTest_Team" LEFT JOIN ' .
45 47
 			'"DataObjectTest_SubTeam" ON "DataObjectTest_SubTeam"."ID" = "DataObjectTest_Team"."ID" WHERE ' .
46  
-			'("DataObjectTest_Team"."ClassName" IN ('.$db->prepStringForDB('DataObjectTest_SubTeam').'))';
  48
+			'("DataObjectTest_Team"."ClassName" IN ('.$db->prepStringForDB('DataObjectTest_SubTeam').')) ' .
  49
+			'ORDER BY "DataObjectTest_Team"."Title" ASC';
47 50
 		$this->assertEquals($expected, $playerList->sql());
48 51
 	}
49 52
 
@@ -55,7 +58,8 @@ function testQueriedColumnsFromBaseTable() {
55 58
 			'"DataObjectTest_Team"."LastEdited", "DataObjectTest_Team"."Title", "DataObjectTest_Team"."ID", ' .
56 59
 			'CASE WHEN "DataObjectTest_Team"."ClassName" IS NOT NULL THEN "DataObjectTest_Team"."ClassName" ELSE ' .
57 60
 			$db->prepStringForDB('DataObjectTest_Team').' END AS "RecordClassName" FROM "DataObjectTest_Team" WHERE ' .
58  
-			'("DataObjectTest_Team"."ClassName" IN ('.$db->prepStringForDB('DataObjectTest_SubTeam').'))';
  61
+			'("DataObjectTest_Team"."ClassName" IN ('.$db->prepStringForDB('DataObjectTest_SubTeam').')) ' .
  62
+			'ORDER BY "DataObjectTest_Team"."Title" ASC';
59 63
 		$this->assertEquals($expected, $playerList->sql());
60 64
 	}
61 65
 
@@ -66,9 +70,10 @@ function testQueriedColumnsFromSubTable() {
66 70
 		$expected = 'SELECT DISTINCT "DataObjectTest_Team"."ClassName", "DataObjectTest_Team"."Created", ' .
67 71
 			'"DataObjectTest_Team"."LastEdited", "DataObjectTest_SubTeam"."SubclassDatabaseField", ' .
68 72
 			'"DataObjectTest_Team"."ID", CASE WHEN "DataObjectTest_Team"."ClassName" IS NOT NULL THEN ' .
69  
-			'"DataObjectTest_Team"."ClassName" ELSE '.$db->prepStringForDB('DataObjectTest_Team').' END AS "RecordClassName" FROM ' .
  73
+			'"DataObjectTest_Team"."ClassName" ELSE '.$db->prepStringForDB('DataObjectTest_Team').' END AS "RecordClassName", "DataObjectTest_Team"."Title" FROM ' .
70 74
 			'"DataObjectTest_Team" LEFT JOIN "DataObjectTest_SubTeam" ON "DataObjectTest_SubTeam"."ID" = ' .
71  
-			'"DataObjectTest_Team"."ID" WHERE ("DataObjectTest_Team"."ClassName" IN ('.$db->prepStringForDB('DataObjectTest_SubTeam').'))';
  75
+			'"DataObjectTest_Team"."ID" WHERE ("DataObjectTest_Team"."ClassName" IN ('.$db->prepStringForDB('DataObjectTest_SubTeam').')) ' . 
  76
+			'ORDER BY "DataObjectTest_Team"."Title" ASC';
72 77
 		$this->assertEquals($expected, $playerList->sql());
73 78
 	}
74 79
 
2  tests/model/DataObjectTest.php
@@ -1111,6 +1111,8 @@ class DataObjectTest_Team extends DataObject implements TestOnly {
1111 1111
 		)
1112 1112
 	);
1113 1113
 
  1114
+	static $default_sort = "Title";
  1115
+
1114 1116
 	function MyTitle() {
1115 1117
 		return 'Team ' . $this->Title;
1116 1118
 	}

0 notes on commit f6334dd

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