Skip to content

Commit

Permalink
add test to not found email transport class error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Graziel committed May 20, 2016
1 parent 24d4a1d commit 2f67740
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Mailer/Email.php
Expand Up @@ -1003,10 +1003,12 @@ protected function _constructTransport($name)
$className = App::className($config['className'], 'Mailer/Transport', 'Transport');
if (!$className) {
$className = App::className($config['className'], 'Network/Email', 'Transport');
trigger_error(
'Transports in "Network/Email" are deprecated, use "Mailer/Transport" instead.',
E_USER_DEPRECATED
);
if ($className) {
trigger_error(
'Transports in "Network/Email" are deprecated, use "Mailer/Transport" instead.',
E_USER_DEPRECATED
);
}
}

if (!$className) {
Expand Down
18 changes: 18 additions & 0 deletions tests/TestCase/Mailer/EmailTest.php
Expand Up @@ -103,6 +103,9 @@ public function setUp()
$this->transports = [
'debug' => [
'className' => 'Debug'
],
'badClassName' => [
'className' => 'TestFalse'
]
];
Email::configTransport($this->transports);
Expand All @@ -119,6 +122,7 @@ public function tearDown()
Log::drop('email');
Email::drop('test');
Email::dropTransport('debug');
Email::dropTransport('badClassName');
Email::dropTransport('test_smtp');
}

Expand Down Expand Up @@ -356,6 +360,20 @@ public function testCustomEmailValidation()
], $this->CakeEmail->to());
}

/**
* Tests not found transport class name exception
*
* @return void
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Transport class "TestFalse" not found.
*/
public function testClassNameException()
{
$email = new Email();
$email->transport('badClassName');
}

/**
* Tests that it is possible to unset the email pattern and make use of filter_var() instead.
*
Expand Down

0 comments on commit 2f67740

Please sign in to comment.