+ $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->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);
+ }
+
+ public function testCreateNewUserWithoutAuthentication()
+ {
+ // create a new client instead of using $this->client to be sure client isn't authenticated
+ $client = static::createClient();
+ $client->getContainer()->get('craue_config')->set('api_user_registration', 1);
+ $client->request('PUT', '/api/user.json', [
+ 'username' => 'google',
+ 'password' => 'googlegoogle',
+ 'email' => 'wallabag@google.com',
+ 'client_name' => 'My client name !!',
+ ]);
+
+ $this->assertSame(201, $client->getResponse()->getStatusCode());
+
+ $content = json_decode($client->getResponse()->getContent(), true);
+
+ $this->assertArrayHasKey('id', $content);
+ $this->assertArrayHasKey('email', $content);
+ $this->assertArrayHasKey('username', $content);
+ $this->assertArrayHasKey('created_at', $content);
+ $this->assertArrayHasKey('updated_at', $content);
+ $this->assertArrayHasKey('default_client', $content);