This commit is contained in:
Marcel Pociot
2022-03-04 12:05:28 +01:00
parent 117424cf0e
commit 3cc290998d
3 changed files with 58 additions and 4 deletions

View File

@@ -67,6 +67,54 @@ class ApiTest extends TestCase
$this->assertSame([], $users[0]->sites);
}
/** @test */
public function it_can_update_registered_users()
{
/** @var Response $response */
$this->await($this->browser->post('http://127.0.0.1:8080/api/users', [
'Host' => 'expose.localhost',
'Authorization' => base64_encode('username:secret'),
'Content-Type' => 'application/json',
], json_encode([
'name' => 'Marcel',
'can_specify_subdomains' => true,
])));
/** @var Response $response */
$response = $this->await($this->browser->get('http://127.0.0.1:8080/api/users', [
'Host' => 'expose.localhost',
'Authorization' => base64_encode('username:secret'),
'Content-Type' => 'application/json',
]));
$user = json_decode($response->getBody()->getContents())->paginated->users[0];
$this->assertSame('Marcel', $user->name);
$this->assertSame(1, $user->can_specify_subdomains);
$this->await($this->browser->post('http://127.0.0.1:8080/api/users', [
'Host' => 'expose.localhost',
'Authorization' => base64_encode('username:secret'),
'Content-Type' => 'application/json',
], json_encode([
'token' => $user->auth_token,
'name' => 'Julia',
'can_specify_subdomains' => false,
])));
$response = $this->await($this->browser->get('http://127.0.0.1:8080/api/users', [
'Host' => 'expose.localhost',
'Authorization' => base64_encode('username:secret'),
'Content-Type' => 'application/json',
]));
$users = json_decode($response->getBody()->getContents())->paginated;
$user = $users->users[0];
$this->assertCount(1, $users->users);
$this->assertSame('Julia', $user->name);
$this->assertSame(0, $user->can_specify_subdomains);
}
/** @test */
public function it_can_specify_a_token_when_creating_a_user()
{