-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notice: Undefined index: _SERVER in PHPUnit/Util/Filter.php on line 69 #705
Comments
Are you unsetting |
I did text search of all usages of $GLOBALS['_SERVER'] and dont found anything. var_dump($GLOBALS['_SERVER']); Giving me NULL also |
I noticed ValerchikV runs Kohana. I have the same problem trying to unittest kohana. |
Think this can be closed here. Kohana messes up the $GLOBALS array in CoreTest.php:110
|
Sorry comment on this unrelated issue, but I have a quick fix for anyone in the thread. Just disable the core Kohana tests from the unittest config with |
This thread turned up at number 1 search result when I searched for Undefined index: _SERVER, which is what I was experiencing while writing some tests earlier. I wanted to clean up the modifications to _SERVER that my tests made in order to test the code I'm writing which relies upon indices such as REQUEST_URI, REQUEST_METHOD and SERVER_PROTOCOL, for instance. In the tearDown method, I simply Here's how I am currently getting round this issue, in case it helps others who are searching for the same thing: <?php
class Example_Test extends \PHPUnit_Framework_TestCase {
private $_SERVER;
public function setUp() {
// Store a copy of the superglobal on the testcase object.
$this->_SERVER = $_SERVER;
// ...
}
public function tearDown() {
// ...
// Restore the original superglobal its pre-test state.
$_SERVER = $this->_SERVER;
} |
By default, PHPUnit runs your tests in a way where changes to global and super-global variables ($GLOBALS, $_ENV, $_POST, $_GET, $_COOKIE, $_SERVER, $_FILES, $_REQUEST) do not affect other tests. See http://phpunit.de/manual/current/en/fixtures.html#fixtures.global-state for details. |
I run tests and got this error:
Notice: Undefined index: _SERVER in /usr/share/pear/PHPUnit/Util/Filter.php on line 69
Full output dump:
phpunit --bootstrap=modules/unittest/bootstrap.php modules/unittest/tests.php
PHPUnit 3.7.8 by Sebastian Bergmann.
.............................S..........SSSSSSSSSSSSSSSSSSSSS 61 / 1299 ( 4%)
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 122 / 1299 ( 9%)
SSSS......................................................... 183 / 1299 ( 14%)
............................................................. 244 / 1299 ( 18%)
.SSSSSS............SS........................................ 305 / 1299 ( 23%)
............................................................. 366 / 1299 ( 28%)
..............................................F.............S 427 / 1299 ( 32%)
.SS.......................................................... 488 / 1299 ( 37%)
............................................................. 549 / 1299 ( 42%)
............................................................. 610 / 1299 ( 46%)
............................................................. 671 / 1299 ( 51%)
.........................S.................................SS 732 / 1299 ( 56%)
SSS..I....................................................... 793 / 1299 ( 61%)
............................................................. 854 / 1299 ( 65%)
.....................................F....................... 915 / 1299 ( 70%)
............................................................. 976 / 1299 ( 75%)
............................................................. 1037 / 1299 ( 79%)
............................................................. 1098 / 1299 ( 84%)
............................................................. 1159 / 1299 ( 89%)
............................................................. 1220 / 1299 ( 93%)
............................................................. 1281 / 1299 ( 98%)
..................
Time: 34 seconds, Memory: 22.50Mb
There were 2 failures:
Notice: Undefined index: _SERVER in /usr/share/pear/PHPUnit/Util/Filter.php on line 69
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'string(10) "foobar±10"'
+'string(0) ""'
/mnt/hgfs/ipnew/system/tests/kohana/DebugTest.php:124
/mnt/hgfs/ipnew/modules/unittest/classes/Kohana/Unittest/TestSuite.php:51
/usr/bin/phpunit:46
Notice: Undefined index: _SERVER in /usr/share/pear/PHPUnit/Util/Filter.php on line 69
Failed asserting that false is identical to ''.
/mnt/hgfs/ipnew/system/tests/kohana/UTF8Test.php:41
/mnt/hgfs/ipnew/modules/unittest/classes/Kohana/Unittest/TestSuite.php:51
/usr/bin/phpunit:46
FAILURES!
Tests: 1299, Assertions: 2749, Failures: 2, Incomplete: 1, Skipped: 104.
The text was updated successfully, but these errors were encountered: