| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,49 @@ |
| 1 |
+#!/bin/bash |
|
| 2 |
+ |
|
| 3 |
+set -e |
|
| 4 |
+testDir="php-sdk-test" |
|
| 5 |
+GREEN="\033[0;32m" |
|
| 6 |
+NC="\033[0m" |
|
| 7 |
+ |
|
| 8 |
+if [ ! $PLIVO_API_PROD_HOST ] || [ ! $PLIVO_API_DEV_HOST ] || [ ! $PLIVO_AUTH_ID ] || [ ! $PLIVO_AUTH_TOKEN ]; then |
|
| 9 |
+ echo "Environment variables not properly set! Please refer to Local Development section in README!" |
|
| 10 |
+ exit 126 |
|
| 11 |
+fi |
|
| 12 |
+ |
|
| 13 |
+cd /usr/src/app |
|
| 14 |
+ |
|
| 15 |
+echo "Setting plivo-api endpoint to dev..." |
|
| 16 |
+find /usr/src/app/src/Plivo -type f -exec sed -i "s/$PLIVO_API_PROD_HOST/$PLIVO_API_DEV_HOST/g" {} \;
|
|
| 17 |
+ |
|
| 18 |
+composer install |
|
| 19 |
+ |
|
| 20 |
+if [ ! -d $testDir ]; then |
|
| 21 |
+ echo "Creating test dir..." |
|
| 22 |
+ mkdir -p $testDir |
|
| 23 |
+fi |
|
| 24 |
+ |
|
| 25 |
+if [ ! -f $testDir/test.php ]; then |
|
| 26 |
+ echo "Creating test file..." |
|
| 27 |
+ cd $testDir |
|
| 28 |
+ echo "<?php" > test.php |
|
| 29 |
+ echo "require '/usr/src/app/vendor/autoload.php';" >> test.php |
|
| 30 |
+ echo "use Plivo\\RestClient;" >> test.php |
|
| 31 |
+ echo -e "\n\n\$client = new RestClient();\n" >> test.php |
|
| 32 |
+ echo -e "\n\n?>" >> test.php |
|
| 33 |
+ cd - |
|
| 34 |
+fi |
|
| 35 |
+ |
|
| 36 |
+echo -e "\n\nSDK setup complete! You can test changes either on host or inside the docker container:" |
|
| 37 |
+echo -e "\ta. To test your changes ON HOST:" |
|
| 38 |
+echo -e "\t\t1. Add your test code in <path_to_cloned_sdk>/$testDir/test.php" |
|
| 39 |
+echo -e "\t\t2. Run your test file using: $GREEN make run CONTAINER=$HOSTNAME$NC" |
|
| 40 |
+echo -e "\t\t3. Run unit tests using: $GREEN make test CONTAINER=$HOSTNAME$NC" |
|
| 41 |
+echo |
|
| 42 |
+echo -e "\tb. To test your changes INSIDE CONTAINER:" |
|
| 43 |
+echo -e "\t\t1. Run a terminal in the container using: $GREEN docker exec -it $HOSTNAME /bin/bash$NC" |
|
| 44 |
+echo -e "\t\t2. Add your test code in /usr/src/app/$testDir/test.php" |
|
| 45 |
+echo -e "\t\t3. Run your test file using: $GREEN make run$NC" |
|
| 46 |
+echo -e "\t\t4. Run unit tests using: $GREEN make test$NC" |
|
| 47 |
+ |
|
| 48 |
+## To keep the container running post setup |
|
| 49 |
+/bin/bash |
|
| 0 | 50 |
\ No newline at end of file |