Index: tests/t3lib/t3lib_divTest.php =================================================================== --- tests/t3lib/t3lib_divTest.php (revision 8127) +++ tests/t3lib/t3lib_divTest.php (working copy) @@ -1542,5 +1542,81 @@ rmdir($directory); } + + /** + * Data provider for checkIsFirstPartOfStrReturnsTrueForMatchingFirstParts + * + * @return array + */ + public function matchingFirstPartsDataProvider() { + return array( + 'hello world/hello' => array('hello world', 'hello'), + 'hello/hello' => array('hello', 'hello'), + + ); + } + + /** + * Data provider for checkIsFirstPartOfStrReturnsFalseForNotMatchingFirstParts + * + * @return array + */ + public function notMatchingFirstPartsDataProvider() { + return array( + 'hello/bye' => array('hello', 'bye'), + 'bye/hello' => array('bye', 'hello'), + 'string/array' => array('string', array()), + 'array/string' => array(array(), 'string'), + 'string/null' => array('string', NULL), + 'null/string' => array(NULL, 'string'), + 'array/null' => array(array(), NULL), + 'null/array' => array(NULL, array()), + 'empty strings' => array('', ''), + 'empty string/null' => array('', NULL), + 'empty string/false' => array('', FALSE), + 'null/empty string' => array(NULL, ''), + 'false/empty string' => array(FALSE, ''), + 'zero/empty string' => array(0, ''), + 'null/zero' => array(NULL, 0), + 'empty string/zero' => array('', 0), + 'string/integer' => array('24', 24), + 'integer/string' => array(24, '24'), + 'string/integer as first part' => array('24 Bier bitte', 24) + ); + } + + /** + * Checks if t3lib_div::isFirstPartOfStr returns true for a set of matching + * string/firstParts. + * + * @test + * @see t3lib_div::isFirstPartOfStr + * @dataProvider matchingFirstPartsDataProvider + */ + public function checkIsFirstPartOfStrReturnsTrueForMatchingFirstParts($str, $partStr) { + $this->assertTrue(t3lib_div::isFirstPartOfStr($str, $partStr)); + } + + /** + * Checks if t3lib_div::isFirstPartOfStr returns false for a not matching + * pair of string and firstPart. + * + * @test + * @see t3lib_div::isFirstPartOfStr + * @dataProvider notMatchingFirstPartsDataProvider + */ + public function checkIsFirstPartOfStrReturnsFalseForNotMatchingFirstParts($str, $partStr) { + $this->assertFalse(t3lib_div::isFirstPartOfStr($str, $partStr)); + } + + /** + * Checks if t3lib_div::isFirstPartOfStr works case sensitive. + * + * @test + * @see t3lib_div::isFirstPartOfStr + */ + public function checkIsFirstPartOfStrWorksCaseSensitive($str, $partStr) { + $this->assertFalse(t3lib_div::isFirstPartOfStr('hello world', 'Hello')); + } } ?> \ No newline at end of file