summaryrefslogtreecommitdiff
path: root/tests/Unit/Http/MessageTraitRequestTest.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2018-09-04 18:24:11 +0200
committermsquare <msquare@notrademark.de>2018-09-04 18:24:11 +0200
commitb320fc779063ee80b8f0ba505cb323287ccccbf5 (patch)
tree1e420597ae72c979361bf29b66ae7e27c73cf431 /tests/Unit/Http/MessageTraitRequestTest.php
parent9f1ee0c6c6497d43fb275491ec53fda420f64b81 (diff)
parent36dafdb68acbde2fe42ce36ef50f497c8c06411f (diff)
Merge branch 'MyIgel-rebuild-psr7'
Diffstat (limited to 'tests/Unit/Http/MessageTraitRequestTest.php')
-rw-r--r--tests/Unit/Http/MessageTraitRequestTest.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/Unit/Http/MessageTraitRequestTest.php b/tests/Unit/Http/MessageTraitRequestTest.php
new file mode 100644
index 00000000..7430b5d7
--- /dev/null
+++ b/tests/Unit/Http/MessageTraitRequestTest.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Http;
+
+use Engelsystem\Test\Unit\Http\Stub\MessageTraitRequestImplementation;
+use PHPUnit\Framework\TestCase;
+use Zend\Diactoros\Stream;
+
+class MessageTraitRequestTest extends TestCase
+{
+ /**
+ * @covers \Engelsystem\Http\MessageTrait::withProtocolVersion
+ */
+ public function testWithProtocolVersion()
+ {
+ $message = new MessageTraitRequestImplementation();
+ $newMessage = $message->withProtocolVersion('0.1');
+ $this->assertNotEquals($message, $newMessage);
+ $this->assertEquals('0.1', $newMessage->getProtocolVersion());
+ }
+
+ /**
+ * @covers \Engelsystem\Http\MessageTrait::getHeaders
+ */
+ public function testGetHeaders()
+ {
+ $message = new MessageTraitRequestImplementation();
+ $newMessage = $message->withHeader('lorem', 'ipsum');
+
+ $this->assertNotEquals($message, $newMessage);
+ $this->assertArraySubset(['lorem' => ['ipsum']], $newMessage->getHeaders());
+ }
+
+ /**
+ * @covers \Engelsystem\Http\MessageTrait::withBody
+ */
+ public function testWithBody()
+ {
+ /** @var Stream $stream */
+ $stream = new Stream('php://memory', 'wb+');
+ $stream->write('Test content');
+ $stream->rewind();
+
+ $message = new MessageTraitRequestImplementation();
+ $newMessage = $message->withBody($stream);
+
+ $this->assertNotEquals($message, $newMessage);
+ $this->assertEquals('Test content', $newMessage->getContent());
+ }
+}