From 67087bbda87db7ff95c205c8f72efbadfd3b4261 Mon Sep 17 00:00:00 2001
From: Artem Baranovskyi <artem.baranovsky1980@gmail.com>
Date: Fri, 20 Sep 2024 09:48:40 +0300
Subject: [PATCH] Auto phpunit testsuite config added.

---
 install_moodle.sh | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/install_moodle.sh b/install_moodle.sh
index a5fb416..f858f68 100755
--- a/install_moodle.sh
+++ b/install_moodle.sh
@@ -66,6 +66,23 @@ docker-compose exec moodle bash -c "
 # Next, configure PHPUnit for Moodle:
  docker-compose exec moodle php admin/tool/phpunit/cli/init.php
 
+# Define the path to the phpunit.xml file
+PHPUNIT_XML_PATH="/var/www/html/moodle/phpunit.xml"
+
+# Define the content to insert for your plugin's test suite
+TEST_SUITE_ENTRY='<testsuite name="Unit Tests">
+    <directory>local/asystgrade/tests</directory>
+</testsuite>'
+
+# Check if the plugin suite is already defined in phpunit.xml
+if grep -q "local/asystgrade/tests" "$PHPUNIT_XML_PATH"; then
+    echo "Test suite for asystgrade plugin already exists in phpunit.xml."
+else
+    # Use sed to insert the test suite entry right before @plugin_suites_end@
+    sed -i "/@plugin_suites_end@/i $TEST_SUITE_ENTRY" "$PHPUNIT_XML_PATH"
+    echo "Test suite for asystgrade plugin added to phpunit.xml."
+fi
+
  # Ensure correct ownership and permissions after installation
  docker-compose exec moodle chown -R www-data:www-data ${MOODLE_BASE_DIR}
  docker-compose exec moodle chmod -R 755 ${MOODLE_BASE_DIR}
-- 
GitLab