Skip to content

Commit

Permalink
Merge pull request zendframework#5808 from samsonasik/fix/multiple-in…
Browse files Browse the repository at this point in the history
…valid-explodevalidator

Fixes zendframework#5796
  • Loading branch information
weierophinney committed Mar 4, 2014
2 parents ce426d0 + fbe99f0 commit 6fbe01b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Validator/AbstractValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function setOptions($options = array())
*/
public function getMessages()
{
return array_unique($this->abstractOptions['messages']);
return array_unique($this->abstractOptions['messages'], SORT_REGULAR);
}

/**
Expand Down
22 changes: 22 additions & 0 deletions tests/ZendTest/Validator/ExplodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace ZendTest\Validator;

use Zend\Validator\Explode;
use Zend\Validator\EmailAddress;

/**
* @group Zend_Validator
Expand Down Expand Up @@ -129,4 +130,25 @@ public function testSetValidatorInvalidParam()
$validator = new Explode();
$validator->setValidator('inarray');
}

/**
* @group ZF2-5796
*/
public function testGetMessagesMultipleInvalid()
{
$validator = new Explode(array(
'validator' => new EmailAddress,
'valueDelimiter' => ',',
'breakOnFirstFailure' => true,
));

$messages = array(
0 => array(
'emailAddressInvalidFormat' => 'The input is not a valid email address. Use the basic format local-part@hostname',
),
);

$this->assertFalse($validator->isValid('[email protected],abc,defghij'));
$this->assertEquals($messages, $validator->getMessages());
}
}

0 comments on commit 6fbe01b

Please sign in to comment.