Skip to content

Commit

Permalink
Rename mail to action + missing docblock
Browse files Browse the repository at this point in the history
  • Loading branch information
jadb committed Apr 15, 2015
1 parent 8831c5d commit 61c6f81
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
Expand Up @@ -15,10 +15,9 @@
use Cake\Core\Exception\Exception;

/**
* Missing Action exception - used when a controller action
* cannot be found, or when the controller's isAction() method returns false.
* Missing Action exception - used when a mailer action cannot be found.
*/
class MissingMailException extends Exception
class MissingActionException extends Exception
{

/**
Expand Down
18 changes: 9 additions & 9 deletions src/Mailer/Mailer.php
Expand Up @@ -15,7 +15,7 @@
use ArrayAccess;
use Cake\Datasource\ModelAwareTrait;
use Cake\Event\EventListenerInterface;
use Cake\Mailer\Exception\MissingMailException;
use Cake\Mailer\Exception\MissingActionException;
use Cake\Utility\Inflector;

abstract class Mailer implements ArrayAccess, EventListenerInterface
Expand Down Expand Up @@ -130,25 +130,25 @@ public function set($key, $value = null)
/**
* Sends email.
*
* @param string $mail The name of the mail action to trigger.
* @param array $args Arguments to pass to the triggered mail action.
* @param string $action The name of the mailer action to trigger.
* @param array $args Arguments to pass to the triggered mailer action.
* @param array $headers Headers to set.
* @return array
* @throws \Cake\Mailer\Exception\MissingMailException
* @throws \Cake\Mailer\Exception\MissingActionException
* @throws \BadMethodCallException
*/
public function send($mail, $args = [], $headers = [])
public function send($action, $args = [], $headers = [])
{
if (!method_exists($this, $mail)) {
throw new MissingMailException([
if (!method_exists($this, $action)) {
throw new MissingActionException([
'mailer' => $this->getName() . 'Mailer',
'mail' => $mail,
'action' => $action,
]);
}

$this->setHeaders($headers);

call_user_func_array([$this, $mail], $args);
call_user_func_array([$this, $action], $args);

$result = $this->_email
->profile((array)$this)
Expand Down
15 changes: 13 additions & 2 deletions tests/TestCase/Mailer/MailerTest.php
@@ -1,4 +1,15 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @since 3.1.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Test\TestCase\Mailer;

use Cake\Mailer\Email;
Expand Down Expand Up @@ -108,10 +119,10 @@ public function testSend()
}

/**
* @expectedException Cake\Mailer\Exception\MissingMailException
* @expectedException Cake\Mailer\Exception\MissingActionException
* @expectedExceptionMessage Mail TestMailer::test() could not be found, or is not accessible.
*/
public function testMissingMailThrowsException()
public function testMissingActionThrowsException()
{
(new TestMailer())->send('test');
}
Expand Down

0 comments on commit 61c6f81

Please sign in to comment.