1
0
Fork 0
mirror of synced 2024-06-23 08:40:58 +12:00

Add e2e test for users.update.prefs

This commit is contained in:
kodumbeats 2021-03-04 13:47:02 -05:00
parent 192ba00e3f
commit 440a67e6d2

View file

@ -186,7 +186,46 @@ class WebhooksCustomServerTest extends Scope
*/
return ['userId' => $user['body']['$id'], 'name' => $user['body']['name'], 'email' => $user['body']['email']];
}
/**
* @depends testCreateUser
*/
public function testUpdateUserPrefs(array $data):array
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/prefs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'prefs' => ['test' => true],
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertNotEmpty($user['body']['prefs']);
$webhook = $this->getLastRequest();
$this->assertEquals($webhook['method'], 'POST');
$this->assertEquals($webhook['headers']['Content-Type'], 'application/json');
$this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io');
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Event'], 'users.update.prefs');
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], 'not-yet-implemented');
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']);
$this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']);
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertEquals($webhook['data']['name'], $data['name']);
$this->assertIsInt($webhook['data']['registration']);
$this->assertEquals($webhook['data']['status'], 0);
$this->assertEquals($webhook['data']['email'], $data['email']);
$this->assertEquals($webhook['data']['emailVerification'], false);
$this->assertEquals($webhook['data']['prefs'], ["test" => true]);
return $data;
}
/**
* @depends testCreateUser
*/
@ -261,4 +300,4 @@ class WebhooksCustomServerTest extends Scope
return $data;
}
}
}