2018-08-16 18:13:53 +02:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-08-16 18:13:53 +02:00
|
|
|
namespace Engelsystem\Test\Unit\Http;
|
|
|
|
|
2019-04-24 10:45:00 +02:00
|
|
|
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
|
2018-08-16 18:13:53 +02:00
|
|
|
use Engelsystem\Test\Unit\Http\Stub\MessageTraitRequestImplementation;
|
2019-04-17 10:09:50 +02:00
|
|
|
use Nyholm\Psr7\Stream;
|
2018-08-16 18:13:53 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class MessageTraitRequestTest extends TestCase
|
|
|
|
{
|
2019-04-24 10:45:00 +02:00
|
|
|
use ArraySubsetAsserts;
|
|
|
|
|
2018-08-16 18:13:53 +02:00
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Http\MessageTrait::withProtocolVersion
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testWithProtocolVersion(): void
|
2018-08-16 18:13:53 +02:00
|
|
|
{
|
|
|
|
$message = new MessageTraitRequestImplementation();
|
|
|
|
$newMessage = $message->withProtocolVersion('0.1');
|
|
|
|
$this->assertNotEquals($message, $newMessage);
|
|
|
|
$this->assertEquals('0.1', $newMessage->getProtocolVersion());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Http\MessageTrait::getHeaders
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testGetHeaders(): void
|
2018-08-16 18:13:53 +02:00
|
|
|
{
|
|
|
|
$message = new MessageTraitRequestImplementation();
|
|
|
|
$newMessage = $message->withHeader('lorem', 'ipsum');
|
|
|
|
|
|
|
|
$this->assertNotEquals($message, $newMessage);
|
|
|
|
$this->assertArraySubset(['lorem' => ['ipsum']], $newMessage->getHeaders());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Http\MessageTrait::withBody
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testWithBody(): void
|
2018-08-16 18:13:53 +02:00
|
|
|
{
|
2019-04-17 10:09:50 +02:00
|
|
|
$stream = Stream::create('Test content');
|
2018-08-16 18:13:53 +02:00
|
|
|
$message = new MessageTraitRequestImplementation();
|
|
|
|
$newMessage = $message->withBody($stream);
|
|
|
|
|
|
|
|
$this->assertNotEquals($message, $newMessage);
|
|
|
|
$this->assertEquals('Test content', $newMessage->getContent());
|
|
|
|
}
|
|
|
|
}
|