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 +}