Added PHP tests
This commit is contained in:
parent
d4bffb8a43
commit
c75f3d44cc
|
@ -481,12 +481,13 @@ class FunctionsCustomServerTest extends Scope
|
||||||
* bash tests/resources/functions/package.sh
|
* bash tests/resources/functions/package.sh
|
||||||
*/
|
*/
|
||||||
$envs = [
|
$envs = [
|
||||||
//[
|
[
|
||||||
// 'name' => 'php-7.4',
|
'language' => 'PHP',
|
||||||
// 'code' => $functions.'/php-fx.tar.gz',
|
'version' => '8.0',
|
||||||
// 'command' => 'php function.php',
|
'name' => 'php-8.0',
|
||||||
//],
|
'code' => $functions.'/php.tar.gz',
|
||||||
|
'command' => 'php index.php',
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'language' => 'Python',
|
'language' => 'Python',
|
||||||
'version' => '3.8',
|
'version' => '3.8',
|
||||||
|
|
|
@ -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
|
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.
BIN
tests/resources/functions/php.tar.gz
Normal file
BIN
tests/resources/functions/php.tar.gz
Normal file
Binary file not shown.
23
tests/resources/functions/php/composer.json
Normal file
23
tests/resources/functions/php/composer.json
Normal 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.*"
|
||||||
|
}
|
||||||
|
}
|
28
tests/resources/functions/php/index.php
Normal file
28
tests/resources/functions/php/index.php
Normal 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";
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue