[BUGFIX] Improve functional test execution on Windows system 91/36491/3
authorNicole Cordes <typo3@cordes.co>
Sat, 31 Jan 2015 11:01:09 +0000 (12:01 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sat, 31 Jan 2015 15:11:03 +0000 (16:11 +0100)
On Windows systems you can execute several commands using '&' like
set typo3DatabaseUsername=root & set typo3DatabasePassword=root.
Unfortunately Windows sets those parameter with a trailing space. This
causes database connections not to work. Therefore the patch adds a trim
on getting system environment variables for database credentials for
functional tests.

Furthermore the PHP versions on Windows throw a warning on setting the
database name when the connection is closed. The warning is caught by
PHPUnit but the database tables aren't initialized correctly. This patch
adds an '@' to mute the warning.

Releases: master, 6.2
Resolves: #64680
Change-Id: If649b5bd440a3bd504f028a3c9c96c9d294d380c
Reviewed-on: http://review.typo3.org/36491
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
typo3/sysext/core/Tests/FunctionalTestCaseBootstrapUtility.php

index 9a402f5..b671746 100644 (file)
@@ -264,12 +264,12 @@ class FunctionalTestCaseBootstrapUtility {
         * @return void
         */
        protected function setUpLocalConfiguration(array $configurationToMerge) {
-               $databaseName = getenv('typo3DatabaseName');
-               $databaseHost = getenv('typo3DatabaseHost');
-               $databaseUsername = getenv('typo3DatabaseUsername');
-               $databasePassword = getenv('typo3DatabasePassword');
-               $databasePort = getenv('typo3DatabasePort');
-               $databaseSocket = getenv('typo3DatabaseSocket');
+               $databaseName = trim(getenv('typo3DatabaseName'));
+               $databaseHost = trim(getenv('typo3DatabaseHost'));
+               $databaseUsername = trim(getenv('typo3DatabaseUsername'));
+               $databasePassword = trim(getenv('typo3DatabasePassword'));
+               $databasePort = trim(getenv('typo3DatabasePort'));
+               $databaseSocket = trim(getenv('typo3DatabaseSocket'));
                if ($databaseName || $databaseHost || $databaseUsername || $databasePassword || $databasePort || $databaseSocket) {
                        // Try to get database credentials from environment variables first
                        $originalConfigurationArray = array(
@@ -468,7 +468,8 @@ class FunctionalTestCaseBootstrapUtility {
                        );
                }
                $database->setDatabaseName($this->databaseName);
-               $database->sql_select_db();
+               // On windows, this still works, but throws a warning, which we need to discard.
+               @$database->sql_select_db();
        }
 
        /**