/** * * @return IComplexTypeValidator */ function _ctValidator($pMessage = null) { return CopixValidatorFactory::createComplexType($pMessage); }
public function testCustom() { try { $validator = CopixValidatorFactory::create('copixtest|notexists'); $this->assertTrue(false); } catch (CopixException $e) { $this->assertTrue(true); } try { $validator = CopixValidatorFactory::create('copixtest|validatorNoInterface'); $this->assertTrue(false); } catch (CopixException $e) { $this->assertTrue(true); } try { $validator = CopixValidatorFactory::create('copixtest|validatorConstructNoInterface'); $this->assertTrue(false); } catch (CopixException $e) { $this->assertTrue(true); } $validator = CopixValidatorFactory::create('copixtest|validatorMod2'); $this->assertTrue($validator->check(4)); $this->assertTrue($validator->check(5) !== true); $validator = _validator('copixtest|validatorMod2'); $this->assertTrue($validator->check(4)); $this->assertTrue($validator->check(5) !== true); //test avec des paramètres $validator = CopixValidatorFactory::create('copixtest|validatorMod', array('mod' => 5)); $this->assertTrue($validator->check(10)); $this->assertTrue($validator->check(6) !== true); $validator = _validator('copixtest|validatorMod', array('mod' => 5)); $this->assertTrue($validator->check(10)); $this->assertTrue($validator->check(6) !== true); //test avec des paramètres (non tableau) $validator = CopixValidatorFactory::create('copixtest|validatorMod', 6); $this->assertTrue($validator->check(12)); $this->assertTrue($validator->check(7) !== true); $validator = _validator('copixtest|validatorMod', 6); $this->assertTrue($validator->check(12)); $this->assertTrue($validator->check(7) !== true); //test sans passer tous les paramètres $validator = _validator('copixtest|validatorMod'); try { $this->assertTrue($validator->check(12)); $this->assertTrue(false); } catch (CopixException $e) { $this->assertTrue(true); } }