Ejemplo n.º 1
0
 /**
  * @dataProvider getExpectedData
  */
 public function testExpectedBehavior($value, $delimiter, $breakOnFirst, $numIsValidCalls, $isValidReturn, $messages, $expects)
 {
     $mockValidator = $this->getMock('Zend\\Validator\\ValidatorInterface');
     $mockValidator->expects($this->exactly($numIsValidCalls))->method('isValid')->will($this->returnValue($isValidReturn));
     $mockValidator->expects($this->any())->method('getMessages')->will($this->returnValue('X'));
     $validator = new Explode(array('validator' => $mockValidator, 'valueDelimiter' => $delimiter, 'breakOnFirstFailure' => $breakOnFirst));
     $this->assertEquals($expects, $validator->isValid($value));
     $this->assertEquals($messages, $validator->getMessages());
 }
Ejemplo n.º 2
0
 /**
  * @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('zf-devteam@zend.com,abc,defghij'));
     $this->assertEquals($messages, $validator->getMessages());
 }