Bug #23086 ยป tests.diff
tests/t3lib/t3lib_pageselectTest.php (working copy) | ||
---|---|---|
/**
|
||
* Testcase for class t3lib_page
|
||
*
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
* @author Christian Kuhn <lolli@schwarzbu.ch>
|
||
* @author Oliver Klee <typo3-coding@oliverklee.de>
|
||
*
|
||
* @package TYPO3
|
||
* @subpackage t3lib
|
||
*/
|
||
... | ... | |
$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/',
|
||
)
|
||
)
|
||
);
|
||
}
|
||
}
|
||
?>
|
tests/t3lib/t3lib_arraybrowserTest.php (revision 0) | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 2010 Oliver Klee (typo3-coding@oliverklee.de)
|
||
* All rights reserved
|
||
*
|
||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||
* free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* The GNU General Public License can be found at
|
||
* http://www.gnu.org/copyleft/gpl.html.
|
||
*
|
||
* This script is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
/**
|
||
* Testcase for the t3lib_arrayBrowser class in the TYPO3 Core.
|
||
*
|
||
* @package TYPO3
|
||
* @subpackage t3lib
|
||
*
|
||
* @author Oliver Klee <typo3-coding@oliverklee.de>
|
||
*/
|
||
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())
|
||
);
|
||
}
|
||
}
|
||
?>
|
tests/t3lib/t3lib_csTest.php (revision 0) | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 2010 Oliver Klee (typo3-coding@oliverklee.de)
|
||
* All rights reserved
|
||
*
|
||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||
* free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* The GNU General Public License can be found at
|
||
* http://www.gnu.org/copyleft/gpl.html.
|
||
*
|
||
* This script is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
/**
|
||
* Testcase for the t3lib_cs class in the TYPO3 Core.
|
||
*
|
||
* @package TYPO3
|
||
* @subpackage t3lib
|
||
*
|
||
* @author Oliver Klee <typo3-coding@oliverklee.de>
|
||
*/
|
||
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')
|
||
);
|
||
}
|
||
}
|
||
?>
|
tests/t3lib/t3lib_divTest.php (working copy) | ||
---|---|---|
}
|
||
///////////////////////////////
|
||
// 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)
|
||
);
|
||
}
|
||
/**
|