Testing sending headers
Posted: Sat May 10, 2008 2:54 pm
I'm attempting to write a test to check a method that should send an image Content-Type header to the user's browser, but I'm running into an exception..
How can I either test the method without getting the exception, or suppress the header being sent (not ideal really..).
My test code:
The imageJpeg() method is what's sending the header. I'm planning on comparing the image data in $image_data to the contents of a file containing what imageJpeg should make, but I haven't got that far yet.
Code: Select all
Exception: All DataStore tests -> C:\xampp\htdocs\pictooer\version1\test/unit/image.test.php -> ImageTest -> testOpenAndOutputImage_JPEG -> Unexpected PHP error [Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\simpletest\reporter.php:43)] severity [E_WARNING] in [C:\xampp\htdocs\pictooer\version1\base\image\image.class.php line 52]My test code:
Code: Select all
public function testOpenAndOutputImage_JPEG() {
$image = new image();
$image->openImage(TEST_BASE.DIRECTORY_SEPARATOR."image.jpg");
$this->assertEqual(get_resource_type($image->image), "gd");
ob_start();
$image->imageJpeg();
$image_data = ob_get_contents();
ob_end_clean();
}