Tutorials

Using docker-phpqa

Colorful graffiti art

Photo by Lucas Gallone.

How to get it?

  1. You will need to have Docker installed on your machine.

  2. Run our installer:

1
curl -s https://raw.githubusercontent.com/herdphp/docker-phpqa/master/bin/installer.sh | bash

Start PHPTesting!!!

How to use it?

To generate new PHPT test files

The generate-phpt tool wrapped by docker-phpqa is a developer tool that lives inside of PHP-SRC repository. Its usage is very simple and the intent is to bootstrap PHPT creation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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:

1
phpqa generate -h

If you want to create a basic PHPT test for the ucfirst function:

1
phpqa generate -f ucfirst -b

This will create a template PHPT file for the function ucfirst inside of the phpt/ directory.

If you want to override the destination directory where the files are generated you can pass it as the first argument of the generate command:

1
phpqa generate /path/to/phpt/dir -f ucfirst -b

To run your created tests against multiple PHP versions

  1. Write a PHPT test in any folder;
  2. Run the phpqa command passing as arguments the filepath (relative or full) and the PHP version to run the test (72, 71, 70, 56, 55):
1
2
3
4
5
6
# without a version the test will run against 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 versions
phpqa run phpt/examples/closure_061.phpt all

PHP versions available

PHP 5.5, 5.6, 7.0, 7.1 and 7.2 (Beta1) are fully available and supported;

Contributing

If you notice any bug or typo, please feel free to create an issue and/or open a pull request with the fix.