/** * The constructor. * @param ref object $configuration A {@link Properties} Properties with configuration for connection. * @access public * @return void **/ function LDAPConnector($configuration) { $this->_configuration = $configuration; // Validate the configuration options we use: ArgumentValidator::validate($this->_configuration->getProperty('LDAPHost'), FieldRequiredValidatorRule::getRule()); ArgumentValidator::validate($this->_configuration->getProperty('LDAPPort'), OptionalRule::getRule(NumericValidatorRule::getRule())); ArgumentValidator::validate($this->_configuration->getProperty('UserBaseDN'), FieldRequiredValidatorRule::getRule()); ArgumentValidator::validate($this->_configuration->getProperty('ClassesBaseDN'), FieldRequiredValidatorRule::getRule()); ArgumentValidator::validate($this->_configuration->getProperty('GroupBaseDN'), FieldRequiredValidatorRule::getRule()); ArgumentValidator::validate($this->_configuration->getProperty('bindDN'), OptionalRule::getRule(StringValidatorRule::getRule())); ArgumentValidator::validate($this->_configuration->getProperty('bindDNPassword'), OptionalRule::getRule(StringValidatorRule::getRule())); }
/** * Tests different types of validations. */ function test_All_Sorts_Of_Values() { // test a plain string $this->assertTrue(ArgumentValidator::validate("Hello!", StringValidatorRule::getRule(), true)); // test numeric values $this->assertTrue(ArgumentValidator::validate("23.21E10", NumericValidatorRule::getRule(), true)); $this->assertTrue(ArgumentValidator::validate(23, NumericValidatorRule::getRule(), true)); $this->assertTrue(ArgumentValidator::validate(23.21, NumericValidatorRule::getRule(), true)); // test integer values $this->assertTrue(ArgumentValidator::validate(23, IntegerValidatorRule::getRule(), true)); // test string values $this->assertTrue(ArgumentValidator::validate("23", StringValidatorRule::getRule(), true)); // test email values $this->assertTrue(ArgumentValidator::validate("*****@*****.**", EmailValidatorRule::getRule(), true)); $this->assertFalse(ArgumentValidator::validate("dradichk@middlebury", EmailValidatorRule::getRule(), false), "Gabe, fix this! Your EmailValidatorRule is faulty!"); // test boolean values $this->assertTrue(ArgumentValidator::validate(true, BooleanValidatorRule::getRule(), true)); $this->assertFalse(ArgumentValidator::validate("HOHO", BooleanValidatorRule::getRule(), false), "Gabe, fix this! Your BooleanValidatorRule is faulty!\nIn fact, I think you should just use is_bool() in your check() function."); }
function test_rule_set_add_multiple() { $this->assertEqual($this->testRuleSet->count(), 0); // what the hell is this??? // $error = 1; $error = new Error("UnitTest", "UnitTest", false); $rq = FieldRequiredValidatorRule::getRule(); $email = EmailValidatorRule::getRule(); $number = NumericValidatorRule::getRule(); $this->testRuleSet->addRule("mystring", $rq, $error); $this->testRuleSet->addRule("mystring", $email, $error); $this->testRuleSet->addRule("boolean", BooleanValidatorRule::getRule(), $error); $this->testRuleSet->addRule("mynumber", $number, $error); $this->assertEqual($this->testRuleSet->count(), 3); $this->assertReference($this->testRuleSet->_rules["mystring"][0][0], $rq); $this->assertReference($this->testRuleSet->_rules["mystring"][1][0], $email); $this->assertReference($this->testRuleSet->_rules["mynumber"][0][0], $number); // $this->assertEqual($this->testRuleSet->getKeys(), array("mystring","mynumber","boolean")); }
/** * Get the unique Id with this String representation or create a new unique * Id with this representation. * * @param string $idString * * @return object Id * * @throws object IdException An exception with one of the following * messages defined in org.osid.id.IdException: {@link * org.osid.id.IdException#OPERATION_FAILED OPERATION_FAILED}, * {@link org.osid.id.IdException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.id.IdException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.id.IdException#UNIMPLEMENTED UNIMPLEMENTED}, {@link * org.osid.id.IdException#NULL_ARGUMENT NULL_ARGUMENT} * * @access public */ function getId($idString) { // if (isset($this->_ids[$idString])) { // print "id:". $idString." and ".$this->_ids[$idString]->getIdString()."<br/>"; // return $this->_ids[$idString]; // } ArgumentValidator::validate($idString, OrValidatorRule::getRule(NonzeroLengthStringValidatorRule::getRule(), NumericValidatorRule::getRule())); $id = new HarmoniId($idString); // cache the id // $this->_ids[$idString] = $id; return $id; }
/** * Sets the value of this text field. * @param string $value * @access public * @return void */ function setValue($value) { ArgumentValidator::validate($value, OrValidatorRule::getRule(StringValidatorRule::getRule(), NumericValidatorRule::getRule())); $this->_value = $value; }