diff --git a/src/AbstractValidator.php b/src/AbstractValidator.php index 8fff81121..8ab827f69 100644 --- a/src/AbstractValidator.php +++ b/src/AbstractValidator.php @@ -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); } /** diff --git a/test/ExplodeTest.php b/test/ExplodeTest.php index 229eb6f07..f0df2ae22 100644 --- a/test/ExplodeTest.php +++ b/test/ExplodeTest.php @@ -10,6 +10,7 @@ namespace ZendTest\Validator; use Zend\Validator\Explode; +use Zend\Validator\EmailAddress; /** * @group Zend_Validator @@ -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('zf-devteam@zend.com,abc,defghij')); + $this->assertEquals($messages, $validator->getMessages()); + } }