diff --git a/tests/unit/suites/libraries/cms/application/JApplicationAdministratorTest.php b/tests/unit/suites/libraries/cms/application/JApplicationAdministratorTest.php index 25c86bae6595b..3003e864ea759 100644 --- a/tests/unit/suites/libraries/cms/application/JApplicationAdministratorTest.php +++ b/tests/unit/suites/libraries/cms/application/JApplicationAdministratorTest.php @@ -48,6 +48,14 @@ class JApplicationAdministratorTest extends TestCaseDatabase */ protected $class; + /** + * Backup of the SERVER superglobal + * + * @var array + * @since 3.4 + */ + protected $backupServer; + /** * Data for fetchConfigurationData method. * @@ -75,6 +83,14 @@ public function setUp() { parent::setUp(); + $this->saveFactoryState(); + + JFactory::$document = $this->getMockDocument(); + JFactory::$language = $this->getMockLanguage(); + JFactory::$session = $this->getMockSession(); + + $this->backupServer = $_SERVER; + $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['HTTP_USER_AGENT'] = self::TEST_USER_AGENT; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; @@ -87,12 +103,6 @@ public function setUp() // Get a new JApplicationAdministrator instance. $this->class = new JApplicationAdministrator(null, $config); TestReflection::setValue('JApplicationCms', 'instances', array('administrator' => $this->class)); - - // We are coupled to Document and Language in JFactory. - $this->saveFactoryState(); - - JFactory::$document = $this->getMockDocument(); - JFactory::$language = $this->getMockLanguage(); } /** @@ -109,6 +119,8 @@ protected function tearDown() TestReflection::setValue('JEventDispatcher', 'instance', null); TestReflection::setValue('JApplicationCms', 'instances', array()); + $_SERVER = $this->backupServer; + $this->restoreFactoryState(); parent::tearDown(); diff --git a/tests/unit/suites/libraries/cms/application/JApplicationCmsTest.php b/tests/unit/suites/libraries/cms/application/JApplicationCmsTest.php index 0edc5f6d7ebd8..c1d3f8cad4bd5 100644 --- a/tests/unit/suites/libraries/cms/application/JApplicationCmsTest.php +++ b/tests/unit/suites/libraries/cms/application/JApplicationCmsTest.php @@ -50,6 +50,14 @@ class JApplicationCmsTest extends TestCaseDatabase */ protected $class; + /** + * Backup of the SERVER superglobal + * + * @var array + * @since 3.4 + */ + protected $backupServer; + /** * Data for fetchConfigurationData method. * @@ -77,6 +85,14 @@ public function setUp() { parent::setUp(); + $this->saveFactoryState(); + + JFactory::$document = $this->getMockDocument(); + JFactory::$language = $this->getMockLanguage(); + JFactory::$session = $this->getMockSession(); + + $this->backupServer = $_SERVER; + $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['HTTP_USER_AGENT'] = self::TEST_USER_AGENT; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; @@ -88,12 +104,6 @@ public function setUp() // Get a new JApplicationCmsInspector instance. $this->class = new JApplicationCmsInspector(null, $config); - - // We are coupled to Document and Language in JFactory. - $this->saveFactoryState(); - - JFactory::$document = $this->getMockDocument(); - JFactory::$language = $this->getMockLanguage(); } /** @@ -113,6 +123,8 @@ protected function tearDown() JApplicationCmsInspector::$headersSent = false; JApplicationCmsInspector::$connectionAlive = true; + $_SERVER = $this->backupServer; + $this->restoreFactoryState(); parent::tearDown(); diff --git a/tests/unit/suites/libraries/cms/application/JApplicationSiteTest.php b/tests/unit/suites/libraries/cms/application/JApplicationSiteTest.php index 42aaa66713921..09496c3f30a9c 100644 --- a/tests/unit/suites/libraries/cms/application/JApplicationSiteTest.php +++ b/tests/unit/suites/libraries/cms/application/JApplicationSiteTest.php @@ -48,6 +48,14 @@ class JApplicationSiteTest extends TestCaseDatabase */ protected $class; + /** + * Backup of the SERVER superglobal + * + * @var array + * @since 3.4 + */ + protected $backupServer; + /** * Data for fetchConfigurationData method. * @@ -75,6 +83,14 @@ public function setUp() { parent::setUp(); + $this->saveFactoryState(); + + JFactory::$document = $this->getMockDocument(); + JFactory::$language = $this->getMockLanguage(); + JFactory::$session = $this->getMockSession(); + + $this->backupServer = $_SERVER; + $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['HTTP_USER_AGENT'] = self::TEST_USER_AGENT; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; @@ -87,12 +103,6 @@ public function setUp() // Get a new JApplicationSite instance. $this->class = new JApplicationSite(null, $config); TestReflection::setValue('JApplicationCms', 'instances', array('site' => $this->class)); - - // We are coupled to Document and Language in JFactory. - $this->saveFactoryState(); - - JFactory::$document = $this->getMockDocument(); - //JFactory::$language = $this->getMockLanguage(); } /** @@ -109,6 +119,8 @@ protected function tearDown() TestReflection::setValue('JEventDispatcher', 'instance', null); TestReflection::setValue('JApplicationCms', 'instances', array()); + $_SERVER = $this->backupServer; + $this->restoreFactoryState(); parent::tearDown(); diff --git a/tests/unit/suites/libraries/joomla/application/JApplicationBaseTest.php b/tests/unit/suites/libraries/joomla/application/JApplicationBaseTest.php index 2a0546024ea4b..fc835035d7814 100644 --- a/tests/unit/suites/libraries/joomla/application/JApplicationBaseTest.php +++ b/tests/unit/suites/libraries/joomla/application/JApplicationBaseTest.php @@ -37,6 +37,8 @@ protected function setUp() { parent::setUp(); + $this->saveFactoryState(); + // Create the class object to be tested. $this->class = new JApplicationBaseInspector; } @@ -54,6 +56,8 @@ protected function tearDown() // Reset the dispatcher instance. TestReflection::setValue('JEventDispatcher', 'instance', null); + $this->restoreFactoryState(); + parent::tearDown(); } diff --git a/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php b/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php index 533740de8eb9f..9788f22c0a3cc 100644 --- a/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php +++ b/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php @@ -50,6 +50,14 @@ class JApplicationWebTest extends TestCase */ protected $class; + /** + * Backup of the SERVER superglobal + * + * @var array + * @since 3.4 + */ + protected $backupServer; + /** * Data for detectRequestUri method. * @@ -95,6 +103,13 @@ public function setUp() { parent::setUp(); + $this->saveFactoryState(); + + JFactory::$document = $this->getMockDocument(); + JFactory::$language = $this->getMockLanguage(); + + $this->backupServer = $_SERVER; + $_SERVER['HTTP_HOST'] = self::TEST_HTTP_HOST; $_SERVER['HTTP_USER_AGENT'] = self::TEST_USER_AGENT; $_SERVER['REQUEST_URI'] = self::TEST_REQUEST_URI; @@ -102,12 +117,6 @@ public function setUp() // Get a new JApplicationWebInspector instance. $this->class = new JApplicationWebInspector; - - // We are only coupled to Document and Language in JFactory. - $this->saveFactoryState(); - - JFactory::$document = $this->getMockDocument(); - JFactory::$language = $this->getMockLanguage(); } /** @@ -120,8 +129,9 @@ public function setUp() */ protected function tearDown() { - // Reset the dispatcher instance. + // Reset the dispatcher and session instances. TestReflection::setValue('JEventDispatcher', 'instance', null); + TestReflection::setValue('JSession', 'instance', null); // Reset some web inspector static settings. JApplicationWebInspector::$headersSent = false;