Docker tools to easily create and run tests for PHP-SRC. The intent of this library is to help anyone to create PHPT tests for PHP language engine and its core extensions.
-
You must have the latest version of docker installed on your machine.
-
Run our installer:
curl -s https://raw.githubusercontent.com/herdphp/docker-phpqa/master/bin/installer.sh | bash
- Start PHPTesting!!!
The generate-phpt
tool wrapped by docker-phpqa
is a developer tool that lives inside of PHP-SRC repository.
It is meant to bootstrap PHPT creation, it has a very simple usage.
Usage:
phpqa generate [PHPT_DIR] -f <function_name> |-c <class_name> -m <method_name> -b|e|v [-s skipif:ini:clean:done] [-k win|notwin|64b|not64b] [-x ext]
Where:
-f function_name ................. Name of PHP function, eg cos
-c class name .................... Name of class, eg DOMDocument
-m method name ................... Name of method, eg createAttribute
-b ............................... Generate basic tests
-e ............................... Generate error tests
-v ............................... Generate variation tests
-s sections....................... Create optional sections, colon separated list
-k skipif key..................... Skipif option, only used if -s skipif is used.
-x extension...................... Skipif option, specify extension to check for
-h ............................... Print this message
If you want to see the help you can just use:
phpqa generate -h
If you want to create a basic PHPT test for the ucfirst
function:
phpqa generate -f ucfirst -b
This will create a template PHPT file for the function ucfirst
inside of your PHPT default folder. If you want to choose
the PHPT directory where the files are generated you can pass it as the first argument of the generate command:
phpqa generate /path/to/phpt/dir -f ucfirst -b
- Write a PHPT test in any folder;
- Run the
phpqa
command passing as arguments the filepath (relative or full) and the PHP version to run the test (master, 72, 71, 70, 56, 55, all):
# without a version the test will run against the latest PHP stable version (PHP 7.1) codebase
phpqa run phpt/examples/closure_061.phpt
# with a version the test will run against the specified version
phpqa run phpt/examples/closure_061.phpt 56
# if you want you can pass `all` as second argument and the test will run against all available versions
phpqa run phpt/examples/closure_061.phpt all
To update your docker-phpqa
tool and images just call the update command:
phpqa update
docker-phpqa
has a small set of commands and a quick way to get help about its usage is either type the phpqa
command without any arguments or calling phpqa help
command.
PHP 5.5, 5.6, 7.0, 7.1, 7.2 (RC4) and the master branch from PHP-SRC repository are fully available and supported;
If you notice any bug or typo or if you want to improve this tool, please feel free to create an issue and/or open a pull request.
This repository intent to facilitate participation and contribution in the PHP Test Festival. More information about it:
- QA PHP TestFest
- Some blog posts from Stefan Koopmanschap
- Philip Norton's post on the UK PHP TestFest 2010
- PHPBelgium slides for preparing for TestFest 2009
- PHPTestFestBrasil
- Sammy's php|tek 2017 talk
- Discussion at PHP User Groups list
- Testing with .php files on PHP Internals Book
- Playlist in how compile PHP and start writing tests - by Sammy Kaye
- PHPDublin Meetup: PHP test fest - by Barry O Sullivan
- The tests in the examples folder are part of the PHP interpreter codebase distributed under PHP License 3.01.
- The Dockerfile in this repository is inspired and based on the official Dockerfile template and images present in the
PHP Docker Hub repository also available at the Docker Library Github repository. The
scripts
docker-php-*
are also from the same repository. These source code is distributed under MIT license.
Copyright (c) 2017 Bruno Ricardo Siqueira, Joao Paulo Vendramini Martins
This work is licensed under the terms of the MIT license.