X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FApiBundle%2FController%2FUserRestControllerTest.php;h=51fac2bd33194ce5dedd1d7210a69fae97d95a70;hb=f808b01692a835673f328d7221ba8c212caa9b61;hp=5735bc5819e78cdf2e79db188f8d3d907da1a127;hpb=438329be467d77595f549da48a6b49f38ece9b55;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php index 5735bc58..51fac2bd 100644 --- a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php @@ -9,7 +9,7 @@ class UserRestControllerTest extends WallabagApiTestCase public function testGetUser() { $this->client->request('GET', '/api/user.json'); - $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + $this->assertSame(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); @@ -20,27 +20,27 @@ class UserRestControllerTest extends WallabagApiTestCase $this->assertArrayHasKey('created_at', $content); $this->assertArrayHasKey('updated_at', $content); - $this->assertEquals('bigboss@wallabag.org', $content['email']); - $this->assertEquals('Big boss', $content['name']); - $this->assertEquals('admin', $content['username']); + $this->assertSame('bigboss@wallabag.org', $content['email']); + $this->assertSame('Big boss', $content['name']); + $this->assertSame('admin', $content['username']); - $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); + $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type')); } public function testGetUserWithoutAuthentication() { $client = static::createClient(); $client->request('GET', '/api/user.json'); - $this->assertEquals(401, $client->getResponse()->getStatusCode()); + $this->assertSame(401, $client->getResponse()->getStatusCode()); $content = json_decode($client->getResponse()->getContent(), true); $this->assertArrayHasKey('error', $content); $this->assertArrayHasKey('error_description', $content); - $this->assertEquals('access_denied', $content['error']); + $this->assertSame('access_denied', $content['error']); - $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); + $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type')); } public function testCreateNewUser() @@ -52,7 +52,7 @@ class UserRestControllerTest extends WallabagApiTestCase 'email' => 'wallabag@google.com', ]); - $this->assertEquals(201, $this->client->getResponse()->getStatusCode()); + $this->assertSame(201, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); @@ -61,11 +61,17 @@ class UserRestControllerTest extends WallabagApiTestCase $this->assertArrayHasKey('username', $content); $this->assertArrayHasKey('created_at', $content); $this->assertArrayHasKey('updated_at', $content); + $this->assertArrayHasKey('default_client', $content); - $this->assertEquals('wallabag@google.com', $content['email']); - $this->assertEquals('google', $content['username']); + $this->assertSame('wallabag@google.com', $content['email']); + $this->assertSame('google', $content['username']); - $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); + $this->assertArrayHasKey('client_secret', $content['default_client']); + $this->assertArrayHasKey('client_id', $content['default_client']); + + $this->assertSame('Default client', $content['default_client']['name']); + + $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type')); $this->client->getContainer()->get('craue_config')->set('api_user_registration', 0); } @@ -79,9 +85,10 @@ class UserRestControllerTest extends WallabagApiTestCase 'username' => 'google', 'password' => 'googlegoogle', 'email' => 'wallabag@google.com', + 'client_name' => 'My client name !!', ]); - $this->assertEquals(201, $client->getResponse()->getStatusCode()); + $this->assertSame(201, $client->getResponse()->getStatusCode()); $content = json_decode($client->getResponse()->getContent(), true); @@ -90,11 +97,17 @@ class UserRestControllerTest extends WallabagApiTestCase $this->assertArrayHasKey('username', $content); $this->assertArrayHasKey('created_at', $content); $this->assertArrayHasKey('updated_at', $content); + $this->assertArrayHasKey('default_client', $content); + + $this->assertSame('wallabag@google.com', $content['email']); + $this->assertSame('google', $content['username']); + + $this->assertArrayHasKey('client_secret', $content['default_client']); + $this->assertArrayHasKey('client_id', $content['default_client']); - $this->assertEquals('wallabag@google.com', $content['email']); - $this->assertEquals('google', $content['username']); + $this->assertSame('My client name !!', $content['default_client']['name']); - $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); + $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type')); $client->getContainer()->get('craue_config')->set('api_user_registration', 0); } @@ -109,7 +122,7 @@ class UserRestControllerTest extends WallabagApiTestCase 'email' => 'bigboss@wallabag.org', ]); - $this->assertEquals(400, $client->getResponse()->getStatusCode()); + $this->assertSame(400, $client->getResponse()->getStatusCode()); $content = json_decode($client->getResponse()->getContent(), true); @@ -120,10 +133,10 @@ class UserRestControllerTest extends WallabagApiTestCase // $this->assertEquals('fos_user.username.already_used', $content['error']['username'][0]); // $this->assertEquals('fos_user.email.already_used', $content['error']['email'][0]); // This shouldn't be translated ... - $this->assertEquals('This value is already used.', $content['error']['username'][0]); - $this->assertEquals('This value is already used.', $content['error']['email'][0]); + $this->assertSame('This value is already used.', $content['error']['username'][0]); + $this->assertSame('This value is already used.', $content['error']['email'][0]); - $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); + $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type')); $client->getContainer()->get('craue_config')->set('api_user_registration', 0); } @@ -138,16 +151,16 @@ class UserRestControllerTest extends WallabagApiTestCase 'email' => 'facebook@wallabag.org', ]); - $this->assertEquals(400, $client->getResponse()->getStatusCode()); + $this->assertSame(400, $client->getResponse()->getStatusCode()); $content = json_decode($client->getResponse()->getContent(), true); $this->assertArrayHasKey('error', $content); $this->assertArrayHasKey('password', $content['error']); - $this->assertEquals('validator.password_too_short', $content['error']['password'][0]); + $this->assertSame('validator.password_too_short', $content['error']['password'][0]); - $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); + $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type')); $client->getContainer()->get('craue_config')->set('api_user_registration', 0); } @@ -161,12 +174,12 @@ class UserRestControllerTest extends WallabagApiTestCase 'email' => 'facebook@wallabag.org', ]); - $this->assertEquals(403, $client->getResponse()->getStatusCode()); + $this->assertSame(403, $client->getResponse()->getStatusCode()); $content = json_decode($client->getResponse()->getContent(), true); $this->assertArrayHasKey('error', $content); - $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); + $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type')); } }