Exemplo n.º 1
0
 /**
  * Test isValid method
  *
  * @dataProvider isValidDataProvider
  *
  * @param mixed $value
  * @param bool $expectedResult
  * @param array $expectedMessages
  */
 public function testIsValid($value, $expectedResult, $expectedMessages = array())
 {
     $this->_validatorMock->expects($this->once())->method('isValid')->with($value)->will($this->returnValue($expectedResult));
     if ($expectedResult) {
         $this->_validatorMock->expects($this->never())->method('getMessages');
     } else {
         $this->_validatorMock->expects($this->once())->method('getMessages')->will($this->returnValue($expectedMessages));
     }
     $this->assertEquals($expectedResult, $this->_constraint->isValid($value));
     $this->assertEquals($expectedMessages, $this->_constraint->getMessages());
 }
 private function stubGetMessages($messages)
 {
     $this->validatorStub->expects($this->any())->method('getMessages')->willReturn($messages);
 }