Files
huangjingfen/pro_v3.5.1/vendor/guzzlehttp/guzzle-services/tests/RequestLocation/HeaderLocationTest.php
panchengyong 7acbf45ff7 new files
2026-03-07 22:29:07 +08:00

55 lines
1.7 KiB
PHP
Executable File

<?php
namespace GuzzleHttp\Tests\Command\Guzzle\RequestLocation;
use GuzzleHttp\Command\Command;
use GuzzleHttp\Command\Guzzle\Operation;
use GuzzleHttp\Command\Guzzle\Parameter;
use GuzzleHttp\Command\Guzzle\RequestLocation\HeaderLocation;
use GuzzleHttp\Psr7\Request;
use PHPUnit\Framework\TestCase;
/**
* @covers \GuzzleHttp\Command\Guzzle\RequestLocation\HeaderLocation
* @covers \GuzzleHttp\Command\Guzzle\RequestLocation\AbstractLocation
*/
class HeaderLocationTest extends TestCase
{
/**
* @group RequestLocation
*/
public function testVisitsLocation()
{
$location = new HeaderLocation('header');
$command = new Command('foo', ['foo' => 'bar']);
$request = new Request('POST', 'http://httbin.org');
$param = new Parameter(['name' => 'foo']);
$request = $location->visit($command, $request, $param);
$header = $request->getHeader('foo');
$this->assertIsArray($header);
$this->assertEquals([0 => 'bar'], $request->getHeader('foo'));
}
/**
* @group RequestLocation
*/
public function testAddsAdditionalProperties()
{
$location = new HeaderLocation('header');
$command = new Command('foo', ['foo' => 'bar']);
$command['add'] = 'props';
$operation = new Operation([
'additionalParameters' => [
'location' => 'header',
],
]);
$request = new Request('POST', 'http://httbin.org');
$request = $location->after($command, $request, $operation);
$header = $request->getHeader('add');
$this->assertIsArray($header);
$this->assertEquals([0 => 'props'], $header);
}
}