Jump to content

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.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.