Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.2

Doc Bug #19735 PHPUnit Tutorial needs significant updating
Submitted: 2012-12-07 17:29 UTC
From: julianharty Assigned:
Status: Open Package: PHPUnit (version Unknown)
PHP Version: 5.3.15 OS: Mac OSX 10.7.5
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 19 + 49 = ?

 
 [2012-12-07 17:29 UTC] julianharty (Julian Harty)
Description: ------------ The tutorial http://pear.php.net/manual/en/package.php.phpunit.intro.php is out of date for the current version of PHPUnit and no longer reflects the current class structures or methods. Here are the main changes I made to get the code to compile and run: replace: require_once 'PHPUnit.php'; with require_once 'PHPUnit/Autoload.php'; class StringTest extends PHPUnit_Framework_TestCase Delete the constructor method in testcase.php. Another useful change is to replace the AssertTrue call in testAdd() with AssertEquals($expected, $result); I cannot find a way to get stringtest.php to run the test suite; the call to PHPUnit::run($suite); fails with: PHP Fatal error: Class 'PHPUnit' not found in /Users/julianharty/sandbox/php/stringtest.php on line 7 I ended up simply calling testcase.php directly e.g. phpunit testcase.php Should we still be able to run a test suite programatically? if so, how? The PHPUnit documentation at http://www.phpunit.de/manual/current/en/organizing- tests.html doesn't provide an example of creating and running a suite of tests in PHP. Instead it describes 2 other ways of running the various tests. Perhaps it'd be worth adding a link to that page to this documentation? (rather than repeating what it says). Test script: --------------- <?php require_once 'testcase.php'; require_once 'PHPUnit/Autoload.php'; $suite = new PHPUnit_Framework_TestSuite("StringTest"); $result = PHPUnit::run($suite); echo $result -> toString(); ?> Expected result: ---------------- I expected the test suite to run the 3 tests in class StringTest (in file testcase.php) Actual result: -------------- PHP Fatal error: Class 'PHPUnit' not found in /Users/julianharty/sandbox/php/stringtest.php on line 7

Comments