开发者

phpunit.xml Does not seem to be working

I have bee trying to get this test to run

require_once 'PHPUnit/Framework.php';
require_once('../config/config.php');
require_once('../classes/division.class.php');

class DivisionTest extends PHPUnit_Framework_TestCase
{
    public function Divisiontest()
    { 
     $division = new division();
     try{
      $division->createDivisionDetails();
     }catch (CustomException $e) {
   return;
  }
     $this->fail('An expected exception has not been raised.');
    }

}

on this Command

phpunit --configuration=phpunit.xml division.test.php

but keep geting the error message

PHP Notice:  Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 13

Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 13
PHP Notice:  Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 26

Notice: Undefined index: HTTP_HOST in /home/workspace/people_scope/config/config.php on line 26
PHP Warning:  require_once(/people_scope/config/standard.inc.php): failed to open stream: No such file or directory in /home/workspace/people_scope/config/config.php on line 46

Warning: require_once(/people_scope/config/standard.inc.php): failed to open stream: No such file or directory in /home/workspace/people_scope/config/config.php on line 46
PHP Fatal error:  require_once(): Failed opening required '/people_scope/config/standard.inc.php' (include_path='/usr/bin:.:/usr/share/php:/usr/share/pear:/people_scope/assets/PEAR/:/people_scope/classes/base/') in /home/workspace/people_scope/config/config.php on line 46

Fatal error: require_once(): Failed opening required '/people_scope/config/standard.inc.php' (include_path='/usr/bin:.:/usr开发者_运维问答/share/php:/usr/share/pear:/people_scope/assets/PEAR/:/people_scope/classes/base/') in /home/workspace/people_scope/config/config.php on line 46

I am using a phpunit.xml to try to set the $_SERVER['HTTP_HOST'] but seem like it is not working at all

<?xml version="1.0" encoding="utf-8" ?>

<phpunit>
        <php>
                <server name="HTTP_HOST" value="DEV"/>
        </php>
</phpunit>

Everything I have read seem to say this should work


The xml looks fine as far as i can see it. Two suggestions:

class DivisionTest extends PHPUnit_Framework_TestCase
{
    public function Divisiontest()

i'd change the function name to testDivision() so phpunit picks it up as a real test (the code gets execution because its named like the class (a.k.a. php 4 style constructor) but thats not really optimal)

If that doesn't fix your problem: Does it work when you put

$_SERVER['HTTP_HOST'] = "DEV";

before the

$division = new division();

statement ? Just to make sure the error is that the xml file isn't read and doesn't hide somewhere else

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