summaryrefslogtreecommitdiff
path: root/tests/Unit/Http
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-01-18 19:01:34 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2018-08-07 16:54:08 +0200
commit3c088292050982505726f5136ff4d0f1a918b879 (patch)
tree8d0e03947935ceb994ef6f8fe01af81bbb268b14 /tests/Unit/Http
parent2f41b9e4418def9b69cf237312bc592364585025 (diff)
Added Http\Response and Psr7{Request,Response}
Diffstat (limited to 'tests/Unit/Http')
-rw-r--r--tests/Unit/Http/Psr7ServiceProviderTest.php65
-rw-r--r--tests/Unit/Http/RequestTest.php10
-rw-r--r--tests/Unit/Http/ResponseServiceProviderTest.php29
-rw-r--r--tests/Unit/Http/ResponseTest.php19
4 files changed, 123 insertions, 0 deletions
diff --git a/tests/Unit/Http/Psr7ServiceProviderTest.php b/tests/Unit/Http/Psr7ServiceProviderTest.php
new file mode 100644
index 00000000..b4c3c042
--- /dev/null
+++ b/tests/Unit/Http/Psr7ServiceProviderTest.php
@@ -0,0 +1,65 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Http;
+
+use Engelsystem\Http\Psr7ServiceProvider;
+use Engelsystem\Http\Request;
+use Engelsystem\Http\Response;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface as RequestInterface;
+use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
+
+class Psr7ServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Http\Psr7ServiceProvider::register()
+ */
+ public function testRegister()
+ {
+ /** @var MockObject|DiactorosFactory $psr7Factory */
+ $psr7Factory = $this->createMock(DiactorosFactory::class);
+ /** @var MockObject|Request $request */
+ $request = $this->createMock(Request::class);
+ /** @var MockObject|Response $response */
+ $response = $this->createMock(Response::class);
+ /** @var MockObject|RequestInterface $psr7request */
+ $psr7request = $this->createMock(Request::class);
+ /** @var MockObject|ResponseInterface $psr7response */
+ $psr7response = $this->createMock(Response::class);
+
+ $app = $this->getApp(['make', 'instance', 'get', 'bind']);
+ $this->setExpects($app, 'make', [DiactorosFactory::class], $psr7Factory);
+
+ $app->expects($this->atLeastOnce())
+ ->method('get')
+ ->withConsecutive(['request'], ['response'])
+ ->willReturnOnConsecutiveCalls($request, $response);
+ $app->expects($this->atLeastOnce())
+ ->method('instance')
+ ->withConsecutive(
+ ['psr7.factory', $psr7Factory],
+ ['psr7.request', $psr7request],
+ ['psr7.response', $psr7response]
+ );
+ $app->expects($this->atLeastOnce())
+ ->method('bind')
+ ->withConsecutive(
+ [RequestInterface::class, 'psr7.request'],
+ [ResponseInterface::class, 'psr7.response']
+ );
+
+ $psr7Factory->expects($this->once())
+ ->method('createRequest')
+ ->with($request)
+ ->willReturn($psr7request);
+ $psr7Factory->expects($this->once())
+ ->method('createResponse')
+ ->with($response)
+ ->willReturn($psr7response);
+
+ $serviceProvider = new Psr7ServiceProvider($app);
+ $serviceProvider->register();
+ }
+}
diff --git a/tests/Unit/Http/RequestTest.php b/tests/Unit/Http/RequestTest.php
index a68f8b8f..f8444b84 100644
--- a/tests/Unit/Http/RequestTest.php
+++ b/tests/Unit/Http/RequestTest.php
@@ -5,10 +5,20 @@ namespace Engelsystem\Test\Unit\Http;
use Engelsystem\Http\Request;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
class RequestTest extends TestCase
{
/**
+ * @covers \Engelsystem\Http\Request
+ */
+ public function testCreate()
+ {
+ $response = new Request();
+ $this->assertInstanceOf(SymfonyRequest::class, $response);
+ }
+
+ /**
* @covers \Engelsystem\Http\Request::postData
*/
public function testPostData()
diff --git a/tests/Unit/Http/ResponseServiceProviderTest.php b/tests/Unit/Http/ResponseServiceProviderTest.php
new file mode 100644
index 00000000..52e95714
--- /dev/null
+++ b/tests/Unit/Http/ResponseServiceProviderTest.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Http;
+
+use Engelsystem\Http\Response;
+use Engelsystem\Http\ResponseServiceProvider;
+use Engelsystem\Test\Unit\ServiceProviderTest;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+
+class ResponseServiceProviderTest extends ServiceProviderTest
+{
+ /**
+ * @covers \Engelsystem\Http\ResponseServiceProvider::register()
+ */
+ public function testRegister()
+ {
+ /** @var MockObject|Response $response */
+ $response = $this->getMockBuilder(Response::class)
+ ->getMock();
+
+ $app = $this->getApp();
+
+ $this->setExpects($app, 'make', [Response::class], $response);
+ $this->setExpects($app, 'instance', ['response', $response]);
+
+ $serviceProvider = new ResponseServiceProvider($app);
+ $serviceProvider->register();
+ }
+}
diff --git a/tests/Unit/Http/ResponseTest.php b/tests/Unit/Http/ResponseTest.php
new file mode 100644
index 00000000..6bedf5c1
--- /dev/null
+++ b/tests/Unit/Http/ResponseTest.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Http;
+
+use Engelsystem\Http\Response;
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
+
+class ResponseTest extends TestCase
+{
+ /**
+ * @covers \Engelsystem\Http\Response
+ */
+ public function testCreate()
+ {
+ $response = new Response();
+ $this->assertInstanceOf(SymfonyResponse::class, $response);
+ }
+}