moodle-phpunit-testing

moodle-phpunit-testing is a skill for Claude Code from SaadRahman01/claude-moodle-dev. It costs 50 tokens per session (1,748 once invoked), scanned A, original, MIT.

A guide to PHPUnit testing for Moodle, the learning platform, including Moodle's own test setup and tools.

In plain words
What is it for?
Writing, running, and debugging tests for Moodle plugins or core code, including test data generators and continuous-integration setup.
Why use it?
It helps developers write isolated tests and diagnose failures involving databases, events, scheduled tasks, and external functions.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the moodle-dev plugin — 13 skills, 8 commands, 2 agents shipped together

Good fit Writing, running, and debugging tests for Moodle plugins or core code, including test data generators and continuous-integration setup.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/saadrahman01/claude-moodle-dev/moodle-phpunit-testing
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add SaadRahman01/claude-moodle-dev --skill moodle-phpunit-testing
Clone the repo
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev

Made for: Claude Code.

Or install moodle-dev, the plugin that ships this one along with the rest of its 13 skills, 8 commands, 2 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for moodle-phpunit-testing

README.md
[![agentmods](https://agentmods.dev/badge/skills/saadrahman01/claude-moodle-dev/moodle-phpunit-testing/github.svg)](https://agentmods.dev/skills/saadrahman01/claude-moodle-dev/moodle-phpunit-testing)
Your own site
<a href="https://agentmods.dev/skills/saadrahman01/claude-moodle-dev/moodle-phpunit-testing"><img src="https://agentmods.dev/badge/skills/saadrahman01/claude-moodle-dev/moodle-phpunit-testing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for moodle-phpunit-testing

Your own site · 80×15
<a href="https://agentmods.dev/skills/saadrahman01/claude-moodle-dev/moodle-phpunit-testing"><img src="https://agentmods.dev/badge/skills/saadrahman01/claude-moodle-dev/moodle-phpunit-testing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,748 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00050 $0.01748
Opus 5.5 $0.00020 $0.00699
Sonnet 5.5 $0.00010 $0.00350
Haiku 4.5 $0.00005 $0.00175

Measured 2mo ago against content hash 9e5ad11caabb, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

moodle-phpunit-testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/moodle-phpunit-testing/SKILL.md · 234 lines

How it starts

The opening of the file, as written. The whole thing — 234 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Moodle PHPUnit Testing

Overview

Moodle ships its own PHPUnit harness with test bootstrap, transactional resets, and data generators. Tests live in <plugin>/tests/<thing>_test.php and extend advanced_testcase. Never call parent::setUp() for DB cleanup — use $this->resetAfterTest().

When to Use

  • Writing unit/integration tests for any Moodle plugin or core API
  • Debugging test failures (Database was modified errors, isolation issues)
  • Adding a data generator (tests/generator/lib.php)
  • Testing events, scheduled tasks, ad-hoc tasks, external functions
  • Setting up CI for Moodle test suites

Skip when: writing Behat acceptance tests (use moodle-behat-testing).

First-time setup

php admin/tool/phpunit/cli/init.php       # writes phpunit.xml + initializes test DB
vendor/bin/phpunit --testsuite local_example_testsuite

phpunit.xml is regenerated by init.php — never hand-edit. Re-run after installing a new plugin.

Test class skeleton

<?php
namespace local_example;
defined('MOODLE_INTERNAL') || die();

/**
 * @group local_example
 * @covers \local_example\manager
 */
final class manager_test extends \advanced_testcase {

    public function test_create_item(): void {
        $this->resetAfterTest();
        $generator = self::getDataGenerator();
        $course = $generator->create_course();
        $user = $generator->create_user();

        $manager = new manager();
        $id = $manager->create_item($course->id, $user->id, 'hello');

        global $DB;
        $row = $DB->get_record('local_example_items', ['id' => $id], '*', MUST_EXIST);
        $this->assertSame('hello', $row->name);
    }
}

Key rules:

  • File name: <thing>_test.php, class: <thing>_test
  • final class (Moodle policy since 4.2)
  • @covers annotation required by Moodle CS
  • @group <component> enables --group filtering
  • void return type on test methods, : void on setUp
  • self:: (not $this->) for static methods like getDataGenerator()

Read the full file on GitHub · 234 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 234 lines · 50 tokens per session scan A 9e5ad11caabb

Subscribe to this mod's changes

moodle-phpunit-testing is a skill published in the GitHub repository SaadRahman01/claude-moodle-dev (42 stars, last pushed 4mo ago), licensed MIT. It adds 50 tokens to every session and 1,748 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

architecture-patterns

Architecture validation and patterns for clean architecture, backend structure enforcement, project structure validation, test standards, and context-aware sizing. Use when designing system boundaries, enforcing layered architecture, validating project structure, defining test standards, or choosing the right…

yonatangross/orchestkit · 56 tokens

testing-llm

LLM and AI testing patterns — mock responses, evaluation with DeepEval/RAGAS, structured output validation, and agentic test patterns (generator, healer, planner). Use when testing AI features, validating LLM outputs, or building evaluation pipelines.

yonatangross/orchestkit · 55 tokens

testing-patterns

Redirect — testing-patterns was split into 5 focused sub-skills. Use when looking for testing-patterns, writing tests, or test automation. Redirects to testing-unit, testing-e2e, testing-integration, testing-llm, or testing-perf.

yonatangross/orchestkit · 59 tokens

ship-feature

End-to-end feature delivery — implement a feature, verify builds/tests pass, open a fully-filled draft PR, then automatically push every feedback round and review iteration to the same PR. Use when the user asks to implement or build a feature, fix-and-ship a change, or iterate on an existing feature PR.

classroomio/classroomio · 66 tokens

generate-tests

Use when the user asks to generate, create, write, or add unit tests for existing code, or to cover a class, method, or file with tests — including Java targets using JUnit 5, Mockito, or AssertJ. Not for analysis-only requests that stop at listing test cases.

mavka-ai/unit-tests-skills · 63 tokens

lab-forge

Executable teaching-artifact builder for STEM professors — pipeline Stage 2 extension. 5-agent team that builds lab and programming assignments as working packages: per-student synthetic datasets with planted, recoverable ground truth, starter-code scaffolds that run as shipped, autograders with visible/hidden test…

YujxZJCN/teaching-skills · 142 tokens