Selaa lähdekoodia

Fix namespace
Improved testing methods

Sergio 4 vuotta sitten
vanhempi
commit
d042a3b84a
3 muutettua tiedostoa jossa 27 lisäystä ja 4 poistoa
  1. 2 2
      bootstrap/app.php
  2. 2 2
      tests/Feature/LoginControllerTest.php
  3. 23 0
      tests/TestCase.php

+ 2 - 2
bootstrap/app.php

@@ -1,7 +1,7 @@
 <?php
 <?php
 
 
-use App\Exception\Handlers\AppErrorHandler;
-use App\Exception\Handlers\Renderers\HtmlErrorRenderer;
+use App\Exceptions\Handlers\AppErrorHandler;
+use App\Exceptions\Handlers\Renderers\HtmlErrorRenderer;
 use App\Factories\ViewFactory;
 use App\Factories\ViewFactory;
 use App\Middleware\InjectMiddleware;
 use App\Middleware\InjectMiddleware;
 use App\Middleware\LangMiddleware;
 use App\Middleware\LangMiddleware;

+ 2 - 2
tests/Feature/LoginControllerTest.php

@@ -11,7 +11,7 @@ class LoginControllerTest extends TestCase
     /** @test */
     /** @test */
     public function it_loads_the_login_page()
     public function it_loads_the_login_page()
     {
     {
-        $this->client->request('GET', '/login');
-        $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+        $response = $this->get('/login');
+        $this->assertSame(200, $response->getStatusCode());
     }
     }
 }
 }

+ 23 - 0
tests/TestCase.php

@@ -2,6 +2,7 @@
 
 
 namespace Tests;
 namespace Tests;
 
 
+use GuzzleHttp\Psr7\Response;
 use PHPUnit\Framework\TestCase as BaseTestCase;
 use PHPUnit\Framework\TestCase as BaseTestCase;
 
 
 abstract class TestCase extends BaseTestCase
 abstract class TestCase extends BaseTestCase
@@ -16,4 +17,26 @@ abstract class TestCase extends BaseTestCase
 
 
         $this->client = new Client();
         $this->client = new Client();
     }
     }
+
+    /**
+     * @param  string  $uri
+     * @param  array  $parameters
+     * @return Response|object
+     */
+    public function get(string $uri, array $parameters = [])
+    {
+        $this->client->request('GET', $uri, $parameters);
+        return $this->client->getResponse();
+    }
+
+    /**
+     * @param  string  $uri
+     * @param  array  $parameters
+     * @return Response|object
+     */
+    public function post(string $uri, array $parameters = [])
+    {
+        $this->client->request('POST', $uri, $parameters);
+        return $this->client->getResponse();
+    }
 }
 }