PHP code example of qbhy / hyperf-testing

1. Go to this page and download the library: Download qbhy/hyperf-testing library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

qbhy / hyperf-testing example snippets




namespace HyperfTest\Cases\Dev;

use HyperfTest\HttpTestCase;
use Qbhy\HyperfTesting\Client;
use Qbhy\HyperfTesting\TestResponse;

/**
 * Class DevTest
 * @method TestResponse get($uri, $data = [], $headers = [])
 * @method TestResponse post($uri, $data = [], $headers = [])
 * @method TestResponse delete($uri, $data = [], $headers = [])
 * @method TestResponse put($uri, $data = [], $headers = [])
 * @method TestResponse json($uri, $data = [], $headers = [])
 * @method TestResponse file($uri, $data = [], $headers = [])
 * @package HyperfTest\Cases\Dev
 */
class DevTest extends HttpTestCase
{
    public function __construct($name = null, array $data = [], $dataName = '')
    {
        parent::__construct($name, $data, $dataName);
        $this->client = make(Client::class);
    }

    public function testExample()
    {
        $this->get('/')->assertOk()->assertJsonStructure([
            'data', 'code', 'message',
        ]);
    }
}