/** * testEnum method * * @return void */ public function testEnum() { $result = Set::enum(1, 'one, two'); $this->assertEquals('two', $result); $result = Set::enum(2, 'one, two'); $this->assertNull($result); $set = array('one', 'two'); $result = Set::enum(0, $set); $this->assertEquals('one', $result); $result = Set::enum(1, $set); $this->assertEquals('two', $result); $result = Set::enum(1, array('one', 'two')); $this->assertEquals('two', $result); $result = Set::enum(2, array('one', 'two')); $this->assertNull($result); $result = Set::enum('first', array('first' => 'one', 'second' => 'two')); $this->assertEquals('one', $result); $result = Set::enum('third', array('first' => 'one', 'second' => 'two')); $this->assertNull($result); $result = Set::enum('no', array('no' => 0, 'yes' => 1)); $this->assertEquals(0, $result); $result = Set::enum('not sure', array('no' => 0, 'yes' => 1)); $this->assertNull($result); $result = Set::enum(0); $this->assertEquals('no', $result); $result = Set::enum(1); $this->assertEquals('yes', $result); $result = Set::enum(2); $this->assertNull($result); }
/** * testEnum method * * @access public * @return void */ function testEnum() { $result = Set::enum(1, 'one, two'); $this->assertIdentical($result, 'two'); $result = Set::enum(2, 'one, two'); $this->assertNull($result); $result = Set::enum(1, array('one', 'two')); $this->assertIdentical($result, 'two'); $result = Set::enum(2, array('one', 'two')); $this->assertNull($result); $result = Set::enum('first', array('first' => 'one', 'second' => 'two')); $this->assertIdentical($result, 'one'); $result = Set::enum('third', array('first' => 'one', 'second' => 'two')); $this->assertNull($result); $result = Set::enum('no', array('no' => 0, 'yes' => 1)); $this->assertIdentical($result, 0); $result = Set::enum('not sure', array('no' => 0, 'yes' => 1)); $this->assertNull($result); }
public function getReturnedMessage($code) { return empty($code) ? '' : Set::enum($code, $this->returned_messages); }
function _modifyChecks_r(&$array) { static $condEnum = array('logical' => array('not' => CHECK_CONDITION_LOGICAL_NOT, 'and' => CHECK_CONDITION_LOGICAL_AND, 'or' => CHECK_CONDITION_LOGICAL_OR, 'atleast' => CHECK_CONDITION_LOGICAL_AT_LEAST, 'atmost' => CHECK_CONDITION_LOGICAL_AT_MOST), 'registry' => array('exist' => CHECK_CONDITION_REGISTRY_EXISTS, 'equals' => CHECK_CONDITION_REGISTRY_EQUALS), 'file' => array('exists' => CHECK_CONDITION_FILE_EXISTS, 'sizeequals' => CHECK_CONDITION_FILE_SIZE_EQUALS, 'versionsmallerthan' => CHECK_CONDITION_FILE_VERSION_SMALLER_THAN, 'versionlessorequal' => CHECK_CONDITION_FILE_VERSION_LESS_THAN_OR_EQUAL_TO, 'versionequalto' => CHECK_CONDITION_FILE_VERSION_EQUAL_TO, 'versiongreaterthan' => CHECK_CONDITION_FILE_VERSION_GREATER_THAN, 'versiongreaterorequal' => CHECK_CONDITION_FILE_VERSION_GREATER_THAN_OR_EQUAL_TO), 'execute' => array('exitcodesmallerthan' => CHECK_CONDITION_EXECUTE_EXIT_CODE_SMALLER_THAN, 'exitcodelessorequal' => CHECK_CONDITION_EXECUTE_EXIT_CODE_LESS_THAN_OR_EQUAL_TO, 'exitcodeequalto' => CHECK_CONDITION_EXECUTE_EXIT_CODE_EQUAL_TO, 'exitcodegreaterthan' => CHECK_CONDITION_EXECUTE_EXIT_CODE_GREATER_THAN, 'exitcodegreaterorequal' => CHECK_CONDITION_EXECUTE_EXIT_CODE_GREATER_THAN_OR_EQUAL_TO), 'uninstall' => array('exists' => CHECK_CONDITION_UNINSTALL_EXISTS)); $array['condition'] = Set::enum(strtolower($array['condition']), $condEnum[strtolower($array['type'])]); $array['type'] = constant('CHECK_TYPE_' . strtoupper($array['type'])); if (isset($array['Childcheck']) && $array['type'] == CHECK_TYPE_LOGICAL) { $this->_arrayify($array['Childcheck']); for ($i = 0; $i < count($array['Childcheck']); $i++) { $this->_modifyChecks_r($array['Childcheck'][$i]); } } }