Skip to content
This repository
Browse code

MINOR Fixed failing tests on pgsql

  • Loading branch information...
commit 6c9a3ba9f0ac97460cce8c9117ef7978d7865f00 1 parent 1742b4b
Sean Harvey authored April 10, 2012
8  tests/forms/ListboxFieldTest.php
@@ -117,19 +117,19 @@ function testSaveIntoManyManyRelation() {
117 117
 		$field->setValue(array($tag1->ID,$tag2->ID));
118 118
 		$field->saveInto($article);
119 119
 		$article = Dataobject::get_by_id('ListboxFieldTest_Article', $article->ID, false);
120  
-		$this->assertEquals(array($tag1->ID, $tag2->ID), $article->Tags()->column('ID'));
  120
+		$this->assertEquals(array($tag1->ID, $tag2->ID), $article->Tags()->sort('ID')->column('ID'));
121 121
 
122 122
 		// Remove existing relation
123 123
 		$field->setValue(array($tag1->ID));
124 124
 		$field->saveInto($article);
125 125
 		$article = Dataobject::get_by_id('ListboxFieldTest_Article', $article->ID, false);
126  
-		$this->assertEquals(array($tag1->ID), $article->Tags()->column('ID'));
  126
+		$this->assertEquals(array($tag1->ID), $article->Tags()->sort('ID')->column('ID'));
127 127
 
128 128
 		// Set NULL value
129 129
 		$field->setValue(null);
130 130
 		$field->saveInto($article);
131 131
 		$article = Dataobject::get_by_id('ListboxFieldTest_Article', $article->ID, false);
132  
-		$this->assertEquals(array(), $article->Tags()->column('ID'));
  132
+		$this->assertEquals(array(), $article->Tags()->sort('ID')->column('ID'));
133 133
 	}
134 134
 	
