This repository was archived by the owner on Dec 17, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
tests/AppBundle/Controller Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 3
3
namespace tests \AppBundle \Controller ;
4
4
5
5
use GuzzleHttp \Client ;
6
- use GuzzleHttp \Psr7 \ Request ;
6
+ use GuzzleHttp \Exception \ ClientException ;
7
7
8
8
class CarControllerTest extends \PHPUnit_Framework_TestCase
9
9
{
@@ -22,7 +22,7 @@ public function setUp() {
22
22
* @test
23
23
*/
24
24
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 ' );
27
27
}
28
28
}
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
3
namespace tests \AppBundle \Controller ;
4
+
4
5
use GuzzleHttp \Client ;
5
- use Symfony \ Bundle \ FrameworkBundle \ Test \ KernelTestCase ;
6
+ use GuzzleHttp \ Exception \ ClientException ;
6
7
7
8
class TokenControllerTest extends \PHPUnit_Framework_TestCase
8
9
{
@@ -38,10 +39,10 @@ public function shouldCreateTokenOnValidCredentials()
38
39
*/
39
40
public function shouldThrowExceptionOnInvalidCredentials ()
40
41
{
41
- $ response = $ this ->client ->post ('/api/token ' , [
42
+ $ this ->expectException (ClientException::class);
43
+
44
+ $ this ->client ->post ('/api/t
5318
oken ' , [
42
45
'auth ' => ['admin ' , 'reallysafepassword ' ]
43
46
]);
44
-
45
- $ this ->assertEquals (401 , $ response ->getStatusCode ());
46
47
}
47
48
}
You can’t perform that action at this time.
0 commit comments