Add e2e test for users.update.prefs
This commit is contained in:
parent
192ba00e3f
commit
440a67e6d2
1 changed files with 41 additions and 2 deletions
|
@ -187,6 +187,45 @@ class WebhooksCustomServerTest extends Scope
|
||||||
return ['userId' => $user['body']['$id'], 'name' => $user['body']['name'], 'email' => $user['body']['email']];
|
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
|
* @depends testCreateUser
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue