diff --git a/tests/resources/functions/package-php-fn.sh b/tests/resources/functions/package-php-fn.sh new file mode 100755 index 0000000000..bbb4920cbc --- /dev/null +++ b/tests/resources/functions/package-php-fn.sh @@ -0,0 +1,12 @@ + +echo 'PHP Packaging...' + +cp -r $(pwd)/tests/resources/functions/php-fn $(pwd)/tests/resources/functions/packages/php-fn + +docker run --rm -v $(pwd)/tests/resources/functions/packages/php-fn:/app -w /app composer:2.0 composer install --ignore-platform-reqs + +docker run --rm -v $(pwd)/tests/resources/functions/packages/php-fn:/app -w /app appwrite/env-php-8.0:1.0.0 tar -zcvf code.tar.gz . + +mv $(pwd)/tests/resources/functions/packages/php-fn/code.tar.gz $(pwd)/tests/resources/functions/php-fn.tar.gz + +rm -r $(pwd)/tests/resources/functions/packages/php-fn diff --git a/tests/resources/functions/php-fn.tar.gz b/tests/resources/functions/php-fn.tar.gz new file mode 100644 index 0000000000..55dd108891 Binary files /dev/null and b/tests/resources/functions/php-fn.tar.gz differ diff --git a/tests/resources/functions/php-fn/composer.json b/tests/resources/functions/php-fn/composer.json new file mode 100644 index 0000000000..e3c6db23e9 --- /dev/null +++ b/tests/resources/functions/php-fn/composer.json @@ -0,0 +1,18 @@ +{ + "name": "appwrite/cloud-function-demo", + "description": "Demo cloud function script", + "type": "library", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Team Appwrite", + "email": "team@appwrite.io" + } + ], + "require": { + "php": ">=7.4.0", + "ext-curl": "*", + "ext-json": "*", + "appwrite/appwrite": "1.1.*" + } +} diff --git a/tests/resources/functions/php-fn/composer.lock b/tests/resources/functions/php-fn/composer.lock new file mode 100644 index 0000000000..758c73c3f9 --- /dev/null +++ b/tests/resources/functions/php-fn/composer.lock @@ -0,0 +1,64 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "afdff6a172e6c44aee11f1562175f81a", + "packages": [ + { + "name": "appwrite/appwrite", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/appwrite/sdk-for-php.git", + "reference": "98b327d3fd18a72f4582019916afd735a0e9e0e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/98b327d3fd18a72f4582019916afd735a0e9e0e7", + "reference": "98b327d3fd18a72f4582019916afd735a0e9e0e7", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "php": ">=7.1.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "Appwrite\\": "src/Appwrite" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks", + "support": { + "email": "team@localhost.test", + "issues": "https://github.com/appwrite/sdk-for-php/issues", + "source": "https://github.com/appwrite/sdk-for-php/tree/1.1.2", + "url": "https://appwrite.io/support" + }, + "time": "2020-08-15T18:24:32+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.4.0", + "ext-curl": "*", + "ext-json": "*" + }, + "platform-dev": [], + "plugin-api-version": "2.0.0" +} diff --git a/tests/resources/functions/php-fn/index.php b/tests/resources/functions/php-fn/index.php new file mode 100644 index 0000000000..6d4bad1e5a --- /dev/null +++ b/tests/resources/functions/php-fn/index.php @@ -0,0 +1,31 @@ +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"; +echo 'data:'.$_ENV['APPWRITE_FUNCTION_DATA']."\n"; +echo 'userId:'.$_ENV['APPWRITE_FUNCTION_USERID']."\n"; +echo 'jwt:'.$_ENV['APPWRITE_FUNCTION_JWT']."\n";