diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 9d9cf429d97..5e896795dee 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -2027,13 +2027,10 @@ public function testCreationWithMultipleData() { $articles = $Article->find('all', array( 'fields' => array('id','title'), - 'recursive' => -1 + 'recursive' => -1, + 'order' => array('Article.id' => 'ASC') )); - - $comments = $Comment->find('all', array( - 'fields' => array('id','article_id','user_id','comment','published'), 'recursive' => -1)); - - $this->assertEquals($articles, array( + $expected = array( array('Article' => array( 'id' => 1, 'title' => 'First Article' @@ -2045,9 +2042,15 @@ public function testCreationWithMultipleData() { array('Article' => array( 'id' => 3, 'title' => 'Third Article' - )))); + ))); + $this->assertEquals($expected, $articles); - $this->assertEquals($comments, array( + $comments = $Comment->find('all', array( + 'fields' => array('id','article_id','user_id','comment','published'), + 'recursive' => -1, + 'order' => array('Comment.id' => 'ASC') + )); + $expected = array( array('Comment' => array( 'id' => 1, 'article_id' => 1, @@ -2089,7 +2092,8 @@ public function testCreationWithMultipleData() { 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y' - )))); + ))); + $this->assertEquals($expected, $comments); $data = array( 'Comment' => array( @@ -2102,24 +2106,18 @@ public function testCreationWithMultipleData() { 'id' => 2, 'title' => 'Second Article Modified' )); - $result = $Comment->create($data); - $this->assertFalse(empty($result)); + $result = $Comment->save(); $this->assertFalse(empty($result)); $articles = $Article->find('all', array( 'fields' => array('id','title'), - 'recursive' => -1 - )); - - $comments = $Comment->find('all', array( - 'fields' => array('id','article_id','user_id','comment','published'), - 'recursive' => -1 + 'recursive' => -1, + 'order' => array('Article.id' => 'ASC') )); - - $this->assertEquals($articles, array( + $expected = array( array('Article' => array( 'id' => 1, 'title' => 'First Article' @@ -2131,9 +2129,16 @@ public function testCreationWithMultipleData() { array('Article' => array( 'id' => 3, 'title' => 'Third Article' - )))); + ))); - $this->assertEquals($comments, array( + $this->assertEquals($expected, $articles); + + $comments = $Comment->find('all', array( + 'fields' => array('id','article_id','user_id','comment','published'), + 'recursive' => -1, + 'order' => array('Comment.id' => 'ASC') + )); + $expected = array( array('Comment' => array( 'id' => 1, 'article_id' => 1, @@ -2182,8 +2187,8 @@ public function testCreationWithMultipleData() { 'user_id' => 4, 'comment' => 'Brand New Comment', 'published' => 'N' - )))); - + ))); + $this->assertEquals($expected, $comments); } /** @@ -2197,7 +2202,7 @@ public function testCreationWithMultipleDataSameModel() { $SecondaryArticle = new Article(); $result = $Article->field('title', array('id' => 1)); - $this->assertEquals($result, 'First Article'); + $this->assertEquals('First Article', $result); $data = array( 'Article' => array( @@ -2222,10 +2227,10 @@ public function testCreationWithMultipleDataSameModel() { $articles = $Article->find('all', array( 'fields' => array('id','title'), - 'recursive' => -1 + 'recursive' => -1, + 'order' => array('Article.id' => 'ASC') )); - - $this->assertEquals($articles, array( + $expected = array( array('Article' => array( 'id' => 1, 'title' => 'First Article' @@ -2241,7 +2246,9 @@ public function testCreationWithMultipleDataSameModel() { array('Article' => array( 'id' => 4, 'title' => 'Brand New Article' - )))); + ))); + + $this->assertEquals($expected, $articles); } /** @@ -2255,7 +2262,7 @@ public function testCreationWithMultipleDataSameModelManualInstances() { $Secondary = new PrimaryModel(); $result = $Primary->field('primary_name', array('id' => 1)); - $this->assertEquals($result, 'Primary Name Existing'); + $this->assertEquals('Primary Name Existing', $result); $data = array( 'PrimaryModel' => array( @@ -2270,16 +2277,16 @@ public function testCreationWithMultipleDataSameModelManualInstances() { $this->assertFalse(empty($result)); $result = $Primary->field('primary_name', array('id' => 1)); - $this->assertEquals($result, 'Primary Name Existing'); + $this->assertEquals('Primary Name Existing', $result); $result = $Primary->getInsertID(); $this->assertTrue(!empty($result)); $result = $Primary->field('primary_name', array('id' => $result)); - $this->assertEquals($result, 'Primary Name New'); + $this->assertEquals('Primary Name New', $result); $result = $Primary->find('count'); - $this->assertEquals($result, 2); + $this->assertEquals(2, $result); } /**