On Mon, Dec 8, 2008 at 11:24 PM, Sebastian Hopfe <[EMAIL PROTECTED]> wrote:
> Hi,
>
>
>
> i want to open a discussion about PHPUnit. First of all – I love PHPUnit –
> but i see some problems by testing methodes which providing downwardly
> compatible.
>
>
>
>  The function „file_gets_content" is in old php versions not available. We
> should check this with function_exists() – if these is false we should write
> an alternative function.
>
> This is only an example.

Added in 5.0.0. :P

> But how we could test this with PHPUnit?

On a more serious note...

I'm not sure how to do that with PHPUnit, but you can run PHPT tests
with PHPUnit as well, and in PHPT you can do the following:

--TEST--
This is an example test.
--SKIPIF--
if (!function_exists('file_get_contents')) die('SKIP
file_get_contents() does not exist');
--FILE--
<?php
$resp = @file_get_contents('http://domain.tld');
var_dump($resp);
?>
--EXPECT--
bool(false)


You can run this test with pear run-tests foo.phpt, but also use an
extension which is bundled with PHPUnit to include phpt's in the usual
phpunit AllTests.php run.

For example:
<http://cvs.php.net/viewvc.cgi/pear/HTTP_Session2/tests/AllTests.php?view=markup>

Cheers,
Till

Reply via email to