135 135
 	/**
@@ -216,4 +216,4 @@ class ListboxFieldTest_Tag extends DataObject implements TestOnly {
216 216
 	static $belongs_many_many = array(
217 217
 		'Articles' => 'ListboxFieldTest_Article'
218 218
 	);
219  
-}
  219
+}
38  tests/forms/gridfield/GridFieldDetailFormTest.php
@@ -8,13 +8,13 @@ class GridFieldDetailFormTest extends FunctionalTest {
8 8
 		'GridFieldDetailFormTest_PeopleGroup',
9 9
 		'GridFieldDetailFormTest_Category',
10 10
 	);
11  
-	
12 11
 
13 12
 	function testAddForm() {
14 13
 		$this->logInWithPermission('ADMIN');
15 14
 		$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
16  
-		            ->filter('Name', 'My Group')
17  
-		            ->First();
  15
+			->filter('Name', 'My Group')
  16
+			->sort('Name')
  17
+			->First();
18 18
 		$count = $group->People()->Count();
19 19
 
20 20
 		$response = $this->get('GridFieldDetailFormTest_Controller');
@@ -41,16 +41,18 @@ function testAddForm() {
41 41
 		$this->assertFalse($response->isError());
42 42
 
43 43
 		$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
44  
-            ->filter('Name', 'My Group')
45  
-            ->First();
46  
-        $this->assertEquals($count + 1, $group->People()->Count());
  44
+			->filter('Name', 'My Group')
  45
+			->sort('Name')
  46
+			->First();
  47
+		$this->assertEquals($count + 1, $group->People()->Count());
47 48
 	}
48 49
 
49 50
 	function testEditForm() {
50 51
 		$this->logInWithPermission('ADMIN');
51 52
 		$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
52  
-		            ->filter('Name', 'My Group')
53  
-		            ->First();
  53
+			->filter('Name', 'My Group')
  54
+			->sort('Name')
  55
+			->First();
54 56
 		$firstperson = $group->People()->First();
55 57
 		$this->assertTrue($firstperson->Surname != 'Baggins');
56 58
 
@@ -78,10 +80,11 @@ function testEditForm() {
78 80
 		$this->assertFalse($response->isError());
79 81
 
80 82
 		$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
81  
-            ->filter('Name', 'My Group')
82  
-            ->First();
83  
-        $firstperson = $group->People()->First();
84  
-        $this->assertEquals($firstperson->Surname, 'Baggins');
  83
+			->filter('Name', 'My Group')
  84
+			->sort('Name')
  85
+			->First();
  86
+		$firstperson = $group->People()->First();
  87
+		$this->assertEquals($firstperson->Surname, 'Baggins');
85 88
 	}
86 89
 
87 90
 	function testNestedEditForm() {
@@ -108,7 +111,7 @@ function testNestedEditForm() {
108 111
 		$parser = new CSSContentParser($response->getBody());
109 112
 		$personEditLink = $parser->getByXpath('//fieldset[@id="Form_ItemEditForm_People"]//tr[contains(@class, "ss-gridfield-item") and contains(@data-id, "' . $person->ID . '")]//a');		
110 113
 		$this->assertEquals(
111  
-			'GridFieldDetailFormTest_GroupController/Form/field/testfield/item/1/ItemEditForm/field/People/item/' . $person->ID . '/edit',
  114
+			sprintf('GridFieldDetailFormTest_GroupController/Form/field/testfield/item/%d/ItemEditForm/field/People/item/%d/edit', $group->ID, $person->ID),
112 115
 			(string)$personEditLink[0]['href']
113 116
 		);
114 117
 
@@ -118,7 +121,7 @@ function testNestedEditForm() {
118 121
 		$parser = new CSSContentParser($response->getBody());
119 122
 		$categoryEditLink = $parser->getByXpath('//fieldset[@id="Form_ItemEditForm_Categories"]//tr[contains(@class, "ss-gridfield-item") and contains(@data-id, "' . $category->ID . '")]//a');	
120 123
 		$this->assertEquals(
121  
-			'GridFieldDetailFormTest_GroupController/Form/field/testfield/item/1/ItemEditForm/field/People/item/' . $category->ID . '/ItemEditForm/field/Categories/item/1/edit',
  124
+			sprintf('GridFieldDetailFormTest_GroupController/Form/field/testfield/item/%d/ItemEditForm/field/People/item/%d/ItemEditForm/field/Categories/item/%d/edit', $group->ID, $person->ID, $category->ID),
122 125
 			(string)$categoryEditLink[0]['href']
123 126
 		);
124 127
 
@@ -202,8 +205,9 @@ class GridFieldDetailFormTest_Controller extends Controller implements TestOnly
202 205
 
203 206
 	function Form() {
204 207
 		$group = DataList::create('GridFieldDetailFormTest_PeopleGroup')
205  
-		            ->filter('Name', 'My Group')
206  
-		            ->First();
  208
+			->filter('Name', 'My Group')
  209
+			->sort('Name')
  210
+			->First();
207 211
 
208 212
 		$field = new GridField('testfield', 'testfield', $group->People());
209 213
 		$field->getConfig()->addComponent(new GridFieldToolbarHeader());
@@ -219,7 +223,7 @@ class GridFieldDetailFormTest_GroupController extends Controller implements Test
219 223
 	protected $template = 'BlankPage';
220 224
 
221 225
 	function Form() {
222  
-		$field = new GridField('testfield', 'testfield', DataList::create('GridFieldDetailFormTest_PeopleGroup'));
  226
+		$field = new GridField('testfield', 'testfield', DataList::create('GridFieldDetailFormTest_PeopleGroup')->sort('Name'));
223 227
 		$field->getConfig()->addComponent($gridFieldForm = new GridFieldDetailForm($this, 'Form'));
224 228
 		$field->getConfig()->addComponent(new GridFieldToolbarHeader());
225 229
 		$field->getConfig()->addComponent(new GridFieldAddNewButton('toolbar-header-right'));
10  tests/model/ManyManyListTest.php
@@ -72,11 +72,11 @@ public function testSetByIdList() {
72 72
 		$team1 = $this->objFromFixture('DataObjectTest_Team', 'team1');
73 73
 		$team2 = $this->objFromFixture('DataObjectTest_Team', 'team2');
74 74
 		$player1->Teams()->setByIdList(array($team1->ID, $team2->ID));
75  
-		$this->assertEquals(array($team1->ID, $team2->ID), $player1->Teams()->column());
  75
+		$this->assertEquals(array($team1->ID, $team2->ID), $player1->Teams()->sort('Title')->column());
76 76
 		$player1->Teams()->setByIdList(array($team1->ID));
77  
-		$this->assertEquals(array($team1->ID), $player1->Teams()->column());
  77
+		$this->assertEquals(array($team1->ID), $player1->Teams()->sort('Title')->column());
78 78
 		$player1->Teams()->setByIdList(array($team2->ID));
79  
-		$this->assertEquals(array($team2->ID), $player1->Teams()->column());
  79
+		$this->assertEquals(array($team2->ID), $player1->Teams()->sort('Title')->column());
80 80
 	}
81 81
 
82 82
 	public function testAddingWithMultipleForeignKeys() {
@@ -89,7 +89,7 @@ public function testAddingWithMultipleForeignKeys() {
89 89
 		$playersTeam1Team2->add($newPlayer);
90 90
 		$this->assertEquals(
91 91
 			array($team1->ID, $team2->ID),
92  
-			$newPlayer->Teams()->column('ID')
  92
+			$newPlayer->Teams()->sort('Title')->column('ID')
93 93
 		);
94 94
 	}
95 95
 	
@@ -115,4 +115,4 @@ public function testSubtractOnAManyManyList() {
115 115
 		$this->assertEquals(1,$teamsWithoutTheCaptain->count(), 'The ManyManyList should onlu contain one team');
116 116
 		$this->assertEquals($teamTwoID, $teamsWithoutTheCaptain->first()->ID, 'The ManyManyList contains the wrong team');
117 117
 	}
118  
-}
  118
+}

0 notes on commit 6c9a3ba

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