Introduction

RestControl is using class methods as test cases. Each class can contain several test cases. Each test case needs to return either \RestControl\TestCase\Request or \RestControl\TestCase\Response. For greater ease of use your test class might inherit from RestControl base class \RestControl\TestCase\AbstractTestCase that includes both methods mentioned earlier.

Example usage:

namespace Tests;

use RestControl\TestCase\AbstractTestCase;

class MyTests extends AbstractTestCase
{
    public function firstEndpointTest()
    {
        return send();
    }

    public function secondEndpointTest()
    {
        return send();
    }
}

Project folder structure should correspond to configuration specified in rest-control.yml file, as RestControl is using this information to load tests.

Annotations

RestControl uses annotations to describe a specific test case. Allows setting, e.g. test title, longer description, test tags.

Example usage:

namespace Tests;

use RestControl\TestCase\AbstractTestCase;

class MyTests extends AbstractTestCase
{
    /**
     * @test(
     *     title="First Endpoint test",
     *     description="First endpoint test long description",
     *     tags="first endpoint test"
     * )
     */
    public function testFirstEndpointTest()
    {
        //..
    }

    /**
     * @test(
     *     title="Second Endpoint test",
     *     description="Second endpoint test long description",
     *     tags="second endpoint test"
     * )
     */
    public function testSecondEndpointTest()
    {
        //..
    }
}