You are here

class IsNullValidatorTest in Plug 7

Hierarchy

Expanded class hierarchy of IsNullValidatorTest

File

lib/Symfony/validator/Symfony/Component/Validator/Tests/Constraints/IsNullValidatorTest.php, line 18

Namespace

Symfony\Component\Validator\Tests\Constraints
View source
class IsNullValidatorTest extends AbstractConstraintValidatorTest {
  protected function getApiVersion() {
    return Validation::API_VERSION_2_5;
  }
  protected function createValidator() {
    return new IsNullValidator();
  }
  public function testNullIsValid() {
    $this->validator
      ->validate(null, new IsNull());
    $this
      ->assertNoViolation();
  }

  /**
   * @dataProvider getInvalidValues
   */
  public function testInvalidValues($value, $valueAsString) {
    $constraint = new IsNull(array(
      'message' => 'myMessage',
    ));
    $this->validator
      ->validate($value, $constraint);
    $this
      ->buildViolation('myMessage')
      ->setParameter('{{ value }}', $valueAsString)
      ->assertRaised();
  }
  public function getInvalidValues() {
    return array(
      array(
        0,
        '0',
      ),
      array(
        false,
        'false',
      ),
      array(
        true,
        'true',
      ),
      array(
        '',
        '""',
      ),
      array(
        'foo bar',
        '"foo bar"',
      ),
      array(
        new \DateTime(),
        'object',
      ),
      array(
        new \stdClass(),
        'object',
      ),
      array(
        array(),
        'array',
      ),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractConstraintValidatorTest::$constraint protected property
AbstractConstraintValidatorTest::$context protected property 1
AbstractConstraintValidatorTest::$defaultTimezone protected property
AbstractConstraintValidatorTest::$group protected property
AbstractConstraintValidatorTest::$metadata protected property
AbstractConstraintValidatorTest::$object protected property
AbstractConstraintValidatorTest::$propertyPath protected property
AbstractConstraintValidatorTest::$root protected property
AbstractConstraintValidatorTest::$validator protected property 1
AbstractConstraintValidatorTest::$value protected property
AbstractConstraintValidatorTest::assertNoViolation protected function
AbstractConstraintValidatorTest::assertViolation Deprecated protected function
AbstractConstraintValidatorTest::assertViolations Deprecated protected function
AbstractConstraintValidatorTest::buildViolation protected function
AbstractConstraintValidatorTest::createContext protected function
AbstractConstraintValidatorTest::createViolation Deprecated protected function
AbstractConstraintValidatorTest::expectNoValidate protected function
AbstractConstraintValidatorTest::expectValidateAt protected function
AbstractConstraintValidatorTest::expectValidateValueAt protected function
AbstractConstraintValidatorTest::restoreDefaultTimezone protected function
AbstractConstraintValidatorTest::setDefaultTimezone protected function
AbstractConstraintValidatorTest::setGroup protected function
AbstractConstraintValidatorTest::setObject protected function
AbstractConstraintValidatorTest::setProperty protected function
AbstractConstraintValidatorTest::setPropertyPath protected function
AbstractConstraintValidatorTest::setRoot protected function
AbstractConstraintValidatorTest::setUp protected function 6
AbstractConstraintValidatorTest::setValue protected function
AbstractConstraintValidatorTest::tearDown protected function 1
IsNullValidatorTest::createValidator protected function Overrides AbstractConstraintValidatorTest::createValidator
IsNullValidatorTest::getApiVersion protected function Overrides AbstractConstraintValidatorTest::getApiVersion 2
IsNullValidatorTest::getInvalidValues public function
IsNullValidatorTest::testInvalidValues public function @dataProvider getInvalidValues
IsNullValidatorTest::testNullIsValid public function