mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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
This commit is contained in:
parent
b871095125
commit
40f4f54b34
6 changed files with 28 additions and 17 deletions
|
@ -63,6 +63,7 @@ class ModelCrossSchemaHabtmTest extends BaseModelTest {
|
||||||
*/
|
*/
|
||||||
protected function _checkConfigs() {
|
protected function _checkConfigs() {
|
||||||
$config = ConnectionManager::enumConnectionObjects();
|
$config = ConnectionManager::enumConnectionObjects();
|
||||||
|
$this->skipIf($this->db instanceof Sqlite, 'This test is not compatible with Sqlite.');
|
||||||
$this->skipIf(
|
$this->skipIf(
|
||||||
!isset($config['test']) || !isset($config['test2']),
|
!isset($config['test']) || !isset($config['test2']),
|
||||||
'Primary and secondary test databases not configured, skipping cross-database join tests.'
|
'Primary and secondary test databases not configured, skipping cross-database join tests.'
|
||||||
|
@ -95,7 +96,6 @@ class ModelCrossSchemaHabtmTest extends BaseModelTest {
|
||||||
*/
|
*/
|
||||||
public function testHabtmFind() {
|
public function testHabtmFind() {
|
||||||
$this->loadFixtures('Player', 'Guild', 'GuildsPlayer');
|
$this->loadFixtures('Player', 'Guild', 'GuildsPlayer');
|
||||||
|
|
||||||
$Player = ClassRegistry::init('Player');
|
$Player = ClassRegistry::init('Player');
|
||||||
|
|
||||||
$players = $Player->find('all', array(
|
$players = $Player->find('all', array(
|
||||||
|
@ -130,7 +130,6 @@ class ModelCrossSchemaHabtmTest extends BaseModelTest {
|
||||||
*/
|
*/
|
||||||
public function testHabtmSave() {
|
public function testHabtmSave() {
|
||||||
$this->loadFixtures('Player', 'Guild', 'GuildsPlayer');
|
$this->loadFixtures('Player', 'Guild', 'GuildsPlayer');
|
||||||
|
|
||||||
$Player = ClassRegistry::init('Player');
|
$Player = ClassRegistry::init('Player');
|
||||||
$players = $Player->find('count');
|
$players = $Player->find('count');
|
||||||
$this->assertEquals(4, $players);
|
$this->assertEquals(4, $players);
|
||||||
|
|
|
@ -316,7 +316,8 @@ class ModelDeleteTest extends BaseModelTest {
|
||||||
|
|
||||||
$TestModel->recursive = -1;
|
$TestModel->recursive = -1;
|
||||||
$result = $TestModel->find('all', array(
|
$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(
|
$expected = array(
|
||||||
|
@ -363,7 +364,8 @@ class ModelDeleteTest extends BaseModelTest {
|
||||||
|
|
||||||
$TestModel->recursive = -1;
|
$TestModel->recursive = -1;
|
||||||
$result = $TestModel->find('all', array(
|
$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(
|
$expected = array(
|
||||||
array('Article' => array(
|
array('Article' => array(
|
||||||
|
@ -398,7 +400,8 @@ class ModelDeleteTest extends BaseModelTest {
|
||||||
|
|
||||||
$TestModel->recursive = -1;
|
$TestModel->recursive = -1;
|
||||||
$result = $TestModel->find('all', array(
|
$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(
|
$expected = array(
|
||||||
array('Article' => array(
|
array('Article' => array(
|
||||||
|
@ -559,7 +562,7 @@ class ModelDeleteTest extends BaseModelTest {
|
||||||
'ArticlesTag', 'Comment', 'User', 'Attachment'
|
'ArticlesTag', 'Comment', 'User', 'Attachment'
|
||||||
);
|
);
|
||||||
$Bidding = new Bidding();
|
$Bidding = new Bidding();
|
||||||
$result = $Bidding->find('all');
|
$result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC')));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
array(
|
array(
|
||||||
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
|
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
|
||||||
|
@ -581,7 +584,7 @@ class ModelDeleteTest extends BaseModelTest {
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$Bidding->delete(4, true);
|
$Bidding->delete(4, true);
|
||||||
$result = $Bidding->find('all');
|
$result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC')));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
array(
|
array(
|
||||||
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
|
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
|
||||||
|
@ -599,7 +602,7 @@ class ModelDeleteTest extends BaseModelTest {
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$Bidding->delete(2, true);
|
$Bidding->delete(2, true);
|
||||||
$result = $Bidding->find('all');
|
$result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC')));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
array(
|
array(
|
||||||
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
|
'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'),
|
||||||
|
|
|
@ -717,6 +717,7 @@ class ModelIntegrationTest extends BaseModelTest {
|
||||||
*/
|
*/
|
||||||
public function testHABTMKeepExistingWithThreeDbs() {
|
public function testHABTMKeepExistingWithThreeDbs() {
|
||||||
$config = ConnectionManager::enumConnectionObjects();
|
$config = ConnectionManager::enumConnectionObjects();
|
||||||
|
$this->skipIf($this->db instanceof Sqlite, 'This test is not compatible with Sqlite.');
|
||||||
$this->skipIf(
|
$this->skipIf(
|
||||||
!isset($config['test']) || !isset($config['test2']) || !isset($config['test_database_three']),
|
!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.'
|
'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.'
|
||||||
|
|
|
@ -1006,7 +1006,10 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$TestModel->recursive = -1;
|
$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(
|
$expected = array(
|
||||||
array('Article' => array('id' => 1, 'title' => 'First Article')),
|
array('Article' => array('id' => 1, 'title' => 'First Article')),
|
||||||
array('Article' => array('id' => 2, 'title' => 'Second Article')),
|
array('Article' => array('id' => 2, 'title' => 'Second Article')),
|
||||||
|
@ -3075,7 +3078,8 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'First new comment',
|
'First new comment',
|
||||||
'Second 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'));
|
$result = $TestModel->Comment->User->field('id', array('user' => 'newuser', 'password' => 'newuserpass'));
|
||||||
$this->assertEquals(5, $result);
|
$this->assertEquals(5, $result);
|
||||||
|
@ -3097,7 +3101,8 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'Third new comment',
|
'Third new comment',
|
||||||
'Fourth 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'));
|
$result = $TestModel->Comment->Attachment->field('id', array('attachment' => 'deepsaved'));
|
||||||
$this->assertEquals(2, $result);
|
$this->assertEquals(2, $result);
|
||||||
|
@ -3848,7 +3853,8 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'First new comment',
|
'First new comment',
|
||||||
'Second 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(
|
$result = $TestModel->saveAll(
|
||||||
array(
|
array(
|
||||||
|
@ -3871,7 +3877,8 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'Second new comment',
|
'Second new comment',
|
||||||
'Third 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;
|
$TestModel->beforeSaveReturn = false;
|
||||||
$result = $TestModel->saveAll(
|
$result = $TestModel->saveAll(
|
||||||
|
@ -3895,7 +3902,8 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
'Second new comment',
|
'Second new comment',
|
||||||
'Third 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,7 +50,7 @@ class DebugTransportTest extends CakeTestCase {
|
||||||
$email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>');
|
$email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>');
|
||||||
$email->subject('Testing Message');
|
$email->subject('Testing Message');
|
||||||
$date = date(DATE_RFC2822);
|
$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', '')));
|
$email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '')));
|
||||||
|
|
||||||
$headers = "From: CakePHP Test <noreply@cakephp.org>\r\n";
|
$headers = "From: CakePHP Test <noreply@cakephp.org>\r\n";
|
||||||
|
|
|
@ -221,7 +221,7 @@ class SmtpTransportTest extends CakeTestCase {
|
||||||
$email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>');
|
$email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>');
|
||||||
$email->subject('Testing SMTP');
|
$email->subject('Testing SMTP');
|
||||||
$date = date(DATE_RFC2822);
|
$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', '')));
|
$email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '')));
|
||||||
|
|
||||||
$data = "From: CakePHP Test <noreply@cakephp.org>\r\n";
|
$data = "From: CakePHP Test <noreply@cakephp.org>\r\n";
|
||||||
|
|
Loading…
Reference in a new issue