From f6a011215c2d6f51da1b75d886001ffccbbdff33 Mon Sep 17 00:00:00 2001 From: nojimage Date: Mon, 1 Jul 2013 00:03:18 +0900 Subject: [PATCH] change emailRegex to emailPattern --- lib/Cake/Network/Email/CakeEmail.php | 24 +++++++++---------- .../Test/Case/Network/Email/CakeEmailTest.php | 22 ++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 477dbf3f7..09db74a68 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -324,7 +324,7 @@ class CakeEmail { * * @var string */ - protected $_emailRegex = null; + protected $_emailPattern = null; /** * Constructor @@ -530,16 +530,16 @@ class CakeEmail { } /** - * EmailRegex setter/getter + * EmailPattern setter/getter * - * @param string $regexp + * @param string $regex for email address validation * @return string|CakeEmail */ - public function emailRegex($regex = null) { + public function emailPattern($regex = null) { if ($regex === null) { - return $this->_emailRegex; + return $this->_emailPattern; } - $this->_emailRegex = $regex; + $this->_emailPattern = $regex; return $this; } @@ -554,7 +554,7 @@ class CakeEmail { */ protected function _setEmail($varName, $email, $name) { if (!is_array($email)) { - if (!Validation::email($email, false, $this->_emailRegex)) { + if (!Validation::email($email, false, $this->_emailPattern)) { throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $email)); } if ($name === null) { @@ -568,7 +568,7 @@ class CakeEmail { if (is_int($key)) { $key = $value; } - if (!Validation::email($key, false, $this->_emailRegex)) { + if (!Validation::email($key, false, $this->_emailPattern)) { throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $key)); } $list[$key] = $value; @@ -608,7 +608,7 @@ class CakeEmail { */ protected function _addEmail($varName, $email, $name) { if (!is_array($email)) { - if (!Validation::email($email, false, $this->_emailRegex)) { + if (!Validation::email($email, false, $this->_emailPattern)) { throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $email)); } if ($name === null) { @@ -622,7 +622,7 @@ class CakeEmail { if (is_int($key)) { $key = $value; } - if (!Validation::email($key, false, $this->_emailRegex)) { + if (!Validation::email($key, false, $this->_emailPattern)) { throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $key)); } $list[$key] = $value; @@ -1183,7 +1183,7 @@ class CakeEmail { $simpleMethods = array( 'from', 'sender', 'to', 'replyTo', 'readReceipt', 'returnPath', 'cc', 'bcc', 'messageId', 'domain', 'subject', 'viewRender', 'viewVars', 'attachments', - 'transport', 'emailFormat', 'theme', 'helpers', 'emailRegex' + 'transport', 'emailFormat', 'theme', 'helpers', 'emailPattern' ); foreach ($simpleMethods as $method) { if (isset($config[$method])) { @@ -1240,7 +1240,7 @@ class CakeEmail { $this->headerCharset = null; $this->_attachments = array(); $this->_config = array(); - $this->_emailRegex = null; + $this->_emailPattern = null; return $this; } diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index ad9634725..750e6b1d2 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -265,14 +265,14 @@ class CakeEmailTest extends CakeTestCase { } /** - * test emailRegex method + * test emailPattern method * * @return void */ - public function testEmailRegex() { + public function testEmailPattern() { $regex = '/.+@.+\..+/i'; - $this->assertNull($this->CakeEmail->emailRegex()); - $this->assertSame($regex, $this->CakeEmail->emailRegex($regex)->emailRegex()); + $this->assertNull($this->CakeEmail->emailPattern()); + $this->assertSame($regex, $this->CakeEmail->emailPattern($regex)->emailPattern()); } /** @@ -280,10 +280,10 @@ class CakeEmailTest extends CakeTestCase { * * @return void */ - public function testConfigEmailRegex() { + public function testConfigEmailPattern() { $regex = '/.+@.+\..+/i'; - $email = new CakeEmail(array('emailRegex' => $regex)); - $this->assertSame($regex, $email->emailRegex()); + $email = new CakeEmail(array('emailPattern' => $regex)); + $this->assertSame($regex, $email->emailPattern()); } /** @@ -292,7 +292,7 @@ class CakeEmailTest extends CakeTestCase { public function testCustomEmailValidation() { $regex = '/^[\.a-z0-9!#$%&\'*+\/=?^_`{|}~-]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]{2,6}$/i'; - $this->CakeEmail->emailRegex($regex)->to('pass.@example.com'); + $this->CakeEmail->emailPattern($regex)->to('pass.@example.com'); $this->assertSame(array( 'pass.@example.com' => 'pass.@example.com', ), $this->CakeEmail->to()); @@ -312,7 +312,7 @@ class CakeEmailTest extends CakeTestCase { '.extend.@example.com', '.docomo@example.com' ); - $this->CakeEmail->emailRegex($regex)->to($emails); + $this->CakeEmail->emailPattern($regex)->to($emails); $this->assertSame(array( 'pass.@example.com' => 'pass.@example.com', 'pass..old.docomo@example.com' => 'pass..old.docomo@example.com', @@ -1490,13 +1490,13 @@ class CakeEmailTest extends CakeTestCase { public function testReset() { $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->theme('TestTheme'); - $this->CakeEmail->emailRegex('/.+@.+\..+/i'); + $this->CakeEmail->emailPattern('/.+@.+\..+/i'); $this->assertSame($this->CakeEmail->to(), array('cake@cakephp.org' => 'cake@cakephp.org')); $this->CakeEmail->reset(); $this->assertSame($this->CakeEmail->to(), array()); $this->assertSame(null, $this->CakeEmail->theme()); - $this->assertSame(null, $this->CakeEmail->emailRegex()); + $this->assertSame(null, $this->CakeEmail->emailPattern()); } /**