This is an old revision of the document!
PHPT roundup talk
This wikipage contains all extra information for the talk prepared for phptestfest 2009. They heavily rely on content written by other people before. Every resource of the talk, even the slides (in different formats) will be in this place. Other testfesters can use and modify this talk to save precious time.
How is PHP Tested
What is a PHPT
A phpt test is a little script used by the php internal and quality assurance teams to test PHP's functionality. It can be used with new releases to make sure they can do all the things that previous releases can, or to help find bugs in current releases. By writing phpt tests you are helping to make PHP more stable.
Requirements
All that is really needed to write a phpt test is
- a basic understanding of the PHP language
- a text editor
- a way to execute the code
- the make commando available
- bison or flex
Get the source
First things first. For all the testfest fun you need to checkout all the sourcecode for PP 5.3
CVS Configuration
For easy handling of the PHP CVS repo. you can setup some variables in you ./~cvsrc file
cvs -z3 update -d -P checkout -P diff -u
Login to CVS
cvs -d :pserver:cvsread@cvs.php.net:/repository login
- Username: cvsread
- password: phpfi
Checkout
Testfest 2009 is all about the PHP 5.3 release. So checkout the right part of the source tree
cvs -d :pserver:cvsread@cvs.php.net:/repository checkout -r PHP_5_3 php5
Now you have all the sourcecode you neeed to start testing in a folder php5.
Compile and run the tests
Running phpt tests is part of the build process.
Start by preparing the configuration of your build by executing the buildconf
./buildconf
Everything is now set up to write PHPT tests or just explore and hack the PHP source code. If you want to configure and compile PHP, use the following commands:
./configure && make && make test
If you also want to enable code coverage results, use the following command:
./configure --enable-gcov && make && make lcov
The build will run for a while, strongly depending on the performance of your computer.
While files are compiled the output will look like this:
/bin/sh /home/sschuermann/php/php5/libtool --silent --preserve-dup-deps --mode=compile cc -Isapi/cgi/ -I/home/sschuermann/php/php5/sapi/cgi/ .....
As soon as the main test process starts output will look like this:
PASS Test array_combine() function : usage variations - different arrays(Bug#43424) [ext/standard/tests/array/array_combine_variation3.phpt]
When there are one or more failing tests a special output is presented to you.
===================================================================== EXPECTED FAILED TEST SUMMARY --------------------------------------------------------------------- ob_start(): Ensure unerasable buffer cannot be flushed by ob_flush(). [tests/output/ob_start_basic_unerasable_005.phpt] Inconsistencies when accessing protected members [Zend/tests/access_modifiers_008.phpt] Inconsistencies when accessing protected members - 2 [Zend/tests/access_modifiers_009.phpt] Bug #42718 (unsafe_raw filter not applied when configured as default filter) [ext/filter/tests/bug42718.phpt] SimpleXML: array casting bug [ext/simplexml/tests/034.phpt] ===================================================================== You may have found a problem in PHP. We would like to send this report automatically to the PHP QA team, to give us a better understanding of how the test cases are doing. If you don't want to send it immediately, you can choose "s" to save the report to a file that you can send us later. Do you want to send this report now? [Yns]:
Execute tests
All Tests
Single Test
Write Tests...
... for Coverage
... to find bugs
Naming conventions
Resources
phpt Test Basics http://qa.php.net/write-test.php
Guide to anonymous CVS checkout http://de3.php.net/anoncvs.php
Zoes 2008 Testfest Talk http://www.phplondon.org/conference/2008/media/docs/TestOrDie_Zoe_Slattery.pdf
Sebastian Bergmanns Slides 2008 http://www.slideshare.net/sebastian_bergmann/php-testfest-cologne?src=embed
Requirements for tests on mac http://felix.phpbelgium.be/blog/2008/05/22/writing-phpt-tests-on-your-mac/