[BUGFIX] Fix minor issues in functional testing framework 04/31704/2
authorHelmut Hummel <helmut.hummel@typo3.org>
Sun, 20 Jul 2014 15:03:22 +0000 (17:03 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Mon, 21 Jul 2014 14:23:41 +0000 (16:23 +0200)
The bootstrap for frontend functional tests has some
minor issues, that are now fixed:

* json_decode returns null not false when not successfull
* Properly set the SERVER_PORT
* Use correct array key in error message
* Avoid notices with relative URLs

Releases: 6.2, 6.3
Resolves: #60413
Change-Id: I3ff07f01729d3403374759edbaa5ddcccd2e889a
Reviewed-on: https://review.typo3.org/31704
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
typo3/sysext/core/Tests/Functional/Framework/Frontend/RequestBootstrap.php
typo3/sysext/core/Tests/FunctionalTestCase.php

index d481ac9..1d0c931 100644 (file)
@@ -50,7 +50,7 @@ class RequestBootstrap {
                $_SERVER = array();
                $_SERVER['DOCUMENT_ROOT'] = $requestArguments['documentRoot'];
                $_SERVER['HTTP_USER_AGENT'] = 'TYPO3 Functional Test Request';
-               $_SERVER['HTTP_HOST'] = $_SERVER['SERVER_NAME'] = $requestUrlParts['host'];
+               $_SERVER['HTTP_HOST'] = $_SERVER['SERVER_NAME'] = isset($requestUrlParts['host']) ? $requestUrlParts['host'] : 'localhost';
                $_SERVER['SERVER_ADDR'] = $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
                $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'] = '/index.php';
                $_SERVER['SCRIPT_FILENAME'] = $_SERVER['_'] = $_SERVER['PATH_TRANSLATED'] = $requestArguments['documentRoot'] . '/index.php';
@@ -58,17 +58,23 @@ class RequestBootstrap {
                $_SERVER['REQUEST_URI'] = $requestUrlParts['path'] . (isset($requestUrlParts['query']) ? '?' . $requestUrlParts['query'] : '');
                $_SERVER['REQUEST_METHOD'] = 'GET';
 
+               // Define HTTPS and server port:
+               if (isset($requestUrlParts['scheme'])) {
+                       if ($requestUrlParts['scheme'] === 'https') {
+                               $_SERVER['HTTPS'] = 'on';
+                               $_SERVER['SERVER_PORT'] = '443';
+                       } else {
+                               $_SERVER['SERVER_PORT'] = '80';
+                       }
+               }
+
                // Define a port if used in the URL:
                if (isset($requestUrlParts['port'])) {
                        $_SERVER['SERVER_PORT'] = $requestUrlParts['port'];
                }
-               // Define HTTPS disposal:
-               if ($requestUrlParts['scheme'] === 'https') {
-                       $_SERVER['HTTPS'] = 'on';
-               }
 
                if (!is_dir($_SERVER['DOCUMENT_ROOT'])) {
-                       die('Document root directory "' . $_SERVER['SCRIPT_FILENAME'] . '" does not exist');
+                       die('Document root directory "' . $_SERVER['DOCUMENT_ROOT'] . '" does not exist');
                }
 
                if (!is_file($_SERVER['SCRIPT_FILENAME'])) {
index b3b45cc..ba81fb1 100644 (file)
@@ -360,7 +360,7 @@ abstract class FunctionalTestCase extends BaseTestCase {
                $response = $php->runJob($template->render());
                $result = json_decode($response['stdout'], TRUE);
 
-               if ($result === FALSE) {
+               if ($result === NULL) {
                        $this->fail('Frontend Response is empty');
                }