From 211394b7a3409a1e71c03d09e3246acdda3b9545 Mon Sep 17 00:00:00 2001
From: Thomas Flori <thflori@gmail.com>
Date: Sun, 5 Aug 2018 14:05:09 +0200
Subject: [PATCH] add a test in ServerResponseTest and the code-style command

---
 composer.json                |  3 +++
 tests/ClientResponseTest.php |  2 +-
 tests/ServerResponseTest.php | 10 ++++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/composer.json b/composer.json
index 19d4d9f..55b5a49 100644
--- a/composer.json
+++ b/composer.json
@@ -3,6 +3,9 @@
     "description": "A guzzle/psr-7 wrapper to add additional functionality like sending responses and managing cookies",
     "type": "library",
     "license": "MIT",
+    "scripts": {
+        "code-style": "phpcs --standard=PSR2 src && phpcs --standard=PSR2 --ignore=example tests"
+    },
     "require": {
         "guzzlehttp/psr7": "^1.4.2"
     },
diff --git a/tests/ClientResponseTest.php b/tests/ClientResponseTest.php
index 0c30ecc..7b89db4 100644
--- a/tests/ClientResponseTest.php
+++ b/tests/ClientResponseTest.php
@@ -239,7 +239,7 @@ class ClientResponseTest extends TestCase
     {
         $r1 = new Response(200, ['OWS' => " \t \tFoo\t \t "]);
         $r2 = (new Response())->withHeader('OWS', " \t \tFoo\t \t ");
-        $r3 = (new Response())->withAddedHeader('OWS', " \t \tFoo\t \t ");;
+        $r3 = (new Response())->withAddedHeader('OWS', " \t \tFoo\t \t ");
 
         foreach ([$r1, $r2, $r3] as $r) {
             $this->assertSame(['OWS' => ['Foo']], $r->getHeaders());
diff --git a/tests/ServerResponseTest.php b/tests/ServerResponseTest.php
index 3057e3c..e981583 100644
--- a/tests/ServerResponseTest.php
+++ b/tests/ServerResponseTest.php
@@ -3,8 +3,18 @@
 namespace Tal\Test;
 
 use PHPUnit\Framework\TestCase;
+use Tal\ServerResponse;
 
 class ServerResponseTest extends TestCase
 {
+    public function testSetCookieAddsHeader()
+    {
+        $response = new ServerResponse();
 
+        $response->setCookie('foo', 'bar');
+
+        self::assertEquals([
+            'Set-Cookie' => ['foo=bar']
+        ], $response->getHeaders());
+    }
 }
-- 
GitLab