Skip to content

Commit

Permalink
Merge branch 'hotfix/5808'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Mar 4, 2014
2 parents 21a17e5 + e2d15cf commit 8a9f4bc
Show file tree
Hide file tree
Showing 2 changed files with 26 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
25 changes: 25 additions & 0 deletions tests/ZendTest/Validator/ExplodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
namespace ZendTest\Validator;

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

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

/**
* @group ZF2-5796
*/
public function testGetMessagesMultipleInvalid()
{
$validator = new Explode(array(
'validator' => new Regex(
'/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/'
),
'valueDelimiter' => ',',
'breakOnFirstFailure' => false,
));

$messages = array(
0 => array(
'regexNotMatch' => "The input does not match against pattern '/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/'",
),
);

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

0 comments on commit 8a9f4bc

Please sign in to comment.