8000 Update tests · Lucky-Loek/Symfony-API-Example@7890b30 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Dec 17, 2019. It is now read-only.

Commit 7890b30

Browse files
author
Loek van der Linde
committed
Update tests
1 parent 1541720 commit 7890b30

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

tests/AppBundle/Controller/CarControllerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace tests\AppBundle\Controller;
44

55
use GuzzleHttp\Client;
6-
use GuzzleHttp\Psr7\Request;
6+
use GuzzleHttp\Exception\ClientException;
77

88
class CarControllerTest extends \PHPUnit_Framework_TestCase
99
{
@@ -22,7 +22,7 @@ public function setUp() {
2222
* @test
2323
*/
2424
public function shouldThrow401OnUnauthorizedUserRequest() {
25-
$response = $this->client->request('GET', 'car');
26-
$this->assertEquals(401, $response->getStatusCode());
25+
$this->expectException(ClientException::class);
26+
$this->client->request('GET', 'car');
2727
}
2828
}

tests/AppBundle/Controller/TokenControllerTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
namespace tests\AppBundle\Controller;
4+
45
use GuzzleHttp\Client;
5-
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
6+
use GuzzleHttp\Exception\ClientException;
67

78
class TokenControllerTest extends \PHPUnit_Framework_TestCase
89
{
@@ -38,10 +39,10 @@ public function shouldCreateTokenOnValidCredentials()
3839
*/
3940
public function shouldThrowExceptionOnInvalidCredentials()
4041
{
41-
$response = $this->client->post('/api/token', [
42+
$this->expectException(ClientException::class);
43+
44+
$this->client->post('/api/t 5318 oken', [
4245
'auth' => ['admin', 'reallysafepassword']
4346
]);
44-
45-
$this->assertEquals(401, $response->getStatusCode());
4647
}
4748
}

0 commit comments

Comments
 (0)
0