From caae5c3595193c7a4c1f2819d62001bc9f3e2818 Mon Sep 17 00:00:00 2001
From: tyler36 <7234392+tyler36@users.noreply.github.com>
Date: Fri, 10 Nov 2023 08:15:16 +0000
Subject: [PATCH] add profiling test
---
tests/test.bats | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/tests/test.bats b/tests/test.bats
index ddff8ea..1402d90 100644
--- a/tests/test.bats
+++ b/tests/test.bats
@@ -24,6 +24,19 @@ health_checks() {
ddev exec "curl -s xhgui:80" | grep "XHGui - Run list"
}
+# This tests the collector function works.
+collector_checks() {
+ # Turn on the collector
+ ddev xhprof
+ # Ensure there's no profiling data link
+ ddev exec "curl -s xhgui:80" | grep -v ''
+
+ # Profile site
+ ddev exec "curl -s web:80" | grep "Demo website"
+ # Ensure there a profiling data link
+ ddev exec "curl -s xhgui:80" | grep ''
+}
+
@test "install from directory" {
set -eu -o pipefail
cd ${TESTDIR}
@@ -45,3 +58,26 @@ health_checks() {
# Check service works
health_checks
}
+
+@test "a site can be profiled" {
+ set -eu -o pipefail
+ cd ${TESTDIR}
+
+ # Create test site
+ echo "# Create a demo website at ${TESTDIR}" >&3
+ ddev composer require perftools/php-profiler
+ ddev composer install
+ mkdir -p ${TESTDIR}/public
+ echo "${TESTDIR}/public/index.php
+
+ echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
+ ddev get ${DIR}
+ ddev restart
+
+ # Check service works
+ health_checks
+ collector_checks
+}