/** * Checks if the given value(s) exist in the attribute * * @param string $attribName * @param mixed|array $value * @return bool */ public function attributeHasValue($attribName, $value) { return Ldap\Attribute::attributeHasValue($this->currentData, $attribName, $value); }
public function testHasValue() { $data = array('strings1' => array('value1', 'value2', 'value2', 'value3'), 'strings2' => array('value1', 'value2', 'value3', 'value4'), 'boolean1' => array('TRUE', 'TRUE', 'TRUE', 'TRUE'), 'boolean2' => array('TRUE', 'FALSE', 'TRUE', 'FALSE')); $this->assertTrue(Attribute::attributeHasValue($data, 'strings1', 'value1')); $this->assertFalse(Attribute::attributeHasValue($data, 'strings1', 'value4')); $this->assertTrue(Attribute::attributeHasValue($data, 'boolean1', true)); $this->assertFalse(Attribute::attributeHasValue($data, 'boolean1', false)); $this->assertTrue(Attribute::attributeHasValue($data, 'strings1', array('value1', 'value2'))); $this->assertTrue(Attribute::attributeHasValue($data, 'strings1', array('value1', 'value2', 'value3'))); $this->assertFalse(Attribute::attributeHasValue($data, 'strings1', array('value1', 'value2', 'value3', 'value4'))); $this->assertTrue(Attribute::attributeHasValue($data, 'strings2', array('value1', 'value2', 'value3', 'value4'))); $this->assertTrue(Attribute::attributeHasValue($data, 'boolean2', array(true, false))); $this->assertFalse(Attribute::attributeHasValue($data, 'boolean1', array(true, false))); }