$actual = CRM_Utils_String::parsePrefix(':', $input, $defaultPrefix);
$this->assertEquals($expected, $actual);
}
+
+ function booleanDataProvider() {
+ $cases = array(); // array(0 => $input, 1 => $expectedOutput)
+ $cases[] = array(TRUE, TRUE);
+ $cases[] = array(FALSE, FALSE);
+ $cases[] = array(1, TRUE);
+ $cases[] = array(0, FALSE);
+ $cases[] = array('1', TRUE);
+ $cases[] = array('0', FALSE);
+ $cases[] = array(TRUE, TRUE);
+ $cases[] = array(FALSE, FALSE);
+ $cases[] = array('Y', TRUE);
+ $cases[] = array('N', FALSE);
+ $cases[] = array('y', TRUE);
+ $cases[] = array('n', FALSE);
+ $cases[] = array('Yes', TRUE);
+ $cases[] = array('No', FALSE);
+ $cases[] = array('True', TRUE);
+ $cases[] = array('False', FALSE);
+ $cases[] = array('yEs', TRUE);
+ $cases[] = array('nO', FALSE);
+ $cases[] = array('tRuE', TRUE);
+ $cases[] = array('FaLsE', FALSE);
+ return $cases;
+ }
+
+ /**
+ * @param $input
+ * @param $expected bool
+ * @dataProvider booleanDataProvider
+ */
+ function testStrToBool($input, $expected) {
+ $actual = CRM_Utils_String::strtobool($input);
+ $this->assertTrue($expected === $actual);
+ }
+
}