Index: tests/t3lib/t3lib_pageselectTest.php =================================================================== --- tests/t3lib/t3lib_pageselectTest.php (revision 8082) +++ tests/t3lib/t3lib_pageselectTest.php (working copy) @@ -26,7 +26,9 @@ /** * Testcase for class t3lib_page * - * @author Christian Kuhn + * @author Christian Kuhn + * @author Oliver Klee + * * @package TYPO3 * @subpackage t3lib */ @@ -110,5 +112,52 @@ $this->pageSelectObject->getPathFromRootline(array()) ); } + + + /////////////////////////////// + // Tests concerning getExtURL + /////////////////////////////// + + /** + * @test + */ + public function getExtUrlForDokType2ReturnsFalse() { + $this->assertEquals( + FALSE, + $this->pageSelectObject->getExtURL(array('doktype' => 2)) + ); + } + + /** + * @test + */ + public function getExtUrlForDokType3AndUrlType1AddsHttpSchemeToUrl() { + $this->assertEquals( + 'http://www.example.com', + $this->pageSelectObject->getExtURL( + array( + 'doktype' => 3, + 'urltype' => 1, + 'url' => 'www.example.com', + ) + ) + ); + } + + /** + * @test + */ + public function getExtUrlForDokType3AndUrlType0PrependsSiteUrl() { + $this->assertEquals( + t3lib_div::getIndpEnv('TYPO3_SITE_URL') . 'hello/world/', + $this->pageSelectObject->getExtURL( + array( + 'doktype' => 3, + 'urltype' => 0, + 'url' => 'hello/world/', + ) + ) + ); + } } ?> Index: tests/t3lib/t3lib_arraybrowserTest.php =================================================================== --- tests/t3lib/t3lib_arraybrowserTest.php (revision 0) +++ tests/t3lib/t3lib_arraybrowserTest.php (revision 0) @@ -0,0 +1,72 @@ + + */ +class t3lib_arrayBrowserTest extends tx_phpunit_testcase { + /** + * @var t3lib_arrayBrowser + */ + private $fixture; + + public function setUp() { + $this->fixture = new t3lib_arrayBrowser(); + } + + public function tearDown() { + unset($this->fixture); + } + + + /////////////////////////////// + // Tests concerning depthKeys + /////////////////////////////// + + /** + * @test + */ + public function depthKeysWithEmptyFirstParameterAddsNothing() { + $this->assertEquals( + array(), + $this->fixture->depthKeys(array(), array()) + ); + } + + /** + * @test + */ + public function depthKeysWithNumericKeyAddsOneNumberForKeyFromFirstArray() { + $this->assertEquals( + array(0 => 1), + $this->fixture->depthKeys(array('foo'), array()) + ); + } +} +?> \ No newline at end of file Index: tests/t3lib/t3lib_csTest.php =================================================================== --- tests/t3lib/t3lib_csTest.php (revision 0) +++ tests/t3lib/t3lib_csTest.php (revision 0) @@ -0,0 +1,79 @@ + + */ +class t3lib_csTest extends tx_phpunit_testcase { + /** + * @var t3lib_cs + */ + private $fixture = null; + + public function setUp() { + $this->fixture = new t3lib_cs(); + } + + public function tearDown() { + unset($this->fixture); + } + + + //////////////////////////// + // Tests concerning substr + //////////////////////////// + + /** + * @test + * + * @see http://bugs.typo3.org/view.php?id=13934 + */ + public function substrForEmptyStringAndNonZeroLengthReturnsEmptyString() { + $this->assertSame( + '', + $this->fixture->substr('utf-8', '', 0, 42) + ); + } + + + ///////////////////////////////// + // Tests concerning utf8_strlen + ///////////////////////////////// + + /** + * @test + */ + public function utf8_strlenForNonEmptyAsciiOnlyStringReturnsNumberOfCharacters() { + $this->assertEquals( + 10, + $this->fixture->utf8_strlen('good omens') + ); + } +} +?> \ No newline at end of file Index: tests/t3lib/t3lib_divTest.php =================================================================== --- tests/t3lib/t3lib_divTest.php (revision 8082) +++ tests/t3lib/t3lib_divTest.php (working copy) @@ -56,17 +56,78 @@ } + /////////////////////////////// + // Tests concerning splitCalc + /////////////////////////////// + + /** + * @test + */ + public function splitCalcForEmptyStringReturnsEmptyArray() { + $this->assertEquals( + array(), + t3lib_div::splitCalc('', '+-*/') + ); + } + + /** + * @test + */ + public function splitCalcForNumberWithoutOperatorReturnsArrayWithPlusAndNumber() { + $this->assertEquals( + array(array('+', 42)), + t3lib_div::splitCalc('42', '+-*/') + ); + } + + /** + * @test + */ + public function splitCalcForTwoNumbersWithAsterikReturnsFirstNumberWithPlusAndSecondNumberWithOperator() { + $this->assertEquals( + array( + array('+', 42), + array('*', 31), + ), + t3lib_div::splitCalc('42 * 31', '+-*/') + ); + } + + + ////////////////////////////////// + // Tests concerning calcPriority + ////////////////////////////////// + + /** + * @see calcPriorityCalculatesBasicArithmeticOperation + */ + public function calcPriorityTwoOperandsDataProvider() { + return array( + 'add' => array(9, '6 + 3'), + 'substractWithPositiveResult' => array(3, '6 - 3'), + 'substractWithNegativeResult' => array(-3, '3 - 6'), + 'multiply' => array(6, '2 * 3'), + 'divide' => array(2.5, '5 / 2'), + 'modulus' => array(1, '5 % 2'), + 'power' => array(8, '2 ^ 3'), + ); + } + /** * @test + * + * @dataProvider calcPriorityTwoOperandsDataProvider + * + * @param string $expected the expected value from calcPriority + * @param string $arithmeticExpression the string to feed to calcPriority */ - public function calcPriorityCalculatesBasicArithmeticOperation() { - $this->assertEquals(9, t3lib_div::calcPriority('6 + 3')); - $this->assertEquals(3, t3lib_div::calcPriority('6 - 3')); - $this->assertEquals(-3, t3lib_div::calcPriority('3 - 6')); - $this->assertEquals(6, t3lib_div::calcPriority('2 * 3')); - $this->assertEquals(2.5, t3lib_div::calcPriority('5 / 2')); - $this->assertEquals(1, t3lib_div::calcPriority('5 % 2')); - $this->assertEquals(8, t3lib_div::calcPriority('2 ^ 3')); + public function calcPriorityCalculatesBasicArithmeticOperation( + $expected, $arithmeticExpression + ) { + $this->assertEquals( + $expected, + t3lib_div::calcPriority($arithmeticExpression) + ); } /**