Skip to content

zoek1/php-testing-tools

 
 

Repository files navigation

PHP Testing tools

Build Status SensioLabsInsight

This is a set of examples using some of the coolest tools for testing and design in PHP.

  • Behat
  • phpspec
  • PHPUnit
  • Mockery
  • Alice
  • Codeception

It was used for a testing class here. You can follow the progress of the examples with each commit. You can also check the slides here.

Installation

In order to work with this demo you will need to install PHP 5.6, SQLite, npm and Composer. If you have everything installed just execute the following command:

$ make install

Usage

Tests

You can run all the tests with this command:

$ bin/robo test

Web

You can run the Web application with:

$ bin/robo run

You can now browse to http://localhost:8000/index_dev.php/

Console

You can run the console application with:

$ bin/robo console <command> <arg1> ... <argN>

It implements the Transfer Funds feature in the ewallet:transfer command. The following command would transfer $5.00 MXN from the member with ID 'ABC' to the member with ID 'LMN'.

$ bin/robo console ewallet:transfer ABC LMN 5

Environments

The application can be run in two environments dev and prod. Currently it defaults to the dev environment.

You don't need to change anything if you're not curious on how to run it in the "production environment". However, if you are, you will need to set some environment variables.

DOCTRINE_DEV_MODE=0
TWIG_DEBUG=0
SMTP_HOST=127.0.0.1 # It uses mailcatcher for emails by defaultq
SMTP_PORT=1025      # You'll need to change these to try it in a real SMTP server

These values need to be in the .env file for the console application.

If you're running an Apache virtual host, you can add those values in its configuration file.

<VirtualHost *:8080>
  ServerName ewallet.dev
  DocumentRoot "/path/to/src/EwalletApplication/Bridges/Slim/Resources/web"
  SetEnv DOCTRINE_DEV_MODE 0
  SetEnv TWIG_DEBUG 0
  SetEnv SMTP_HOST 127.0.0.1
  SetEnv SMTP_PORT 1025
  <Directory "/path/to/src/EwalletApplication/Bridges/Slim/Resources/web">
   Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

About

Code examples with several PHP testing tools

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 90.7%
  • HTML 9.1%
  • Other 0.2%