
Moodle phpunit testing
Guides an agent to write, run and debug PHPUnit tests for Moodle plugins and core
Moodle phpunit testing is an open-source agent skill for developer tools. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.
- Scripts
- None
- Platforms
- Claude Code, Codex, Cursor
- GitHub stars
- 44
- Last commit
- License
- MIT
- Listing updated
Similar skills
About Moodle phpunit testing
This skill gives an agent working knowledge of Moodle's PHPUnit harness. It covers the standard test class layout built on the advanced test case base, using resetAfterTest for database isolation, and the conventions Moodle's coding style expects such as final classes and covers annotations.
The guidance walks through setting up the test environment with the Moodle init script, writing plugin data generators, and testing events, emails, scheduled and ad-hoc tasks, and external web service functions including return value cleaning. It also explains how to mock the database when integration tests are not practical, and lists common mistakes with their fixes.
The skill is a single SKILL.md with no bundled scripts. It expects a Moodle codebase with the phpunit tool installed and a configured test database, and it is aimed at PHP developers working on Moodle plugins or core.
When your agent uses it
Use when writing, running, or debugging PHPUnit tests for Moodle plugins or core. Covers advanced_testcase, resetAfterTest, data generators, mocking $DB, testing events/tasks/external functions, and CLI invocation.
From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.
What it can access
From a static check of its 1 file (7 KB) on GitHub on 3 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.
Check another skill before you install it.
Install
This skill ships in the moodle-dev plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):
/plugin marketplace add SaadRahman01/claude-moodle-dev
/plugin install moodle-dev@moodle-devOr copy only this skill to ~/.claude/skills/moodle-phpunit-testing:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/moodle-phpunit-testing &&
cp -R "$tmp/skills/moodle-phpunit-testing" ~/.claude/skills/moodle-phpunit-testing &&
rm -rf "$tmp"For one project only, put the folder in .claude/skills/moodle-phpunit-testing inside it instead.
Copy the skill folder to ~/.agents/skills/moodle-phpunit-testing to use it in every repository:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/moodle-phpunit-testing &&
cp -R "$tmp/skills/moodle-phpunit-testing" ~/.agents/skills/moodle-phpunit-testing &&
rm -rf "$tmp"For one repository only, put the folder in .agents/skills/moodle-phpunit-testing inside it instead.
Copy the skill folder to ~/.cursor/skills/moodle-phpunit-testing to use it in every project:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/moodle-phpunit-testing &&
cp -R "$tmp/skills/moodle-phpunit-testing" ~/.cursor/skills/moodle-phpunit-testing &&
rm -rf "$tmp"For one project only, put the folder in .cursor/skills/moodle-phpunit-testing inside it instead.
Run in a terminal (add --scope workspace to install it for the current workspace only):
gemini skills install https://github.com/SaadRahman01/claude-moodle-dev.git --path skills/moodle-phpunit-testingOr copy the folder to ~/.gemini/skills/moodle-phpunit-testing yourself.
For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/moodle-phpunit-testing:
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/moodle-phpunit-testing &&
cp -R "$tmp/skills/moodle-phpunit-testing" ~/.copilot/skills/moodle-phpunit-testing &&
rm -rf "$tmp"For one project only, put the folder in .github/skills/moodle-phpunit-testing inside it instead.
Get the folder:
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.gitThen copy claude-moodle-dev/skills/moodle-phpunit-testing into your agent's skills folder as moodle-phpunit-testing. Agents that support SKILL.md read one folder per skill.
What it does
- Test class structure
- Covers the file naming, base class, annotations and method signatures Moodle expects for test classes.
- Data generators
- Shows how to add a plugin generator and call it from tests to create fixtures.
- Event and task testing
- Explains capturing events and emails and running scheduled and ad-hoc tasks inside tests.
- External function testing
- Describes testing web service functions and validating return values against their schema.
- Running and debugging suites
- Lists CLI commands for running suites, files, single methods, groups and coverage, plus fixes for database errors.
Good for
- Write PHPUnit tests for a new Moodle local plugin
- Debug a 'Database was modified' failure in a test
- Add a data generator for plugin fixtures
- Test an external web service function's return values
- Set up PHPUnit in a GitHub Actions workflow for Moodle
Moodle phpunit testing FAQ
What does Moodle phpunit testing need to be useful?
It assumes a Moodle codebase with the PHPUnit tool initialised via admin/tool/phpunit/cli/init.php and a separate test database configured in config.php.
Does Moodle phpunit testing cover Behat acceptance tests?
No. The skill says to use a separate moodle-behat-testing skill for Behat acceptance tests.
Does Moodle phpunit testing modify phpunit.xml?
It advises against hand-editing phpunit.xml and says it is regenerated by the init script.
How do I install Moodle phpunit testing in Claude Code?
Copy the skill folder from GitHub to ~/.claude/skills/moodle-phpunit-testing to use it in all your projects, or to .claude/skills/moodle-phpunit-testing in one project. Or install the moodle-dev plugin, which includes it: /plugin marketplace add SaadRahman01/claude-moodle-dev, then /plugin install moodle-dev@moodle-dev.
Does Moodle phpunit testing run scripts?
No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.
Which AI agents can use Moodle phpunit testing?
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.
What are the best alternatives to Moodle phpunit testing?
The closest alternatives to Moodle phpunit testing are Phpunit skill, Moodle behat testing, Moodle plugin development, Moodle performance and Unittest skill.
Where this comes from
- Description: from the skill's own SKILL.md.
More from SaadRahman01/claude-moodle-dev

Guides building and calling Moodle web services: external functions, tokens and schemas
- Open source
- 44 GitHub stars
- Developer tools

Guides agents to build Moodle plugin UI that meets WCAG 2.1 AA accessibility rules
- Open source
- 44 GitHub stars
- Developer tools

Guides writing Moodle browser JavaScript as AMD modules with grunt builds and tests
- Open source
- 44 GitHub stars
- Developer tools

Guides writing and running Behat acceptance tests for Moodle plugins
- Open source
- 44 GitHub stars
- Developer tools

Guides building and migrating Moodle 4.4+ hook classes, listeners and tests
- Open source
- 44 GitHub stars
- Developer tools

Guides building Moodle plugin UI that renders inside the Moodle Mobile app
- Open source
- 44 GitHub stars
- Developer tools


