library bran
A HTTP api testing framework based on phpunit and guzzle
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
基于PHPUnit和Guzzle的Api单元测试工具
安装
执行composer require subtlephp/bran
, (*1)
使用
-
使用Bran\Raven
代替PHPUnit\Framework\TestCase
来创建新的测试类, (*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;
}
}
dev-master
9999999-dev
A HTTP api testing framework based on phpunit and guzzle
Sources
Download
MIT
The Requires
by
Frost Wong
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