Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/razonyang/swoole-unit
The unit test helpers for Swoole
https://github.com/razonyang/swoole-unit
swoole unit-test unit-testing
Last synced: 28 days ago
JSON representation
The unit test helpers for Swoole
- Host: GitHub
- URL: https://github.com/razonyang/swoole-unit
- Owner: razonyang
- License: mit
- Created: 2022-09-17T10:57:38.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-24T08:26:29.000Z (about 2 years ago)
- Last Synced: 2024-04-14T02:23:39.908Z (7 months ago)
- Topics: swoole, unit-test, unit-testing
- Language: PHP
- Homepage:
- Size: 12.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Swoole Unit Test Helpers
[![Latest Stable Version](https://poser.pugx.org/razonyang/swoole-unit/v/stable.png)](https://packagist.org/packages/razonyang/swoole-unit)
[![Total Downloads](https://poser.pugx.org/razonyang/swoole-unit/downloads.png)](https://packagist.org/packages/razonyang/swoole-unit)
[![Build Status](https://github.com/razonyang/swoole-unit/actions/workflows/build.yml/badge.svg)](https://github.com/razonyang/swoole-unit/actions)
[![Coverage Status](https://coveralls.io/repos/github/razonyang/swoole-unit/badge.svg?branch=main)](https://coveralls.io/github/razonyang/swoole-unit?branch=main)
[![StyleCI](https://github.styleci.io/repos/537780358/shield?branch=main)](https://github.styleci.io/repos/537780358?branch=main)## Installation
```bash
composer require razonyang/swoole-unit --prefer-dist --dev
```## Helpers
### Request Builder
The `RequestBuilder` generates `Swoole\Http\Request` instances.
```php
protocol('HTTP/1.1')
->host('localhost')
->contentType('application/x-www-form-urlencoded')
->contentLength(8)
->headers([
'X-Foo' => [
'Bar',
],
])
->body('hello=world')
->create();
```The `RequestBuilder` supports chaining calls until `create`.
#### Form Data
```php
$data = [
'hello' => 'world',
];
$request = RequestBuilder::post('/users')
->formData($data)
->create()
```#### Multipart Form Data
```php
$data = [
'hello' => 'world',
];
$files = [
'avatar' => __DIR__ . DIRECTORY_SEPARATOR . 'avatar.jpg',
];
$request = RequestBuilder::post('/users')
->multipart($data, $files)
->create()
```#### JSON Data
```php
$data = [
'hello' => 'world',
];
$request = RequestBuilder::post('/users')
->jsonData($data)
->create()
```