diff options
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/UserRestController.php | 7 | ||||
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/UserRestController.php b/src/Wallabag/ApiBundle/Controller/UserRestController.php index becbbb9e..7471f5f6 100644 --- a/src/Wallabag/ApiBundle/Controller/UserRestController.php +++ b/src/Wallabag/ApiBundle/Controller/UserRestController.php | |||
@@ -28,13 +28,14 @@ class UserRestController extends WallabagRestController | |||
28 | } | 28 | } |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * Register an user. | 31 | * Register an user and create a client. |
32 | * | 32 | * |
33 | * @ApiDoc( | 33 | * @ApiDoc( |
34 | * requirements={ | 34 | * requirements={ |
35 | * {"name"="username", "dataType"="string", "required"=true, "description"="The user's username"}, | 35 | * {"name"="username", "dataType"="string", "required"=true, "description"="The user's username"}, |
36 | * {"name"="password", "dataType"="string", "required"=true, "description"="The user's password"}, | 36 | * {"name"="password", "dataType"="string", "required"=true, "description"="The user's password"}, |
37 | * {"name"="email", "dataType"="string", "required"=true, "description"="The user's email"} | 37 | * {"name"="email", "dataType"="string", "required"=true, "description"="The user's email"}, |
38 | * {"name"="client_name", "dataType"="string", "required"=true, "description"="The client name (to be used by your app)"} | ||
38 | * } | 39 | * } |
39 | * ) | 40 | * ) |
40 | * | 41 | * |
@@ -100,7 +101,7 @@ class UserRestController extends WallabagRestController | |||
100 | 101 | ||
101 | // create a default client | 102 | // create a default client |
102 | $client = new Client($user); | 103 | $client = new Client($user); |
103 | $client->setName('Default client'); | 104 | $client->setName($request->request->get('client_name', 'Default client')); |
104 | 105 | ||
105 | $this->getDoctrine()->getManager()->persist($client); | 106 | $this->getDoctrine()->getManager()->persist($client); |
106 | 107 | ||
diff --git a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php index 9f01a976..4e65f130 100644 --- a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php | |||
@@ -85,6 +85,7 @@ class UserRestControllerTest extends WallabagApiTestCase | |||
85 | 'username' => 'google', | 85 | 'username' => 'google', |
86 | 'password' => 'googlegoogle', | 86 | 'password' => 'googlegoogle', |
87 | 'email' => 'wallabag@google.com', | 87 | 'email' => 'wallabag@google.com', |
88 | 'client_name' => 'My client name !!', | ||
88 | ]); | 89 | ]); |
89 | 90 | ||
90 | $this->assertEquals(201, $client->getResponse()->getStatusCode()); | 91 | $this->assertEquals(201, $client->getResponse()->getStatusCode()); |
@@ -104,7 +105,7 @@ class UserRestControllerTest extends WallabagApiTestCase | |||
104 | $this->assertArrayHasKey('client_secret', $content['default_client']); | 105 | $this->assertArrayHasKey('client_secret', $content['default_client']); |
105 | $this->assertArrayHasKey('client_id', $content['default_client']); | 106 | $this->assertArrayHasKey('client_id', $content['default_client']); |
106 | 107 | ||
107 | $this->assertEquals('Default client', $content['default_client']['name']); | 108 | $this->assertEquals('My client name !!', $content['default_client']['name']); |
108 | 109 | ||
109 | $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); | 110 | $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); |
110 | 111 | ||