testing-phpunit

testing-phpunit is a skill for Claude Code, Codex from caravanglory/magehub. It costs 32 tokens per session (2,474 once invoked), scanned A, original, MIT.

A PHPUnit testing guide for isolated Magento 2 PHP classes. PHPUnit is a tool for running automated tests, and isolated tests check one class without starting the full Magento application.

In plain words
What is it for?
Use it to write unit tests with mocks, assertions, data providers, and exception checks for Magento service logic.
Why use it?
It helps avoid slow, fragile tests that depend on Magento startup, databases, or real framework services.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to write unit tests with mocks, assertions, data providers, and exception checks for Magento service logic.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/caravanglory/magehub/testing-phpunit
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 caravanglory/magehub --skill testing-phpunit
Clone the repo
git clone --depth 1 https://github.com/caravanglory/magehub

Made for: Claude Code, Codex.

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 testing-phpunit

README.md
[![agentmods](https://agentmods.dev/badge/skills/caravanglory/magehub/testing-phpunit/github.svg)](https://agentmods.dev/skills/caravanglory/magehub/testing-phpunit)
Your own site
<a href="https://agentmods.dev/skills/caravanglory/magehub/testing-phpunit"><img src="https://agentmods.dev/badge/skills/caravanglory/magehub/testing-phpunit/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 testing-phpunit

Your own site · 80×15
<a href="https://agentmods.dev/skills/caravanglory/magehub/testing-phpunit"><img src="https://agentmods.dev/badge/skills/caravanglory/magehub/testing-phpunit.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,474 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.00032 $0.02474
Opus 5.5 $0.00013 $0.00990
Sonnet 5.5 $0.00006 $0.00495
Haiku 4.5 $0.00003 $0.00247

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

Security

Grade A, and why

testing-phpunit 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/testing/testing-phpunit/SKILL.md · 331 lines

How it starts

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

PHPUnit Unit Tests

Activation

Use When
  • The task is to write or update Magento PHPUnit unit tests for isolated PHP classes without framework bootstrap.
  • The task mentions Test/Unit, PHPUnit mocks, data providers, exception assertions, or testing service logic.
Do Not Use When
  • The behavior requires Magento integration tests, database fixtures, web API functional tests, or full ObjectManager bootstrap.
  • The task is only to manually smoke-test UI behavior.
Required Inputs
  • Class under test, constructor dependencies, observable behavior, edge cases, and the project PHPUnit version/config path.
  • Whether collaborators should be mocks, stubs, real value objects, or in-memory fakes.

Workflow

  1. Read the production class and nearby tests before deciding the test shape.
  2. Instantiate the real class under test with mocks for direct dependencies only.
  3. Assert behavior, return values, state changes, exceptions, and meaningful collaborator side effects.
  4. Use data providers for repeated input matrices and keep test method names behavior-oriented.

Guardrails

  • Do not use ObjectManager, Magento bootstrap, database fixtures, or integration-test helpers in unit tests.
  • Do not mock the class under test.
  • Ask before refactoring production code solely to make tests pass when the behavior contract is unclear. (approval required)

Verification

  • Run the targeted PHPUnit test file or Test/Unit directory through the project environment wrapper.
  • Run a broader suite when shared service behavior or public APIs are touched.
  • Report skipped tests or unavailable PHPUnit config explicitly.

Output Contract

  • State test files added/updated, behaviors covered, mocks used, and exact PHPUnit command result.
  • Call out coverage gaps that remain outside unit-test scope.

Magento 2 Unit Test Strategy

Unit tests validate individual classes in isolation without the Magento framework, database, or object manager. They run in milliseconds and catch logic errors immediately. Place test classes in Test/Unit/ mirroring the production namespace.

Read the full file on GitHub · 331 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 331 lines · 32 tokens per session scan A 9fb84c03347e

Subscribe to this mod's changes

testing-phpunit is a skill published in the GitHub repository caravanglory/magehub (2 stars, last pushed 4mo ago), licensed MIT. It adds 32 tokens to every session and 2,474 once invoked, about $0.0001 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-31.

Related

Other skills, from other repositories

Codeception Testing

Expert-level Codeception testing skill for PHP applications. Covers acceptance, functional, and unit testing with the Actor pattern, BDD-style syntax, Page Objects, API testing, and database helpers.

PramodDutta/qaskills · 42 tokens

craft-pest

Testing Craft CMS 5 plugins and modules with Pest — test isolation, database safety, and the markhuot/craft-pest-core harness. ALWAYS load when writing, running, fixing, or reviewing tests for a Craft plugin or module, and whenever a suite touches a real Craft install. Covers why rollback is opt-in, tests/Pest.php +…

michtio/craftcms-claude-skills · 175 tokens

phpunit-unit-test-reviewing

Internal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent.

shopwareLabs/ai-coding-tools · 31 tokens

phpunit-unit-test-writing

Use this skill when the user asks to write, generate, create, or add PHPUnit unit tests for a Shopware 6 source class — phrases like "write unit tests for X", "generate tests for ClassName", "create PHPUnit tests", "add test coverage", "test this class", "cover this with tests", "I need tests for", "unit test this"…

shopwareLabs/ai-coding-tools · 187 tokens

noerd-testing

Use this skill when writing or fixing tests for code built on noerd/noerd: Pest feature tests for list/detail/page/modal Livewire components, store and validation tests of YAML-driven forms (validDetailPayload, requiredLayoutFields), route-vs-component modal behaviour (registerTestLivewireRoute), install/update…

noerd-dev/noerd · 121 tokens

php-testing

Use when writing/configuring tests on a non-Laravel PHP project — PHPUnit vs Pest. Do NOT use for Laravel test helpers or quality tooling (php-quality-tooling).

fusengine/agents · 38 tokens