Exemplo n.º 1
0
 /**
  * @param $propertyValue
  * @param $expected
  *
  * @dataProvider dataProvider
  */
 public function testErrors($propertyValue, $expected)
 {
     $validator = new DateTime();
     $validator->setInput($propertyValue);
     $this->assertEquals($expected, $validator->errors());
 }
Exemplo n.º 2
0
 public function dataProvider($name)
 {
     if ($name == 'testIsValid') {
         return array(array('JohnDoe', true), array('Baby', false), array('TextDate', false));
     }
     if ($name == 'testGetErrorsCount') {
         return array(array('JohnDoe', 0), array('Baby', 1), array('TextDate', 1));
     }
     if ($name == 'testGetErrors') {
         $twoWeek = new \DateTime('-2 weeks');
         return array(array('JohnDoe', array('firstName' => array(), 'lastName' => array(), 'email' => array(), 'dob' => array())), array('Baby', array('firstName' => array(), 'lastName' => array(), 'email' => array(), 'dob' => array('"' . $twoWeek->format('c') . '" is not lower than "-18 years"'))), array('TextDate', array('firstName' => array(), 'lastName' => array(), 'email' => array(), 'dob' => array('"-17 years" is not lower than "-18 years"'))));
     }
     if ($name == 'testGetSanitizedObject') {
         return array(array('JohnDoe', 'same'), array('Baby', 'same'), array('TextDate', ObjectValidatorTestMockClass::sanitizeTextDate()));
     }
 }