Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yegor256/phprack

phpRack Integration Testing Framework
https://github.com/yegor256/phprack

integration-testing php testing vagrant

Last synced: 25 days ago
JSON representation

phpRack Integration Testing Framework

Awesome Lists containing this project

README

        

[![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/phprack)](http://www.rultor.com/p/yegor256/phprack)

[![Build Status](https://travis-ci.org/yegor256/phprack.svg?branch=master)](https://travis-ci.org/yegor256/phprack)
[![PDD status](http://www.0pdd.com/svg?name=yegor256/phprack)](http://www.0pdd.com/p?name=yegor256/phprack)
[![Hits-of-Code](https://hitsofcode.com/github/yegor256/phprack)](https://hitsofcode.com/view/github/yegor256/phprack)

Read about phpRack in ​[php|Architect June 2010](http://www.phparch.com/magazine/2010/june/):
"Integration Testing with phpRack Framework".

**phpRack** is a light framework for automation of integration tests. By
integration tests we mean software modules that should be executed in the
production environment, in order to validate that said environment is configured
as expected. For example your product is a web2.0 application which depends on
proper configuration of PHP, Apache, MySQL and availability of YouTube, Flickr
and GoogleMaps API's. Your product is properly tested with unit tests (obviously
you're using stubs for said services and components). When the product is
deployed to the production environment, you want to be sure that the services
you need are configured and available. If they are not — you want to get a
notification about it before your end-users. And you want to get a detailed
notification.

This is when phpRack is mandatory. You shall add phpRack to your project, and
write a number of tests. All these tests will be executed when requested and
will produce a detailed report, both only and by email. It will save you a lot
of time during deployment and later, during maintenance of your product.

## Quick Start

To start using phpRack you should do three operations:

* Upload phpRack library to your server
* Create `phprack.php` file in your `public_html` directory
* Create PHP integration tests in your rack-tests directory

Let's do them one by one:

### Upload phpRack library

Download [ZIP archive](https://github.com/yegor256/phprack/archive/master.zip)
of phpRach and unpack it to `public_html/phpRack` or some other directory on
your production server.

### Create `phprack.php`

You should create `phprack.php` in your project's public directory
(see [full reference](https://github.com/yegor256/phprack/wiki/Bootstrap)), e.g.:

```php
'../rack-tests',
);
// absolute path to the bootstrap script on your server
include '../library/phpRack/bootstrap.php';
```

### Create integration tests

Write integration tests in the directory rack-tests, each one has to extend the
class `PhpRack_Test` (see
[full list of assertions](https://github.com/yegor256/phprack/wiki/Assertions)).
For example, file `MyTest.php`:

```php
assert->php->version
->atLeast('5.2');
}
public function testPhpExtensionsExist()
{
$this->assert->php->extensions
->isLoaded('xsl')
->isLoaded('simplexml')
->isLoaded('fileinfo');
}
}
```

Go to this URL: `http://your-website-url/phprack.php` and enjoy. Try this link
to see what you're going to see on your site:
​[http://www.phprack.com/phprack.php](http://www.phprack.com/phprack.php).

## How to contribute?

First, fork our repository and clone it to your local machine and install
[Vagrant](http://www.vagrantup.com/). Then, run:

> vagrant up

A virtual machine with pre-installed requisites will be ready in a few
minutes. Login to it and go to `/vagrant` directory:

> vagrant ssh

Then, in the virtual machine run:

> phing

All tests should pass. If you see any problems, please submit an
new issue to us.

After you make your changes don't forget to run `phing` again to make
sure you didn't break anything. When ready, submit a pull request.