Jump to content

Need Help with Simple Test: Header errror Warnings


chobo2

Recommended Posts

Hi

 

I have a problem I have these 2 files:

 

AbandonSeekRequestProcessorTest.php

AbandonSeekRequestProcessor.php

 

 

AbandonSeekRequestProcessorTest

<?php
ini_set('include_path',ini_get('include_path').';../src/');


require_once('simpletest/unit_tester.php');
require_once('simpletest/reporter.php');

class AbandonSeekRequestProcessorTest  extends UnitTestCase
{    
    public function __construct($testName)
    {
        parent::__construct($testName);
    }

    public static function suite()
    {
        $suite = new PHPUnit_Framework_TestSuite("AbandonSeekRequestProcessorTest");
        return $suite;
    }

    public function testCreateResponse()
    {
        $processor        = new AbandonSeekRequestProcessor();
        $document         = $processor->process();
        $this->assertNotNull($document);
        $this->assertEqual('<?xml version="1.0" encoding="UTF-8"?><requesterror xmlns="http://requesterror.chess.comp2910.cst.bcit.ca"><reason message="abandonseek is not implemented"/></requesterror>', $document); 
    }    
}
$t = new AbandonSeekRequestProcessorTest("abandon seek request processor test");
$t->run(new HtmlReporter());
?>

 

AbandonSeekRequestProcessor.php

<?php
class AbandonSeekRequestProcessor
{

public function __construct()
{
}
public function process()
{

header('Content-Type: text/xml'); 		
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .= '<requesterror xmlns="http://requesterror.chess.comp2910.cst.bcit.ca">';
$xml .= '<reason message="abandonseek not implemented"/>';
$xml .= '</requesterror>';
echo $xml;
}
}
?>

 

So the problem is that the htmlReporter from simpleTest already sends out headers. So if you have headers in your program you get header already sent error:

 

Exception: testResponse -> Unexpected PHP error [Cannot modify header information - headers already sent] severity [E_WARNING] in [G:\website\trunk\mysrc\AbandonSeekRequestProcessor.php line 12]

 

I have tired all the flushing and output buffering and nothing seems to work.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.