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.
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-devWrote 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.
[](https://agentmods.dev/rules/saadrahman01/claude-moodle-dev/moodle-phpunit-testing)<a href="https://agentmods.dev/rules/saadrahman01/claude-moodle-dev/moodle-phpunit-testing"><img src="https://agentmods.dev/badge/rules/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.
<a href="https://agentmods.dev/rules/saadrahman01/claude-moodle-dev/moodle-phpunit-testing"><img src="https://agentmods.dev/badge/rules/saadrahman01/claude-moodle-dev/moodle-phpunit-testing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.01764 |
| Opus 5.5 | $0.00000 | $0.00706 |
| Sonnet 5.5 | $0.00000 | $0.00353 |
| Haiku 4.5 | $0.00000 | $0.00176 |
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 1mo 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.
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 modifiederrors, 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)@coversannotation required by Moodle CS@group <component>enables--groupfilteringvoidreturn type on test methods,: voidonsetUpself::(not$this->) for static methods likegetDataGenerator()
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.
- 1mo ago First seen · 234 lines · 0 tokens per session scan A d928361eb92e
moodle-phpunit-testing is a cursor rule published in the GitHub repository SaadRahman01/claude-moodle-dev (40 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,764 tokens. 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.
Other cursor rules, from other repositories
standard-backend-tests-redaction
This standard establishes best practices for writing backend tests using Jest in the Packmind monorepo. It focuses on clarity, maintainability, and consistency across test suites by emphasizing behavi... .
testing
Agent engineering standards — Testing (TR-TEST-001, TR-TEST-002, TR-TEST-004, TR-TEST-005, TR-TEST-006, TR-TEST-007).
rules
Auto-generated from shared/skills/. Do not edit directly. Regenerate with: ./scripts/generate.sh.
use-contract-ir-factories
Use factory functions for creating ContractIR objects instead of manual object creation.
gonavi-go
A Go coding rule set for the GoNavi repository, based on common Go style guides and the project's own conventions. It covers file structure, errors, context, concurrency, logging, and tests.
workflow-level3
Defines the standard workflow for Level 3 (Intermediate Feature) tasks, guiding through comprehensive planning, targeted creative design, structured implementation, detailed reflection, and feature-specific archiving.