I'm still new to phpUnit and I can't make my (very simple) test work.
<?php
use PHPUnit\Framework\TestCase;
class userTest extends TestCase {
public function testTrue() {
$this->assertTrue(true);
// This line wont work without autloader.php
$user = new User();
}
}
The problem is that I need to load all my classes from autoloader.php:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="inc/autoload.php"></phpunit>
But I'n those classes I have a lot of $SERVER variables, like
$_SERVER['REMOTE_ADDR']
$_SERVER['HTTPS']
$_SERVER['SERVER_NAME']
$_SERVER['DOCUMENT_ROOT']
$_SERVER['REQUEST_URI']
This is the error I get:
Notice: Undefined index: REMOTE_ADDR in /Applications/MAMP/htdocs/sakkadentrainer/classes/App.php on line 674
How can I make those variables work? I would prefer to kind of "fake" them as env.variables from the phpunit.xml file, but I don't know if that's possible.
Thanks for you help!
My Setup: php 7.1.2, phpUnit 6.1.1, macOs Mojave, MAMP