1
0
Fork 0
mirror of synced 2024-06-26 10:10:57 +12:00

Added PHP tests

This commit is contained in:
Eldad Fux 2020-12-11 07:50:54 +02:00
parent d4bffb8a43
commit c75f3d44cc
8 changed files with 71 additions and 7 deletions

View file

@ -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',

View file

@ -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
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

Binary file not shown.

View file

@ -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.*"
}
}

View file

@ -0,0 +1,28 @@
<?php
include './vendor/autoload.php';
use Appwrite\Client;
use Appwrite\Services\Storage;
$client = new Client();
$client
->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";