subtlephp / bran
A HTTP api testing framework based on phpunit and guzzle
1.0.1
2017-07-28 10:06 UTC
Requires
- guzzlehttp/guzzle: ^6.0
- monolog/monolog: ^1.0
- phpunit/phpunit: ^6.0
- ramsey/uuid: ^3.6
- subtlephp/middlewares: ^0.0.2
This package is not auto-updated.
Last update: 2024-11-10 05:24:43 UTC
README
安装
执行composer require subtlephp/bran
使用
-
使用
Bran\Raven
代替PHPUnit\Framework\TestCase
来创建新的测试类 -
示例代码如下:
<?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; } }