Skip to content

Commit

Permalink
Merge branch 'ZF-10690' of https://github.com/thomasweidner/zf2 into …
Browse files Browse the repository at this point in the history
…hotfix/zf-10690
  • Loading branch information
weierophinney committed Dec 17, 2010
2 parents 35795b9 + 0bd34c6 commit 104bfce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
10 changes: 5 additions & 5 deletions library/Zend/Validator/EmailAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,17 @@ public function setOptions(array $options = array())
*/
public function setMessage($messageString, $messageKey = null)
{
$messageKeys = $messageKey;
if ($messageKey === null) {
$keys = array_keys($this->_messageTemplates);
$messageKeys = current($keys);
$this->_options['hostname']->setMessage($messageString);
parent::setMessage($messageString);
return $this;
}

if (!isset($this->_messageTemplates[$messageKeys])) {
if (!isset($this->_messageTemplates[$messageKey])) {
$this->_options['hostname']->setMessage($messageString, $messageKey);
}

$this->_messageTemplates[$messageKeys] = $messageString;
$this->_messageTemplates[$messageKey] = $messageString;
return $this;
}

Expand Down
16 changes: 15 additions & 1 deletion tests/Zend/Validator/EmailAddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public function testSetSingleMessage()
{
$messages = $this->_validator->getMessageTemplates();
$this->assertNotEquals('TestMessage', $messages[Validator\EmailAddress::INVALID]);
$this->_validator->setMessage('TestMessage');
$this->_validator->setMessage('TestMessage', Validator\EmailAddress::INVALID);
$messages = $this->_validator->getMessageTemplates();
$this->assertEquals('TestMessage', $messages[Validator\EmailAddress::INVALID]);
}
Expand Down Expand Up @@ -531,6 +531,20 @@ public function testGetDeepMxCheck()
$this->assertFalse($this->_validator->getDeepMxCheck());
}

/**
* Testing setMessage for all messages
*
* @group ZF-10690
*/
public function testSetMultipleMessages()
{
$messages = $this->_validator->getMessageTemplates();
$this->assertNotEquals('TestMessage', $messages[Validator\EmailAddress::INVALID]);
$this->_validator->setMessage('TestMessage');
$messages = $this->_validator->getMessageTemplates();
$this->assertEquals('TestMessage', $messages[Validator\EmailAddress::INVALID]);
}

/**
* Testing getDomainCheck
*/
Expand Down

0 comments on commit 104bfce

Please sign in to comment.