Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8252771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:38:43+00:00 2026-06-08T00:38:43+00:00

I have some PHPT tests that are being run in PHPUnit. These tests include

  • 0

I have some PHPT tests that are being run in PHPUnit. These tests include a --CLEAN-- section that handles the deletion of files created during the test. Running the PHPT tests at the command line using pear run-tests works fine, but when they are run though PHPUnit I get the following error:

BORKED –CLEAN– section! output:
X-Powered-By: PHP/5.3.10-1ubuntu3.2
Content-type: text/html

This obviously looks like an HTTP header, but there is no further text, and the actions in the clean section still work as planned. Removing the CLEAN section removes the problem, but I would rather not have the test cleanup done outside of the PHPT file. Any ideas on what these are caused by, and how to get rid of them? They’re not breaking the tests, but they look untidy in the output.

A PHPT test (the POST file data is truncated to protect my employment):

--TEST--
Test file upload
--POST_RAW-- 
Content-Type: multipart/form-data; boundary=---------------------------168481652011378167832091260413
Content-Length: 3510

-----------------------------168481652011378167832091260413
Content-Disposition: form-data; name="code"

te
-----------------------------168481652011378167832091260413
Content-Disposition: form-data; name="name"

test
-----------------------------168481652011378167832091260413
Content-Disposition: form-data; name="file"; filename="test.xml"
Content-Type: text/xml

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

-----------------------------168481652011378167832091260413--
--FILE--
<?php
// Zend/PHPUnit bootstrap
require_once __DIR__ . '/../../../bootstrap.php';

$upload = new My_File_Upload();
var_dump($upload->handleFile(
    'file', 
    APPLICATION_PATH . '/../datafiles/request/',
    'application/xml',
    'testname'
));
var_dump(file_exists(APPLICATION_PATH . '/../datafiles/request/testname.xml'))
?>
--CLEAN--
<?php
    $file = dirname(__FILE__) . '/../../../../datafiles/request/testname.xml';
    if(file_exists($file)) unlink($file);
?>
--EXPECT--
string(12) "testname.xml"
bool(true)

A Zend/PHPUnit test wrapper:

<?php
require_once 'PHPUnit/Extensions/PhptTestCase.php';
/**
 * UploadFileHandleTest
 * 
 * PHPUnit wrapper for the phpt test file UploadFileHandleTest.phpt
 *
 */
class My_File_UploadFileHandle extends PHPUnit_Extensions_PhptTestCase
{
    /**
     * Test file uploads
     * 
     * Test the file uploads using associated .phpt test files. These test have to 
     * be abstracted to the php-cgi environment to permit accurate manipulation of 
     * the $_FILES superglobal. 
     * 
     * @see http://qafoo.com/blog/013_testing_file_uploads_with_php.html
     * 
     * @covers My_File_Upload::handleFile
     * 
     * @return void
     */
    public function __construct() 
    { 
        parent::__construct(__DIR__ . '/UploadFileHandleTest.phpt'); 
    }

    /**
     * Implement missing hasOutput method for PHPUnit
     * 
     * @return boolean 
     */
    public function hasOutput()
    {
        return false;
    }
}

The test suite to trigger the wrappers:

<?php

require_once 'UploadFileExists.php';
require_once 'UploadFileHandle.php';
require_once 'UploadFileHandleNoName.php';
require_once 'UploadFileHandleExceptions.php';

class My_File_UploadTestSuite extends PHPUnit_Framework_TestSuite
{
    public static function suite()
    {
        $suite = new My_File_UploadTestSuite('My_File_UploadFileTests');

        $suite->addTest(new My_File_UploadFileExists());
        $suite->addTest(new My_File_UploadFileHandle());
        $suite->addTest(new My_File_UploadFileHandleNoName());
        $suite->addTest(new My_File_UploadFileHandleExceptions());

        return $suite;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:38:46+00:00Added an answer on June 8, 2026 at 12:38 am

    This is caused by using the PHP CGI executable to run your tests instead of the CLI version. The CGI binary will append the two headers in front of the response, and the PEAR module used for testing will scream bork bork and bloody murder if there’s output provided from the code run in the –CLEAN– section. Point the tests to the correct PHP binary and the issue should go away.

    :~$ echo "" | php5-cgi
    X-Powered-By: PHP/5.3.10-1ubuntu3.2
    Content-type: text/html
    

    Update: This is caused by an error in PEAR_RunTest where it doesn’t reset which interpreter to use when running the –CLEAN– section. I’ve patched PEAR_RunTest to fix the issue and submitted a PR for the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have some audio and video files that users are to download, however depending on
Have some text files that I need to break out the individual words. But
I have some arbitrary pixel data that I want to save as a PNG.
I have some text lines like that : vt_wildshade2^508^508 vt_ailleurs2^1188^1188 ... vt_high2^13652^13652 Is it
I have some code that will change the background color of a specific label
i have some problems with a Query seem IN dosen't work with Group_concat, that
I have some code here that uses bitsets to store many 1 bit values
Have some data in a sybase image type column that I want to use
I have some code that can convert a single color in a template image
I have some intl characters in a field that django is returning as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.