Testing Moodle Plugins That Send Data to Remote Endpoints
A practical testing guide for Moodle plugins that transmit data to remote endpoints, including fixtures, interception, and repeatable validation.
Summary: This guide shows how to test a Moodle plugin that sends data to a remote endpoint by wiring it to a controlled fake receiver first.
This is the fastest practical way to test event-driven outbound integrations such as grade pushes or webhook-style plugin callbacks without depending on a real external service.
Step 1: Create a fake local endpoint
The SOP uses a minimal local PHP endpoint that prints incoming request data. The point is not realism. The point is visibility.
Typical setup:
mkdir -p ~/php/wstest
cd ~/php/wstest
php -S 127.0.0.1:8000
Point the local test script at that directory and watch the incoming requests in real time.
Step 2: Repoint the plugin to the local endpoint
Change the plugin configuration so it sends data to the local receiver. Before debugging the network call, confirm that:
- the event observer is registered
- the observer method exists and is namespaced correctly
- the endpoint URL is permitted by Moodle’s HTTP security settings
Many “nothing was sent” problems are really event-registration problems.
Step 3: Trigger the real Moodle action
Perform the exact action that should emit the request, such as grading an assignment. Watch both the local endpoint output and the Moodle logs.
Step 4: Debug from the inside out
If the receiver never sees the request, check:
- whether the event fired
- whether the observer ran
- whether the plugin swallowed an exception
- whether the request was blocked by cURL host restrictions
Do not jump straight to transport debugging until you know the Moodle-side event path actually executed.
Solin specializes in Moodle plugin development, integration testing, and debugging of event-driven workflows. Need help? Contact us.
Solin builds and tests Moodle integrations that exchange data with external systems under real operational constraints. Need help? Contact us.
Contact us