Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Several fixes for testcases.

- Ensure correct ordering of find results
- avoid fatal error when testing email transport classes on 5.2
- add skips when running cross db join tests and multiple sqlite configs are defined
  • Loading branch information...
commit 40f4f54b349a1d7675de6adeee61aeaa217ae2a6 1 parent b871095
@ceeram ceeram authored
View
3  lib/Cake/Test/Case/Model/ModelCrossSchemaHabtmTest.php
@@ -63,6 +63,7 @@ public function setUp() {
*/
protected function _checkConfigs() {
$config = ConnectionManager::enumConnectionObjects();
+ $this->skipIf($this->db instanceof Sqlite, 'This test is not compatible with Sqlite.');
$this->skipIf(
!isset($config['test']) || !isset($config['test2']),
'Primary and secondary test databases not configured, skipping cross-database join tests.'
@@ -95,7 +96,6 @@ public function testModelDatasources() {
*/
public function testHabtmFind() {
$this->loadFixtures('Player', 'Guild', 'GuildsPlayer');
-
$Player = ClassRegistry::init('Player');
$players = $Player->find('all', array(
@@ -130,7 +130,6 @@ public function testHabtmFind() {
*/
public function testHabtmSave() {
$this->loadFixtures('Player', 'Guild', 'GuildsPlayer');
-
$Player = ClassRegistry::init('Player');
$players = $Player->find('count');
$this->assertEquals(4, $players);
View
15 lib/Cake/Test/Case/Model/ModelDeleteTest.php
@@ -316,7 +316,8 @@ public function testDeleteAll() {
$TestModel->recursive = -1;
$result = $TestModel->find('all', array(
- 'fields' => array('id', 'user_id', 'title', 'published')
+ 'fields' => array('id', 'user_id', 'title', 'published'),
+ 'order' => array('Article.id' => 'ASC')
));
$expected = array(
@@ -363,7 +364,8 @@ public function testDeleteAll() {
$TestModel->recursive = -1;
$result = $TestModel->find('all', array(
- 'fields' => array('id', 'user_id', 'title', 'published')
+ 'fields' => array('id', 'user_id', 'title', 'published'),
+ 'order' => array('Article.id' => 'ASC')
));
$expected = array(
array('Article' => array(
@@ -398,7 +400,8 @@ public function testDeleteAll() {
$TestModel->recursive = -1;
$result = $TestModel->find('all', array(
- 'fields' => array('id', 'user_id', 'title', 'published')
+ 'fields' => array('id', 'user_id', 'title', 'published'),
+ 'order' => array('Article.id' => 'ASC')
));
$expected = array(
array('Article' => array(
@@ -559,7 +562,7 @@ public function testDeleteDependent() {
'ArticlesTag', 'Comment', 'User', 'Attachment'
);
$Bidding = new Bidding();
- $result = $Bidding->find('all');
+ $result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC')));
$expected = array(
array(
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
@@ -581,7 +584,7 @@ public function testDeleteDependent() {
$this->assertEquals($expected, $result);
$Bidding->delete(4, true);
- $result = $Bidding->find('all');
+ $result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC')));
$expected = array(
array(
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
@@ -599,7 +602,7 @@ public function testDeleteDependent() {
$this->assertEquals($expected, $result);
$Bidding->delete(2, true);
- $result = $Bidding->find('all');
+ $result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC')));
$expected = array(
array(
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
View
3  lib/Cake/Test/Case/Model/ModelIntegrationTest.php
@@ -717,6 +717,7 @@ public function testHABTMKeepExisting() {
*/
public function testHABTMKeepExistingWithThreeDbs() {
$config = ConnectionManager::enumConnectionObjects();
+ $this->skipIf($this->db instanceof Sqlite, 'This test is not compatible with Sqlite.');
$this->skipIf(
!isset($config['test']) || !isset($config['test2']) || !isset($config['test_database_three']),
'Primary, secondary, and tertiary test databases not configured, skipping test. To run this test define $test, $test2, and $test_database_three in your database configuration.'
@@ -835,7 +836,7 @@ public static function timeProvider() {
array('hour' => '', 'min' => '', 'sec' => ''),
''
),
- // set and empty merdian
+ // set and empty merdian
array(
array('hour' => '1', 'min' => '00', 'meridian' => ''),
''
View
20 lib/Cake/Test/Case/Model/ModelWriteTest.php
@@ -1006,7 +1006,10 @@ public function testSaveWithSet() {
$this->assertEquals($expected, $result);
$TestModel->recursive = -1;
- $result = $TestModel->find('all', array('fields' => array('id', 'title')));
+ $result = $TestModel->find('all', array(
+ 'fields' => array('id', 'title'),
+ 'order' => array('Article.id' => 'ASC')
+ ));
$expected = array(
array('Article' => array('id' => 1, 'title' => 'First Article')),
array('Article' => array('id' => 2, 'title' => 'Second Article')),
@@ -3075,7 +3078,8 @@ public function testSaveAllDeepAssociated() {
'First new comment',
'Second new comment'
);
- $this->assertEquals($expected, Set::extract($result['Comment'], '{n}.comment'));
+ $result = Set::extract(Set::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
+ $this->assertEquals($expected, $result);
$result = $TestModel->Comment->User->field('id', array('user' => 'newuser', 'password' => 'newuserpass'));
$this->assertEquals(5, $result);
@@ -3097,7 +3101,8 @@ public function testSaveAllDeepAssociated() {
'Third new comment',
'Fourth new comment'
);
- $this->assertEquals($expected, Set::extract($result['Comment'], '{n}.comment'));
+ $result = Set::extract(Set::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
+ $this->assertEquals($expected, $result);
$result = $TestModel->Comment->Attachment->field('id', array('attachment' => 'deepsaved'));
$this->assertEquals(2, $result);
@@ -3848,7 +3853,8 @@ public function testSaveAllHasMany() {
'First new comment',
'Second new comment'
);
- $this->assertEquals(Set::extract($result['Comment'], '{n}.comment'), $expected);
+ $result = Set::extract(Set::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
+ $this->assertEquals($expected, $result);
$result = $TestModel->saveAll(
array(
@@ -3871,7 +3877,8 @@ public function testSaveAllHasMany() {
'Second new comment',
'Third new comment'
);
- $this->assertEquals(Set::extract($result['Comment'], '{n}.comment'), $expected);
+ $result = Set::extract(Set::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
+ $this->assertEquals($expected, $result);
$TestModel->beforeSaveReturn = false;
$result = $TestModel->saveAll(
@@ -3895,7 +3902,8 @@ public function testSaveAllHasMany() {
'Second new comment',
'Third new comment'
);
- $this->assertEquals(Set::extract($result['Comment'], '{n}.comment'), $expected);
+ $result = Set::extract(Set::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment');
+ $this->assertEquals($expected, $result);
}
/**
View
2  lib/Cake/Test/Case/Network/Email/DebugTransportTest.php
@@ -50,7 +50,7 @@ public function testSend() {
$email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>');
$email->subject('Testing Message');
$date = date(DATE_RFC2822);
- $email->setHeaders(array('X-Mailer' => $email::EMAIL_CLIENT, 'Date' => $date));
+ $email->setHeaders(array('X-Mailer' => DebugCakeEmail::EMAIL_CLIENT, 'Date' => $date));
$email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '')));
$headers = "From: CakePHP Test <noreply@cakephp.org>\r\n";
View
2  lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php
@@ -221,7 +221,7 @@ public function testSendData() {
$email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>');
$email->subject('Testing SMTP');
$date = date(DATE_RFC2822);
- $email->setHeaders(array('X-Mailer' => $email::EMAIL_CLIENT, 'Date' => $date));
+ $email->setHeaders(array('X-Mailer' => SmtpCakeEmail::EMAIL_CLIENT, 'Date' => $date));
$email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '')));
$data = "From: CakePHP Test <noreply@cakephp.org>\r\n";
Please sign in to comment.
Something went wrong with that request. Please try again.