[PHPUnit] Testing output

Test contains not only unit test, integration test, but also the output of screen, including files etc.

For example, with the function exceptOutputString, we can test the string output by echo or print.

class OutputTest extends PHPUnit_Framework_TestCase
    public function testExpectFooActualFoo()
        $this->outputString();    // Call my local function
        $this->expectOutputString('Hello world!');    // Comparaison

    // local function 
    private function outputString()
        echo "Hello world!";

Ref. Methods for output testing


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s