mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-02 14:25:38 +08:00
add ZMRequest support
This commit is contained in:
30
tests/ZM/Utils/ZMRequestTest.php
Normal file
30
tests/ZM/Utils/ZMRequestTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\ZM\Utils;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use ZM\Utils\ZMRequest;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class ZMRequestTest extends TestCase
|
||||
{
|
||||
public function testPost()
|
||||
{
|
||||
$r = ZMRequest::post('http://httpbin.org/post', [], 'niubi=123');
|
||||
$this->assertStringContainsString('123', $r);
|
||||
$r2 = ZMRequest::post('http://httpbin.org/post', ['User-Agent' => 'test'], 'oijoij=ooo', [], false);
|
||||
$this->assertInstanceOf(ResponseInterface::class, $r2);
|
||||
$this->assertStringContainsString('ooo', $r2->getBody()->getContents());
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$r = ZMRequest::get('http://ip.zhamao.xin');
|
||||
$this->assertStringContainsString('114', $r);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user