mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Rename config class used in test cases.
Having a separate classname for testing allows the testsuite to not provide a classname that the application would. This allows composer to generate the correct classmap when CakePHP is installed with composer. Fixes #4112
This commit is contained in:
parent
cd9b325bef
commit
e96fe515a1
2 changed files with 22 additions and 6 deletions
|
@ -325,6 +325,13 @@ class CakeEmail {
|
|||
*/
|
||||
protected $_emailPattern = null;
|
||||
|
||||
/**
|
||||
* The classname used for email configuration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_configClass = 'EmailConfig';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -1179,10 +1186,10 @@ class CakeEmail {
|
|||
*/
|
||||
protected function _applyConfig($config) {
|
||||
if (is_string($config)) {
|
||||
if (!class_exists('EmailConfig') && !config('email')) {
|
||||
if (!class_exists($this->_configClass) && !config('email')) {
|
||||
throw new ConfigureException(__d('cake_dev', '%s not found.', APP . 'Config' . DS . 'email.php'));
|
||||
}
|
||||
$configs = new EmailConfig();
|
||||
$configs = new $this->_configClass();
|
||||
if (!isset($configs->{$config})) {
|
||||
throw new ConfigureException(__d('cake_dev', 'Unknown email configuration "%s".', $config));
|
||||
}
|
||||
|
|
|
@ -26,6 +26,15 @@ App::uses('CakeEmail', 'Network/Email');
|
|||
*/
|
||||
class TestCakeEmail extends CakeEmail {
|
||||
|
||||
/**
|
||||
* Config classname.
|
||||
*
|
||||
* Use a the testing config class in this file.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_configClass = 'TestEmailConfig';
|
||||
|
||||
/**
|
||||
* Config
|
||||
*
|
||||
|
@ -79,7 +88,7 @@ class TestCakeEmail extends CakeEmail {
|
|||
* EmailConfig class
|
||||
*
|
||||
*/
|
||||
class EmailConfig {
|
||||
class TestEmailConfig {
|
||||
|
||||
/**
|
||||
* test config
|
||||
|
@ -841,7 +850,7 @@ class CakeEmailTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testConfigString() {
|
||||
$configs = new EmailConfig();
|
||||
$configs = new TestEmailConfig();
|
||||
$this->CakeEmail->config('test');
|
||||
|
||||
$result = $this->CakeEmail->to();
|
||||
|
@ -1767,8 +1776,8 @@ class CakeEmailTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testConstructWithConfigString() {
|
||||
$configs = new EmailConfig();
|
||||
$this->CakeEmail = new CakeEmail('test');
|
||||
$configs = new TestEmailConfig();
|
||||
$this->CakeEmail = new TestCakeEmail('test');
|
||||
|
||||
$result = $this->CakeEmail->to();
|
||||
$this->assertEquals($configs->test['to'], $result);
|
||||
|
|
Loading…
Reference in a new issue