testing

Guides writing PHPUnit, Jest, and Cypress tests for OrangeHRM plugins.

Updated Jul 23, 2026
One-click install
npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill testing-snow-gift111
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone/tree/main/.agents/skills/testing
Command: npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill testing-snow-gift111

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? OrangeHRM has four distinct test layers (PHPUnit per-plugin testsuites, Jest frontend tests, Cypress E2E, and CI smoke tests) with specific base classes, YAML fixture conventions, and a dedicated test database lifecycle. This Skill removes the guesswork of choosing the right test base class, setting up the test DB, and following the codebase's integration-style testing conventions. ## Core Features & Use Cases - Test base class selection: Explains when to use TestCase, KernelTestCase, EntityTestCase, EndpointTestCase, or EndpointIntegrationTestCase based on what the code under test needs. - Test DB lifecycle: Documents the instance:create-test-db command that builds a migrated, fixture-seeded MySQL database dumped for fast per-test restore. - YAML fixture pattern: Covers per-plugin test/fixtures/<DaoName>.yml files loaded via TestDataService::populate() in setUp(), including the full-table-truncate semantics. - Use Case: You added a new DAO method and need a test. Follow the DAO test recipe: create a YAML fixture, extend TestCase, populate the fixture in setUp(), and run it with ./src/vendor/bin/phpunit --testsuite <Plugin>. ## Quick Start Ask the assistant to write a PHPUnit DAO test with a YAML fixture for your new OrangeHRM plugin DAO method.

Frequently Asked Questions about testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a PHPUnit DAO test in OrangeHRM?

Create a test class extending OrangeHRM\Tests\Util\TestCase in the plugin's test/Dao directory, instantiate the DAO with new, and load a YAML fixture via TestDataService::populate() in setUp(). Run it with ./src/vendor/bin/phpunit --testsuite <Plugin>.

How do I set up the OrangeHRM test database?

Run php devTools/core/console.php instance:create-test-db -p root --dump-options=--ssl=0 once before testing. It creates a fresh MySQL database, runs all migrations, seeds core fixtures, and dumps the result for fast restore. Re-run it whenever migrations change the schema.

Which test base class should I use in OrangeHRM?

Use TestCase for plain unit and DAO tests, KernelTestCase when code needs the DI container or framework boot, EntityTestCase for entity getter/setter checks, and EndpointTestCase or EndpointIntegrationTestCase for REST API endpoint tests with request mocking.

Why does my OrangeHRM test pass locally but fail in CI?

Common causes are database version differences between MySQL and MariaDB in the CI matrix, strict error conversion in phpunit.xml turning notices into failures, missing fixture population in setUp(), and timezone differences since CI runs in UTC.

Does OrangeHRM mock the database in unit tests?

No, the codebase deliberately tests DAOs against a real test database instead of mocking Doctrine's EntityManager. Service tests may mock DAOs via the setXxxDao() setter, but database access itself is always integration-style.

How do I run frontend Jest tests in OrangeHRM?

Run yarn test:unit inside src/client to execute all Jest tests, or pass a file path for a single spec. Tests live in __tests__ directories beside the source files and mostly cover util functions rather than Vue components.