gralhao/gralhao-test

Pack of tools to make simple Gralhao application tests

1.0.1 2020-08-08 03:13 UTC

This package is auto-updated.

Last update: 2024-05-08 11:37:02 UTC


README

Gralhao logo

gralhao/gralhao-test

Latest Stable Version Minimum PHP Version Build Status Status License

A pack of tools to make simple Gralhao application tests

Index

About

This library extends PHP Unit and all PHP Unit features still available.

Getting Started

Prerequisites

PHP ^7.4, Phalcon ^4.x, Gralhao ^1.x

Usage

Installing

composer require gralhao/gralhao-test

Creating test classes:

class MyClassTest extends \Gralhao\Test\TestCase
{
}

Bootstraping:

public function testReturnAnApplicationInstance(): void
{
    $this->bootstrap()->setConfig([
        'modules' => []
    ]);
    $this->assertInstanceOf(\Phalcon\Mvc\Micro::class, $this->getApp());
}

Testing collections:

public function testReturnAValidRequestResponse(): void
{
    $request = new \Gralhao\Test\Request();
    $request->setMethod('POST')
        ->setPath('/test')
        ->setHeader('key', 'value')
        ->setBody('test');
    $response = $this->dispatch($request);
    $this->assertEquals(200, $response->getStatusCode());
    $this->assertEquals('test', $response->data->body);
    $this->assertEquals('value', $response->data->headers->key);
}

Built Using

Authors

See also the list of contributors who participated in this project.

Acknowledgements