addValidatorPrefix() public static method

The backslash at the end is required; e.g. for class "\Api\IsInt" the prefix would be "\Api\" and validator name "IsInt".
public static addValidatorPrefix ( string $prefix )
$prefix string Validator class prefix
Beispiel #1
0
 /**
  * Tests creating a validator instance with a custom prefix.
  */
 public function testCustomValidatorPrefix()
 {
     $validatorName = 'Validator';
     $validatorPrefix = '\\SomeOtherPrefix\\Some\\';
     // Ensure that there is no such class loaded
     if (class_exists($validatorName, false)) {
         $this->markTestSkipped(sprintf('Class %s exists', $validatorName));
     }
     try {
         $this->factory->getValidatorByName($validatorName);
         $this->fail(sprintf('Expected exception %s.', \Jyxo\Input\Exception::class));
     } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
         throw $e;
     } catch (\Exception $e) {
         $this->assertInstanceOf(\Jyxo\Input\Exception::class, $e);
     }
     $this->factory->addValidatorPrefix($validatorPrefix);
     $validator = $this->factory->getValidatorByName($validatorName);
 }