Tester - Unit Testing for Php

Its a unit testing library. But phpunit is probably better.

New Features (beta)

  • internet server testing
    • run tests like phptest -host production
    • the host config lists urls to use for get() & post() requests
  • multi-server (localhost) support.
    • The server.dir & server.router configs are the old version which will likely be removed in v0.4
    • the server config defines deliver scripts. Start your servers with phptest server [name of server] & specify the server name when calling get() or post()


composer require taeluf/tester v0.3.x-dev   

or in your composer.json

{"require":{ "taeluf/tester": "v0.3.x-dev"}}  


In a terminal, run phptest or ./vendor/bin/phptest from your project root. (depending whether you installed via bash or composer)

Example Test class:

See the available assertions below

namespace Tlf\Tester\Test\Runner;  
class NestedTest extends \Tlf\Tester {  
    /** called before tests are run */  
    public function prepare(){}  
    /** Test methods must prefix with `test` */  
    public function testAnything(){  

Sample config

This goes at test/config.json. This is a copy of the config file for tests of this lib.

Note: The multi-server support is in beta & may change.

    "bench.threshold": 0.0001,  


  • phptest init to initialize test setups for a new project
  • phptest server to run a localhost php development server, used for testing
    • phptest server NAME to specify a specific server to run (the servers config)
  • phptest -host NAME to run server tests on the configured host url
  • phptest -test TestName to only run the given test. Multiple -test TestName flags can be given
  • phptest -class ClassName where for \Ns\Test\ClassName, you just pass ClassName. accepts multiple -class flags.
  • any other flags found in test/config.json can be passed as to phptest as well.

Available Assertions

I'll properly document assertions after I write the php grammar for my taeluf/php/lexer
See code/Tester/Assertions.php and for other functionality, see the traits in code/Tester/

Alternate Installation

This also requires code-scrawl for development, which is not handled by this script.
copy+paste this into a bash terminal

mkdir -p "$downloadDir"  
cd "$downloadDir"  
git clone https://gitlab.com/taeluf/php/php-tests.git ${command}   
echo "alias ${command}=\"${downloadDir}/${command}/code/phptest\"" >> ~/.bashrc  
chmod ug+x "${downloadDir}/${command}/code/phptest"  
cd "$pwd";  
source ~/.bashrc  
echo "You can now run \`${command}\`"