how to write phpt tests
TRANSCRIPT
![Page 1: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/1.jpg)
Writing PHP TestsPHPNW TestFest 2009
Wednesday, 27 May 2009
![Page 2: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/2.jpg)
Goals
Increase test coverage in PHP
Win an elePHPant
Have Fun
Beat London
Cheat if we have to
Wednesday, 27 May 2009
![Page 3: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/3.jpg)
Preparation
Grab gcc, autotools, flex-old, bison
Make your directory ~/testfest
Wednesday, 27 May 2009
![Page 4: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/4.jpg)
Snapshot
CVS Checkout
Snapshot (snaps.php.net)
Windows Snapshot (windows.php.net/snapshots/)
Wednesday, 27 May 2009
![Page 5: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/5.jpg)
Windows
run-tests.php
PHP 5.3 http://short.ie/yui3db
PHP 5.2 http://short.ie/zm5vwb
Relax
Wednesday, 27 May 2009
![Page 6: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/6.jpg)
Building
cd ~/testfest
./configure --disable-all --enable-spl
make / make -j3
Wednesday, 27 May 2009
![Page 7: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/7.jpg)
Checking it worked
sapi/cli/php -v
make test (takes a while)
Submit a report
Wednesday, 27 May 2009
![Page 8: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/8.jpg)
Running Selective Tests
run run-tests.php manually
set TEST_PHP_EXECUTABLE
Wednesday, 27 May 2009
![Page 9: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/9.jpg)
Demo
Wednesday, 27 May 2009
![Page 10: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/10.jpg)
What makes a phpt?
Small Collection of PHP Scripts
Separated by section markers
TEST, FILE, EXPECT
Wednesday, 27 May 2009
![Page 11: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/11.jpg)
phpt bits--TEST--
Description of the test
--FILE--
Contents is passed to PHP
--EXPECT--
The expected output
Wednesday, 27 May 2009
![Page 12: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/12.jpg)
A simple phpt
Wednesday, 27 May 2009
![Page 13: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/13.jpg)
Other sections
--CREDITS--
--SKIPIF--
--EXPECTF--
Wednesday, 27 May 2009
![Page 14: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/14.jpg)
Sample Test
Wednesday, 27 May 2009
![Page 15: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/15.jpg)
SPL
Standard PHP Library
Solves Common Problems
Data structures, algorithms, iterators
Wednesday, 27 May 2009
![Page 16: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/16.jpg)
SPL Documentation
http://php.net/~helly/
http://uk2.php.net/spl
Wednesday, 27 May 2009
![Page 17: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/17.jpg)
Our Goals
Write a simple basic test
Write a test for SPLFixedArray, SPLDoublyLinkedList
Look at some iterator tests
Wednesday, 27 May 2009
![Page 18: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/18.jpg)
SVN Checkout
SVN Command Line
Tortoise SVN
Versions on OSX
http://testfest.php.net/repos/testfest/NorthWestUG/
Wednesday, 27 May 2009
![Page 19: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/19.jpg)
Run testSVN: http://testfest.php.net/repos/testfest/NorthWestUG/
Linux: export TEST_PHP_EXECUTABLE=/path/to/checkout/sapi/cli/php
Windows: set TEST_PHP_EXECUTABLE=c:\path\to\php.exe
php run-tests.php /path/to/svntestfest/ext/spl/tests
Wednesday, 27 May 2009
![Page 20: How to write PHPT tests](https://reader034.vdocuments.us/reader034/viewer/2022052307/555a00c5d8b42aa8098b4e62/html5/thumbnails/20.jpg)
URLs
http://qa.php.net/phpt_details.php
http://qa.php.net/write-test.php
http://uk.php.net/spl
Wednesday, 27 May 2009