2017 © Pedro Peláez
 

library bran

A HTTP api testing framework based on phpunit and guzzle

image

subtlephp/bran

A HTTP api testing framework based on phpunit and guzzle

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 51 % Grown

The README.md

基于PHPUnit和Guzzle的Api单元测试工具

安装

执行composer require subtlephp/bran, (*1)

使用

  1. 使用Bran\Raven代替PHPUnit\Framework\TestCase来创建新的测试类, (*2)

  2. 示例代码如下:, (*3)

<?php

use Bran\Raven;

class RavenTest extends Raven
{
    protected $clientConfig = [
        'base_uri' => 'http://gank.io',
    ];

    protected $apiConfig = [
        'images' => [
            'pattern' => '/api/data/Android/10/1',
            'method' => 'get',
        ],
    ];

    public function testAssertStatusCode()
    {
        $entity = $this->call('images');

        $entity->assertStatusCode(200)
            ->assertHeader('Content-Type', 'application/json')
            ->assertJsonBodyHas('error')
            ->assertJsonBodyAttributeEquals('error', false);
    }

    public function setUp()
    {
        parent::setUp();
        $this->clientConfig['headers']['Cookie'] = $this->login();
    }

    public function login()
    {
        $entity = $this->call('login');
        return $entity->cookie;
    }
}

The Versions

27/06 2018

dev-master

9999999-dev

A HTTP api testing framework based on phpunit and guzzle

  Sources   Download

MIT

The Requires

 

by Frost Wong

28/07 2017

1.0.1

1.0.1.0

A HTTP api testing framework based on phpunit and guzzle

  Sources   Download

MIT

The Requires

 

by Frost Wong