Commit 1721a490 authored by Wouter Wolters's avatar Wouter Wolters Committed by Christian Kuhn
Browse files

[TASK] Namespace and move t3lib unit tests - 5

This patch moves most unit tests of the tests/Unit/t3lib/*
directory to the core extension, following the new name scheme.

Change-Id: Ia08a3c0251c577676e3920dc880bb54e1651e5c2
Resolves: #40620
Related: #40095
Releases: 6.0
Reviewed-on: http://review.typo3.org/14339
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
parent 4b7a3860
<?php
namespace TYPO3\CMS\Backend\Tests\Unit\Configuration\TypoScript\ConditionMatching;
/***************************************************************
* Copyright notice
*
......@@ -21,32 +23,33 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for class t3lib_matchCondition_frontend.
* Testcase for class \TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher.
*
* @author Oliver Hader <oliver@typo3.org>
* @package TYPO3
* @subpackage t3lib
*/
class t3lib_matchCondition_backendTest extends tx_phpunit_testcase {
class ConditionMatcherTest extends \tx_phpunit_testcase {
/**
* @var array
* @var array
*/
private $backupGlobalVariables;
/**
* @var array
* @var array
*/
private $rootline;
/**
* @var t3lib_matchCondition_backend
* @var \TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher
*/
private $matchCondition;
/**
* @var string
* @var string
*/
private $testTableName;
......@@ -277,7 +280,7 @@ class t3lib_matchCondition_backendTest extends tx_phpunit_testcase {
* @test
*/
public function languageConditionMatchesCompleteLanguagesExpression() {
$this->markTestSkipped('This comparison seems to be incomplete in t3lib_matchCondition.');
$this->markTestSkipped('This comparison seems to be incomplete in \TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher.');
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
$this->assertTrue($this->matchCondition->match('[language = de-de,de;q=0.8]'));
}
......@@ -806,7 +809,7 @@ class t3lib_matchCondition_backendTest extends tx_phpunit_testcase {
* @test
*/
public function genericGetVariablesFailsWithNamespaceTSFE() {
$GLOBALS['TSFE'] = new stdClass();
$GLOBALS['TSFE'] = new \stdClass();
$GLOBALS['TSFE']->id = 1234567;
$this->assertFalse($this->matchCondition->match('[globalString = TSFE:id = 1234567]'));
}
......
<?php
namespace TYPO3\CMS\Backend\Tests\Unit\Tree\Pagetree;
/***************************************************************
* Copyright notice
*
......@@ -29,7 +31,7 @@
* @package TYPO3
* @subpackage t3lib
*/
class t3lib_tree_pagetree_DataProviderTest extends tx_phpunit_testcase {
class DataProviderTest extends \tx_phpunit_testcase {
/**
* @var boolean
......@@ -44,7 +46,7 @@ class t3lib_tree_pagetree_DataProviderTest extends tx_phpunit_testcase {
protected $backupGlobalsBlacklist = array('TYPO3_DB');
/**
* @var t3lib_tree_pagetree_DataProvider|PHPUnit_Framework_MockObject_MockObject
* @var \TYPO3\CMS\Backend\Tree\Pagetree\DataProvider|\PHPUnit_Framework_MockObject_MockObject
*/
protected $fixture = NULL;
......
<?php
namespace TYPO3\CMS\Backend\Tests\Unit\Tree;
/***************************************************************
* Copyright notice
*
......@@ -21,14 +23,15 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for class t3lib_tree_SortedNodeCollection.
* Testcase for class \TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection.
*
* @author Stefan Galinski <stefan.galinski@gmail.com>
* @package TYPO3
* @subpackage t3lib
*/
class t3lib_tree_SortedNodeCollectionTest extends tx_phpunit_testcase {
class SortedTreeNodeCollectionTest extends \tx_phpunit_testcase {
protected function createTestCollection() {
$nodeCollection = new \TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection();
......
<?php
namespace TYPO3\CMS\Backend\Tests\Unit\Tree;
/***************************************************************
* Copyright notice
*
......@@ -21,14 +23,15 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for class t3lib_tree_NodeCollection.
* Testcase for class \TYPO3\CMS\Backend\Tree\TreeNodeCollection.
*
* @author Stefan Galinski <stefan.galinski@gmail.com>
* @package TYPO3
* @subpackage t3lib
*/
class t3lib_tree_NodeCollectionTest extends tx_phpunit_testcase {
class TreeNodeCollectionTest extends \tx_phpunit_testcase {
public function setUp() {
......
<?php
namespace TYPO3\CMS\Backend\Tests\Unit\Tree;
/***************************************************************
* Copyright notice
*
......@@ -21,14 +23,15 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for class t3lib_tree_Node.
* Testcase for class \TYPO3\CMS\Backend\Tree\TreeNode.
*
* @author Stefan Galinski <stefan.galinski@gmail.com>
* @package TYPO3
* @subpackage t3lib
*/
class t3lib_tree_NodeTest extends tx_phpunit_testcase {
class TreeNodeTest extends \tx_phpunit_testcase {
//////////////////////
// Utility functions
......@@ -39,7 +42,8 @@ class t3lib_tree_NodeTest extends tx_phpunit_testcase {
* @return string the absolute fixtures path for this testcase, will not be empty
*/
private function determineFixturesPath() {
return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Phpunit_Service_TestFinder')->getAbsoluteCoreTestsPath() . 'Unit/t3lib/tree/fixtures/';
// We have to take the whole relative path as otherwise this test fails on Windows systems
return PATH_site . 'typo3/sysext/backend/Tests/Unit/Tree/Fixtures/';
}
protected function setUpNodeTestData() {
......
<?php
namespace TYPO3\CMS\Core\Tests\Unit\Mail;
/***************************************************************
* Copyright notice
*
......@@ -21,14 +23,15 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for the t3lib_mail_Mailer class.
* Testcase for the TYPO3\CMS\Core\Mail\Mailer class.
*
* @package TYPO3
* @subpackage t3lib
* @author Helmut Hummel <helmut.hummel@typo3.org>
*/
class t3lib_mail_MailerTest extends tx_phpunit_testcase {
class MailerTest extends \tx_phpunit_testcase {
/**
* @var \TYPO3\CMS\Core\Mail\Mailer
......@@ -103,7 +106,7 @@ class t3lib_mail_MailerTest extends tx_phpunit_testcase {
*/
public function providingCorrectClassnameDoesNotThrowException() {
if (!class_exists('t3lib_mail_SwiftMailerFakeTransport')) {
// Create fake custom transport class
// Create fake custom transport class
eval('class t3lib_mail_SwiftMailerFakeTransport extends \\TYPO3\\CMS\\Core\\Mail\\MboxTransport {
public function __construct($settings) {}
}');
......
<?php
namespace TYPO3\CMS\Core\Tests\Unit\Mail;
/***************************************************************
* Copyright notice
*
......@@ -21,14 +23,15 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for the t3lib_mail_SwiftMailerAdapter class.
* Testcase for the \TYPO3\CMS\Core\Mail\SwiftMailerAdapter class.
*
* @package TYPO3
* @subpackage t3lib
* @author Ernesto Baschny <ernst@cron-it.de>
*/
class t3lib_mail_SwiftMailerAdapterTest extends tx_phpunit_testcase {
class SwiftMailerAdapterTest extends \tx_phpunit_testcase {
/**
* @var \TYPO3\CMS\Core\Mail\SwiftMailerAdapter
......@@ -36,15 +39,7 @@ class t3lib_mail_SwiftMailerAdapterTest extends tx_phpunit_testcase {
protected $fixture;
public function setUp() {
if (!class_exists('t3lib_mail_SwiftMailerAdapterExposed')) {
// Make protected methods accessible so that they can be tested:
eval('class t3lib_mail_SwiftMailerAdapterExposed extends \\TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter {
public function parseAddressesExposed($args) {
return $this->parseAddresses($args);
}
}');
}
$this->fixture = new t3lib_mail_SwiftMailerAdapterExposed();
$this->fixture = $this->getAccessibleMock('\\TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter', array('dummy'));
}
public function tearDown() {
......@@ -83,7 +78,7 @@ class t3lib_mail_SwiftMailerAdapterTest extends tx_phpunit_testcase {
* @dataProvider parseAddressesProvider
*/
public function parseAddressesTest($source, $addressList) {
$this->assertEquals($addressList, $this->fixture->parseAddressesExposed($source));
$this->assertEquals($addressList, $this->fixture->_callRef('parseAddresses', $source));
}
}
......
<?php
namespace TYPO3\CMS\Core\Tests\Unit\Utility;
/***************************************************************
* Copyright notice
*
......@@ -21,15 +23,16 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for class t3lib_utility_array
* Testcase for class \TYPO3\CMS\Core\Utility\ArrayUtility
*
* @author Susanne Moog <typo3@susanne-moog.de>
* @author Christian Kuhn <lolli@schwarzbu.ch>
* @package TYPO3
* @subpackage t3lib
*/
class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
class ArrayUtilityTest extends \tx_phpunit_testcase {
///////////////////////
// Tests concerning filterByValueRecursive
......@@ -168,22 +171,31 @@ class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
* @dataProvider filterByValueRecursive
*/
public function filterByValueRecursiveCorrectlyFiltersArray($needle, $haystack, $expectedResult) {
$this->assertEquals($expectedResult, \TYPO3\CMS\Core\Utility\ArrayUtility::filterByValueRecursive($needle, $haystack));
$this->assertEquals(
$expectedResult,
\TYPO3\CMS\Core\Utility\ArrayUtility::filterByValueRecursive($needle, $haystack)
);
}
/**
* @test
*/
public function filterByValueRecursiveMatchesReferencesToSameObject() {
$instance = new stdClass();
$this->assertEquals(array($instance), \TYPO3\CMS\Core\Utility\ArrayUtility::filterByValueRecursive($instance, array($instance)));
$instance = new \stdClass();
$this->assertEquals(
array($instance),
\TYPO3\CMS\Core\Utility\ArrayUtility::filterByValueRecursive($instance, array($instance))
);
}
/**
* @test
*/
public function filterByValueRecursiveDoesNotMatchDifferentInstancesOfSameClass() {
$this->assertEquals(array(), \TYPO3\CMS\Core\Utility\ArrayUtility::filterByValueRecursive(new stdClass(), array(new stdClass())));
$this->assertEquals(
array(),
\TYPO3\CMS\Core\Utility\ArrayUtility::filterByValueRecursive(new \stdClass(), array(new \stdClass()))
);
}
///////////////////////
......@@ -200,7 +212,14 @@ class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
public function isValidPathReturnsTrueIfPathExists() {
$namespace = 'TYPO3\\CMS\\Core\\Utility';
$className = uniqid('ArrayUtility');
eval(((((('namespace ' . $namespace . '; class ' . $className) . ' extends \\TYPO3\\CMS\\Core\\Utility\\ArrayUtility {') . ' public static function getValueByPath() {') . ' return 42;') . ' }') . '}');
eval(
'namespace ' . $namespace . ';' .
'class ' . $className . ' extends \\TYPO3\\CMS\\Core\\Utility\\ArrayUtility {' .
' public static function getValueByPath() {' .
' return 42;' .
' }' .
'}'
);
$className = $namespace . '\\' . $className;
$this->assertTrue($className::isValidPath(array('foo'), 'foo'));
}
......@@ -211,7 +230,14 @@ class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
public function isValidPathReturnsFalseIfPathDoesNotExist() {
$namespace = 'TYPO3\\CMS\\Core\\Utility';
$className = uniqid('ArrayUtility');
eval(((((('namespace ' . $namespace . '; class ' . $className) . ' extends \\TYPO3\\CMS\\Core\\Utility\\ArrayUtility {') . ' public static function getValueByPath() {') . ' throw new \RuntimeException(\'foo\', 123);') . ' }') . '}');
eval(
'namespace ' . $namespace . ';' .
'class ' . $className . ' extends \\TYPO3\\CMS\\Core\\Utility\\ArrayUtility {' .
' public static function getValueByPath() {' .
' throw new \RuntimeException(\'foo\', 123);' .
' }' .
'}'
);
$className = $namespace . '\\' . $className;
$this->assertFalse($className::isValidPath(array('foo'), 'foo'));
}
......@@ -295,7 +321,7 @@ class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
* - Expected result
*/
public function getValueByPathValidDataProvider() {
$testObject = new StdClass();
$testObject = new \StdClass();
$testObject->foo = 'foo';
$testObject->bar = 'bar';
return array(
......@@ -402,7 +428,10 @@ class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
$searchPath = 'foo%bar%baz';
$expected = 42;
$delimeter = '%';
$this->assertEquals($expected, \TYPO3\CMS\Core\Utility\ArrayUtility::getValueByPath($input, $searchPath, $delimeter));
$this->assertEquals(
$expected,
\TYPO3\CMS\Core\Utility\ArrayUtility::getValueByPath($input, $searchPath, $delimeter)
);
}
///////////////////////
......@@ -434,7 +463,7 @@ class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
* - Expected result
*/
public function setValueByPathSetsCorrectValueDataProvider() {
$testObject = new StdClass();
$testObject = new \StdClass();
$testObject->foo = 'foo';
$testObject->bar = 'bar';
return array(
......@@ -600,7 +629,10 @@ class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
* @dataProvider setValueByPathSetsCorrectValueDataProvider
*/
public function setValueByPathSetsCorrectValue(array $array, $path, $value, $expectedResult) {
$this->assertEquals($expectedResult, \TYPO3\CMS\Core\Utility\ArrayUtility::setValueByPath($array, $path, $value));
$this->assertEquals(
$expectedResult,
\TYPO3\CMS\Core\Utility\ArrayUtility::setValueByPath($array, $path, $value)
);
}
///////////////////////
......@@ -653,7 +685,20 @@ class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
'baz' => 23,
'foobar' => NULL
);
$expected = ((((((((((((((((((((((((((((((((((((((((((((('array(' . LF) . TAB) . '\'foo\' => array(') . LF) . TAB) . TAB) . '\'bar\' => 42,') . LF) . TAB) . TAB) . '\'bar2\' => array(') . LF) . TAB) . TAB) . TAB) . '\'baz\' => \'val\\\'ue\',') . LF) . TAB) . TAB) . TAB) . '\'baz2\' => TRUE,') . LF) . TAB) . TAB) . TAB) . '\'baz3\' => FALSE,') . LF) . TAB) . TAB) . TAB) . '\'baz4\' => array(),') . LF) . TAB) . TAB) . '),') . LF) . TAB) . '),') . LF) . TAB) . '\'baz\' => 23,') . LF) . TAB) . '\'foobar\' => NULL,') . LF) . ')';
$expected =
'array(' . LF .
TAB . '\'foo\' => array(' . LF .
TAB . TAB . '\'bar\' => 42,' . LF .
TAB . TAB . '\'bar2\' => array(' . LF .
TAB . TAB . TAB . '\'baz\' => \'val\\\'ue\',' . LF .
TAB . TAB . TAB . '\'baz2\' => TRUE,' . LF .
TAB . TAB . TAB . '\'baz3\' => FALSE,' . LF .
TAB . TAB . TAB . '\'baz4\' => array(),' . LF .
TAB . TAB . '),' . LF .
TAB . '),' . LF .
TAB . '\'baz\' => 23,' . LF .
TAB . '\'foobar\' => NULL,' . LF .
')';
$this->assertSame($expected, \TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($array));
}
......@@ -664,7 +709,7 @@ class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
public function arrayExportThrowsExceptionIfObjectShouldBeExported() {
$array = array(
'foo' => array(
'bar' => new stdClass()
'bar' => new \stdClass()
)
);
\TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($array);
......@@ -679,7 +724,12 @@ class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
23 => 'integer key',
'42' => 'string key representing integer'
);
$expected = (((((((((('array(' . LF) . TAB) . '\'foo\' => \'string key\',') . LF) . TAB) . '23 => \'integer key\',') . LF) . TAB) . '42 => \'string key representing integer\',') . LF) . ')';
$expected =
'array(' . LF .
TAB . '\'foo\' => \'string key\',' . LF .
TAB . '23 => \'integer key\',' . LF .
TAB . '42 => \'string key representing integer\',' . LF .
')';
$this->assertSame($expected, \TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($array));
}
......@@ -692,7 +742,12 @@ class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
1 => 'one',
2 => 'two'
);
$expected = (((((((((('array(' . LF) . TAB) . '\'zero\',') . LF) . TAB) . '\'one\',') . LF) . TAB) . '\'two\',') . LF) . ')';
$expected =
'array(' . LF .
TAB . '\'zero\',' . LF .
TAB . '\'one\',' . LF .
TAB . '\'two\',' . LF .
')';
$this->assertSame($expected, \TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($array));
}
......@@ -706,7 +761,13 @@ class t3lib_utility_ArrayTest extends tx_phpunit_testcase {
3 => 'three',
4 => 'four'
);
$expected = ((((((((((((('array(' . LF) . TAB) . '0 => \'zero\',') . LF) . TAB) . '1 => \'one\',') . LF) . TAB) . '3 => \'three\',') . LF) . TAB) . '4 => \'four\',') . LF) . ')';
$expected =
'array(' . LF .
TAB . '0 => \'zero\',' . LF .
TAB . '1 => \'one\',' . LF .
TAB . '3 => \'three\',' . LF .
TAB . '4 => \'four\',' . LF .
')';
$this->assertSame($expected, \TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($array));
}
......
<?php
namespace TYPO3\CMS\Core\Tests\Unit\Utility;
/***************************************************************
* Copyright notice
*
......@@ -21,14 +23,15 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for the t3lib_utility_Client class.
* Testcase for the \TYPO3\CMS\Core\Utility\ClientUtility class.
*
* @package TYPO3
* @subpackage t3lib
* @author Steffen Kamper <info@sk-typo3.de>
*/
class t3lib_utility_clientTest extends tx_phpunit_testcase {
class ClientUtilityTest extends \tx_phpunit_testcase {
/**
* backed-up TYPO3_CONF_VARS SC_OPTIONS
......
<?php
namespace TYPO3\CMS\Core\Tests\Unit\Utility;
/***************************************************************
* Copyright notice
*
......@@ -25,13 +27,13 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for class t3lib_utility_Http
* Testcase for class \TYPO3\CMS\Core\Utility\HttpUtility
*
* @author Oliver Hader <oliver.hader@typo3.org>
* @package TYPO3
* @subpackage t3lib
*/
class t3lib_utility_HttpTest extends tx_phpunit_testcase {
class HttpUtilityTest extends \tx_phpunit_testcase {
/**
* @param array $urlParts
......
<?php
namespace TYPO3\CMS\Core\Tests\Unit\Utility;
/***************************************************************
* Copyright notice
*
......@@ -21,14 +23,15 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for the t3lib_utility_Mail class.
* Testcase for the \TYPO3\CMS\Core\Utility\MailUtility class.
*
* @package TYPO3
* @subpackage t3lib
* @author Oliver Klee <typo3-coding@oliverklee.de>
*/
class t3lib_utility_MailTest extends tx_phpunit_testcase {
class MailUtilityTest extends \tx_phpunit_testcase {
/**
* backed-up TYPO3_CONF_VARS SC_OPTIONS
......
......@@ -27,13 +27,13 @@ namespace TYPO3\CMS\Core\Tests\Unit\Utility;
require_once 'Fixtures/MathUtilityTestClassWithStringRepresentationFixture.php';
/**
* Testcase for class t3lib_utility_Math
* Testcase for class \TYPO3\CMS\Core\Utility\MathUtility
*
* @author Susanne Moog <typo3@susanne-moog.de>
* @package TYPO3
* @subpackage t3lib
*/
class t3lib_utility_MathTest extends \tx_phpunit_testcase {
class MathUtilityTest extends \tx_phpunit_testcase {
//////////////////////////////////
// Tests concerning forceIntegerInRange
......
<?php
namespace TYPO3\CMS\Core\Tests\Unit\Utility;
/***************************************************************
* Copyright notice
*
......@@ -24,14 +26,15 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for class t3lib_utility_Path
* Testcase for class \TYPO3\CMS\Core\Utility\PathUtility
*
* @author Oliver Hader <oliver.hader@typo3.org>
* @package TYPO3
* @subpackage t3lib
*/
class t3lib_utility_PathTest extends tx_phpunit_testcase {
class PathUtilityTest extends \tx_phpunit_testcase {
/**
* @param array $paths
......
<?php
namespace TYPO3\CMS\Core\Tests\Unit\Utility;
/***************************************************************
* Copyright notice
*
......@@ -28,7 +30,7 @@
* @package TYPO3
* @subpackage t3lib
*/
class t3lib_utility_StringTest extends tx_phpunit_testcase {
class StringUtilityTest extends \tx_phpunit_testcase {
/**
* Data provider for isLastPartOfStrReturnsTrueForMatchingLastParts
......
<?php
namespace TYPO3\CMS\Core\Tests\Unit\Utility;
/***************************************************************
* Copyright notice
*
......@@ -21,14 +23,15 @@