Question on writing tests

From: Date: Thu, 18 May 2006 01:42:07 +0000
Subject: Question on writing tests
Groups: php.qa 
Request: Send a blank email to php-qa+get-26773@lists.php.net to get a copy of this message
I have a question on writing a test. I am checking the boundaries of a function and at one point expect to get an error... Reading through the documentation for how to write tests (http://qa.php.net/write-test.php), there is only a single note on the subject - <quote> NOTE: If your test intentionally generates a PHP warning message use $php_errormsg variable, which you can then output. This will result in a consistent error message output across all platforms and PHP configurations, preventing your test from failing due inconsistencies in the error message content. </quote> How am I to use that in the EXPECT section of the test? Sample test: --TEST-- basic array_chunk test --FILE-- <?php $input_array = array('a', 'b', 'c', 'd', 'e'); print_r(array_chunk($input_array, 0)); print_r(array_chunk($input_array, 0, true)); print_r(array_chunk($input_array, 1)); print_r(array_chunk($input_array, 1, true)); print_r(array_chunk($input_array, 2)); print_r(array_chunk($input_array, 2, true)); print_r(array_chunk($input_array, 10)); print_r(array_chunk($input_array, 10, true)); ?> --EXPECT-- <br /> <b>Warning</b>: array_chunk() [<a href='function.array-chunk'>function.array-chunk</a>]: Size parameter expected to be greater than 0 in <b>C:\Program Files\Apache Group\Apache2\htdocs\phpt\codetesting.php</b> on line <b>3</b><br /> <br /> <b>Warning</b>: array_chunk() [<a href='function.array-chunk'>function.array-chunk</a>]: Size parameter expected to be greater than 0 in <b>C:\Program Files\Apache Group\Apache2\htdocs\phpt\codetesting.php</b> on line <b>4</b><br /> Array (
    [0] => Array
        (
            [0] => a
        )
    [1] => Array
        (
            [0] => b
        )
    [2] => Array
        (
            [0] => c
        )
    [3] => Array
        (
            [0] => d
        )
    [4] => Array
        (
            [0] => e
        )
) Array (
    [0] => Array
        (
            [0] => a
        )
    [1] => Array
        (
            [1] => b
        )
    [2] => Array
        (
            [2] => c
        )
    [3] => Array
        (
            [3] => d
        )
    [4] => Array
        (
            [4] => e
        )
) Array (
    [0] => Array
        (
            [0] => a
            [1] => b
        )
    [1] => Array
        (
            [0] => c
            [1] => d
        )
    [2] => Array
        (
            [0] => e
        )
) Array (
    [0] => Array
        (
            [0] => a
            [1] => b
        )
    [1] => Array
        (
            [2] => c
            [3] => d
        )
    [2] => Array
        (
            [4] => e
        )
) Array (
    [0] => Array
        (
            [0] => a
            [1] => b
            [2] => c
            [3] => d
            [4] => e
        )
) Array (
    [0] => Array
        (
            [0] => a
            [1] => b
            [2] => c
            [3] => d
            [4] => e
        )
) -- life is a game... so have fun.

« previous php.qa (#26773) next »