summaryrefslogtreecommitdiff
path: root/tests/Unit/Http/RequestTest.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-11-28 15:43:51 +0100
committerGitHub <noreply@github.com>2017-11-28 15:43:51 +0100
commit599f2fd264bfc7b1b6826fe206442806e317340f (patch)
tree50cf84d7d07d11bd65b45c2c17f37632f6cd8eff /tests/Unit/Http/RequestTest.php
parenta5fc5bd0979e8de1fce8a8addd351a6e7bd6aeb8 (diff)
parenteda7f7788ea8012bd8be46405c56a666c11f3fa5 (diff)
Merge pull request #365 from engelsystem/feature-igel-rewrite
Feature igel rewrite
Diffstat (limited to 'tests/Unit/Http/RequestTest.php')
-rw-r--r--tests/Unit/Http/RequestTest.php99
1 files changed, 99 insertions, 0 deletions
diff --git a/tests/Unit/Http/RequestTest.php b/tests/Unit/Http/RequestTest.php
new file mode 100644
index 00000000..a68f8b8f
--- /dev/null
+++ b/tests/Unit/Http/RequestTest.php
@@ -0,0 +1,99 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Http;
+
+use Engelsystem\Http\Request;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+
+class RequestTest extends TestCase
+{
+ /**
+ * @covers \Engelsystem\Http\Request::postData
+ */
+ public function testPostData()
+ {
+ $request = new Request(
+ ['foo' => 'I\'m a test!'],
+ ['foo' => 'bar']
+ );
+
+ $this->assertEquals('bar', $request->postData('foo'));
+ $this->assertEquals('LoremIpsum', $request->postData('test-key', 'LoremIpsum'));
+ }
+
+ /**
+ * @covers \Engelsystem\Http\Request::input
+ */
+ public function testInput()
+ {
+ $request = new Request(
+ ['foo' => 'I\'m a test!'],
+ ['foo' => 'bar']
+ );
+
+ $this->assertEquals('I\'m a test!', $request->input('foo'));
+ $this->assertEquals('LoremIpsum', $request->input('test-key', 'LoremIpsum'));
+ }
+
+ /**
+ * @covers \Engelsystem\Http\Request::has
+ */
+ public function testHas()
+ {
+ $request = new Request([
+ 'foo' => 'I\'m a test!',
+ 'bar' => '',
+ ]);
+
+ $this->assertTrue($request->has('foo'));
+ $this->assertTrue($request->has('bar'));
+ $this->assertFalse($request->has('baz'));
+ }
+
+ /**
+ * @covers \Engelsystem\Http\Request::path
+ */
+ public function testPath()
+ {
+ /** @var MockObject|Request $request */
+ $request = $this
+ ->getMockBuilder(Request::class)
+ ->setMethods(['getPathInfo'])
+ ->getMock();
+
+ $request
+ ->expects($this->atLeastOnce())
+ ->method('getPathInfo')
+ ->willReturnOnConsecutiveCalls(
+ '/foo',
+ '/'
+ );
+
+ $this->assertEquals('foo', $request->path());
+ $this->assertEquals('/', $request->path());
+ }
+
+ /**
+ * @covers \Engelsystem\Http\Request::url
+ */
+ public function testUrl()
+ {
+ /** @var MockObject|Request $request */
+ $request = $this
+ ->getMockBuilder(Request::class)
+ ->setMethods(['getUri'])
+ ->getMock();
+
+ $request
+ ->expects($this->atLeastOnce())
+ ->method('getUri')
+ ->willReturnOnConsecutiveCalls(
+ 'http://foo.bar/bla/foo/',
+ 'https://lorem.ipsum/dolor/sit?amet=consetetur&sadipscing=elitr'
+ );
+
+ $this->assertEquals('http://foo.bar/bla/foo', $request->url());
+ $this->assertEquals('https://lorem.ipsum/dolor/sit', $request->url());
+ }
+}