PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Kamil   PHP REST Client Framework Control   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP REST Client Framework Control
Testing and validating REST services
Author: By
Last change:
Date: 6 years ago
Size: 3,875 bytes
 

Contents

Class file image Download

RestControl

About RestControl(Twitter)

RestControl is modern and powerful framework for testing REST services. RestControl provides set of tools for describing HTTP requests and responses in expressive and elegant way.

Latest Stable Version Latest Unstable Version License Build status Build Status

Examples

Here is a simple example of how to send a GET request and validate json response:

 /
  * @test(
  *     title="Example test",
  *     description="Example test description",
  *     tags="find user"
  * )
  */
 public function exampleFindUser()
 {
    return send()->get('https://jsonplaceholder.typicode.com/users/1')
                 ->expectedResponse()
                 ->httpStatusOk()
                 ->json()
                 ->jsonPath('$.address.street', endsWith('Light'));
 }

Features/Helpers

  • Easily sending HTTP Requests, variety of http methods like post, get, put, delete, head, patch, purge, options, trace, connect
  • forms
  • request headers
  • basic HTTP authentication
  • oAuth && oAuth2 authentication(in progress)
  • JSON response validation
  • JSON Path body validation
  • easily JSON body items and collection of items validation
  • sets of http response code helpers like httpStatusOk, httpBadGateway etc.
  • easily to use expression language - iteration over body items - values comparing (e.g. equalsTo, lessThan) - string validation (e.g. startsWith, endsWith) - custom validation via closure
  • annotations describing tests
  • measuring response time and tests statistics
  • XML validation(in progress)
  • easily system of tests environments
  • json, html reporting system(in progress)
  • cookies(in progress)
  • proxy, ssl support(in progress)
  • command for automatic generation of tests

Quick Start

The best way for quick start is to use RestControl standalone application. You can find it here https://github.com/rest-control/standalone-testing-application. If you want to save yourself the hassle of installing dependencies required for this project on your local machine, you can use Docker containers as an alternative. Note that you will need Docker and Docker Compose in version >= 2.1.

To build and start RestControl standalone application, run following commands:

user@user:~/projects/standalone-testing-application$ make build
user@user:~/projects/standalone-testing-application$ make start

Now, you can use Docker machine and run example tests.

user@user:~/projects/standalone-testing-application$ docker exec -it restcontrol_cli_1 bash
user@machineid:/app# php vendor/bin/rest-control run

Contributing

Thank you if you considering contributing to RestControl! The contribution guide will be available soon. Start watching this project to get regular updates.

Project roadmap

All planned releases you can find here: https://github.com/rest-control/rest-control/milestones.

Learning RestControl

RestControl documentation is under construction, please be patient. Current documentation files are available on https://rest-control.github.io/