diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 966032bfab..3476157311 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -481,12 +481,13 @@ class FunctionsCustomServerTest extends Scope * bash tests/resources/functions/package.sh */ $envs = [ - //[ - // 'name' => 'php-7.4', - // 'code' => $functions.'/php-fx.tar.gz', - // 'command' => 'php function.php', - //], - + [ + 'language' => 'PHP', + 'version' => '8.0', + 'name' => 'php-8.0', + 'code' => $functions.'/php.tar.gz', + 'command' => 'php index.php', + ], [ 'language' => 'Python', 'version' => '3.8', diff --git a/tests/resources/functions/package.sh b/tests/resources/functions/package.sh index 16aa4ba2b6..ede5a255cd 100644 --- a/tests/resources/functions/package.sh +++ b/tests/resources/functions/package.sh @@ -10,4 +10,16 @@ docker run --rm -v $(pwd)/tests/resources/functions/packages/python:/app -w /app mv $(pwd)/tests/resources/functions/packages/python/code.tar.gz $(pwd)/tests/resources/functions/python.tar.gz -rm -r $(pwd)/tests/resources/functions/packages/python \ No newline at end of file +rm -r $(pwd)/tests/resources/functions/packages/python + +echo 'PHP Packaging...' + +cp -r $(pwd)/tests/resources/functions/php $(pwd)/tests/resources/functions/packages/php + +docker run --rm -v $(pwd)/tests/resources/functions/packages/php:/app -w /app composer:2.0 update --ignore-platform-reqs --optimize-autoloader --no-plugins --no-scripts --prefer-dist + +docker run --rm -v $(pwd)/tests/resources/functions/packages/php:/app -w /app appwrite/env-php-8.0:1.0.0 tar -zcvf code.tar.gz . + +mv $(pwd)/tests/resources/functions/packages/php/code.tar.gz $(pwd)/tests/resources/functions/php.tar.gz + +rm -r $(pwd)/tests/resources/functions/packages/php \ No newline at end of file diff --git a/tests/resources/functions/php-fx.tar.gz b/tests/resources/functions/php-fx.tar.gz deleted file mode 100644 index f8e3cbd811..0000000000 Binary files a/tests/resources/functions/php-fx.tar.gz and /dev/null differ diff --git a/tests/resources/functions/php.tar.gz b/tests/resources/functions/php.tar.gz new file mode 100644 index 0000000000..15688681b8 Binary files /dev/null and b/tests/resources/functions/php.tar.gz differ diff --git a/tests/resources/functions/php/composer.json b/tests/resources/functions/php/composer.json new file mode 100644 index 0000000000..f25f224da9 --- /dev/null +++ b/tests/resources/functions/php/composer.json @@ -0,0 +1,23 @@ +{ + "name": "appwrite/cloud-function-demo", + "description": "Demo cloud function script", + "type": "library", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Team Appwrite", + "email": "team@appwrite.io" + } + ], + "autoload": { + "psr-4": { + "Appwrite\\": "src/Appwrite" + } + }, + "require": { + "php": ">=7.4.0", + "ext-curl": "*", + "ext-json": "*", + "appwrite/appwrite": "1.1.*" + } +} diff --git a/tests/resources/functions/php/index.php b/tests/resources/functions/php/index.php new file mode 100644 index 0000000000..58f8004c12 --- /dev/null +++ b/tests/resources/functions/php/index.php @@ -0,0 +1,28 @@ +setEndpoint($_ENV['APPWRITE_ENDPOINT']) // Your API Endpoint + ->setProject($_ENV['APPWRITE_PROJECT']) // Your project ID + ->setKey($_ENV['APPWRITE_SECRET']) // Your secret API key +; + +$storage = new Storage($client); + +// $result = $storage->getFile($_ENV['APPWRITE_FILEID']); + +echo $_ENV['APPWRITE_FUNCTION_ID']."\n"; +echo $_ENV['APPWRITE_FUNCTION_NAME']."\n"; +echo $_ENV['APPWRITE_FUNCTION_TAG']."\n"; +echo $_ENV['APPWRITE_FUNCTION_TRIGGER']."\n"; +echo $_ENV['APPWRITE_FUNCTION_ENV_NAME']."\n"; +echo $_ENV['APPWRITE_FUNCTION_ENV_VERSION']."\n"; +// echo $result['$id']; +echo $_ENV['APPWRITE_FUNCTION_EVENT']."\n"; +echo $_ENV['APPWRITE_FUNCTION_EVENT_PAYLOAD']."\n"; \ No newline at end of file diff --git a/tests/resources/functions/python-fx.tar.gz b/tests/resources/functions/python-fx.tar.gz deleted file mode 100644 index f445d60c26..0000000000 Binary files a/tests/resources/functions/python-fx.tar.gz and /dev/null differ diff --git a/tests/resources/functions/python.tar.gz b/tests/resources/functions/python.tar.gz index 2c96e6b674..10ed3d326a 100644 Binary files a/tests/resources/functions/python.tar.gz and b/tests/resources/functions/python.tar.gz differ