Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixes #5796 #5808

Closed
wants to merge 3 commits into from

3 participants

@weierophinney weierophinney added this to the 2.2.6 milestone
@Ocramius Ocramius self-assigned this
@Ocramius Ocramius commented on the diff
tests/ZendTest/Validator/ExplodeTest.php
@@ -129,4 +130,25 @@ public function testSetValidatorInvalidParam()
$validator = new Explode();
$validator->setValidator('inarray');
}
+
+ /**
+ * @group ZF2-5796
+ */
+ public function testGetMessagesMultipleInvalid()
@Ocramius Collaborator
Ocramius added a note

@samsonasik the provided test doesn't seem to fail on my machine (excluding the fix).
What are the requirements for it to fail?

when it called via browser, without the SORT_REGULAR option, it will cause error like described at #5796

@Ocramius Collaborator
Ocramius added a note

Yeah, but the test doesn't seem to raise this problem, @samsonasik.

@Ocramius Collaborator
Ocramius added a note

@Satsume can you compare the validator and the values in the test with the ones you got in your form in #5796?

@weierophinney Owner

I think a valid test case will use the regex validator as done in Zend\Form\Element\Email::getEmailValidator(). Going to try that now and see if I see a failure with that.

@weierophinney Owner

Okay, the trick to getting a test that failed was as follows:

  • Use the same validator as Zend\Form\Element\Email uses.
  • Ensure the breakOnFirstFailure flag is set to false, which is the default value, and which is used in the above element.

Once I did that, I had a failing test case; the suggested fix in this PR makes the test pass. Will merge shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#5808] Fixed test case
to test the specific behavior as reported in #5796. Test now fails before the
patch, passes afterwards.
e2d15cf
@weierophinney weierophinney closed this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/5808'
Close #5808
Fixes #5796
8a9f4bc
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/5808' into develop
Forward port #5808
b2ab4b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 10, 2014
  1. @samsonasik

    Fixes #5796

    samsonasik authored
  2. @samsonasik

    added unit test for #5796

    samsonasik authored
Commits on Feb 11, 2014
  1. @samsonasik

    change test method name

    samsonasik authored
This page is out of date. Refresh to see the latest.
View
2  library/Zend/Validator/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);
}
/**
View
22 tests/ZendTest/Validator/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()
@Ocramius Collaborator
Ocramius added a note

@samsonasik the provided test doesn't seem to fail on my machine (excluding the fix).
What are the requirements for it to fail?

when it called via browser, without the SORT_REGULAR option, it will cause error like described at #5796

@Ocramius Collaborator
Ocramius added a note

Yeah, but the test doesn't seem to raise this problem, @samsonasik.

@Ocramius Collaborator
Ocramius added a note

@Satsume can you compare the validator and the values in the test with the ones you got in your form in #5796?

@weierophinney Owner

I think a valid test case will use the regex validator as done in Zend\Form\Element\Email::getEmailValidator(). Going to try that now and see if I see a failure with that.

@weierophinney Owner

Okay, the trick to getting a test that failed was as follows:

  • Use the same validator as Zend\Form\Element\Email uses.
  • Ensure the breakOnFirstFailure flag is set to false, which is the default value, and which is used in the above element.

Once I did that, I had a failing test case; the suggested fix in this PR makes the test pass. Will merge shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ {
+ $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());
+ }
}
Something went wrong with that request. Please try again.