PHP TestFest 2017

Deur!

https://github.com/phpcommunity/phptestfest-php-src/pulls?q=is%3Apr+is%3Aopen+label%3A%22UG%3A+PHP-WVL%22

PHP Tests?

Black-box testing

run-tests.php

https://github.com/php/php-src/blob/master/run-tests.php

*.phpt

  • Normal: ./tests
  • Extensions: ./ext/{name}/tests
  • Zend: ./Zend/tests
  • SAPI: ./sapi/{name}/tests

-- TEST --
echo - hello
-- FILE --
<?php
echo '#phptestfest';
?>
-- EXPECT --
#phptestfest
    					

http://qa.php.net/write-test.php

Getting PHP

  • git clone git@github.com:php/php-src.git
  • ./buildconf
  • ./configure --enable-maintainer-zts --enable-debug --enable-cli
  • make -j9
  • sapi/cli/php --version

Running tests

  • make test TESTS=tests/basic/001.phpt

Debugging

  • *.out
  • *.exp
  • *.diff
  • *.log
  • *.php
  • *.sh

Naming Conventions

  • {function-name}_basic.phpt
  • {function-name}_error.phpt
  • {function-name}_variation.phpt
  • {ext-name}{number}.phpt
  • bug{bug-id}.phpt

http://qa.php.net/write-test.php#naming-conventions

What to test?

Proving bugs

Reading Source

  • PHP_FUNCTION
  • Find exceptions
  • etc...

Docker

  • https://github.com/herdphp/docker-phpqa
  • https://github.com/PHPTestFestBrasil/phptt

Credits


-- TEST --
echo - hello
-- CREDITS --
Jachim Coudenys <jachimcoudenys@gmail.com>
User Group: PHP-WVL & PHPGent #PHPTestFest
-- FILE --
<?php
echo '#phptestfest';
?>
-- EXPECT --
#phptestfest
    					

Contributing

  • Github account
  • Fork https://github.com/phpcommunity/phptestfest-php-src
  • git checkout -b branch-for-my-test phptestfest-2017-master
  • 1 pull request, 1 phpt file
  • Pull request description + User Group: PHP-WVL & PHPGent #PHPTestFest

Final notes

Resources