diff --git a/tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php b/tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php index d8474c649..553c78b9a 100644 --- a/tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php +++ b/tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php @@ -305,6 +305,43 @@ class WebhooksCustomServerTest extends Scope /** * @depends testCreateFunction */ + public function testUpdateFunction($data):array + { + /** + * Test for SUCCESS + */ + $function = $this->client->call(Client::METHOD_PUT, '/functions/'.$data['functionId'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'name' => 'Test', + 'env' => 'php-7.4', + 'execute' => ['*'], + 'vars' => [ + 'key1' => 'value1', + ] + ]); + + $this->assertEquals($function['headers']['status-code'], 200); + $this->assertEquals($function['body']['$id'], $data['functionId']); + $this->assertEquals($function['body']['vars'], ['key1' => 'value1']); + + $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'], 'functions.update'); + $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']); + + return $data; + } + + /** + * @depends testUpdateFunction + */ public function testCreateTag($data):array { /** @@ -422,7 +459,7 @@ class WebhooksCustomServerTest extends Scope } /** - * @depends testUpdateTag + * @depends testExecutions */ public function testDeleteTag($data):array {