| name | dokan-dev-cycle |
| description | Run tests, linting, and quality checks for Dokan development. Use when running tests, fixing code style, building assets, or following the development workflow. |
Dokan Development Cycle
This skill provides guidance for the Dokan Lite development workflow including building, testing, linting, and CI.
Build Commands
npm run start
npm run start:hot
npm run build
npm run makepot
npm run release
PHP Linting (PHPCS)
composer phpcs
composer phpcbf
PHPCS config is in phpcs.xml.dist. It scans includes/ only (excludes assets/, src/, lib/, vendor/, tests/).
CI behavior: GitHub Actions runs PHPCS only on changed files in PRs (not the entire codebase).
JavaScript/CSS Linting
npm run lint:js
npm run lint:css
npm run format
PHPUnit Tests
npm run phpunit
npm run phpunit:coverage
npm run test:phpunit
Environment
npm run env:start
npm run env:stop
Writing PHP Tests
All tests extend DokanTestCase (tests/php/src/DokanTestCase.php):
namespace WeDevs\Dokan\Test\MyDomain;
use WeDevs\Dokan\Test\DokanTestCase;
class MyServiceTest extends DokanTestCase {
public function test_something() {
wp_set_current_user( $this->seller_id1 );
$response = $this->get_request( '/my-resource' );
$this->assertEquals( 200, $response->get_status() );
}
}
Available Test Helpers
Pre-created users (from DokanTestCase):
$this->admin_id — WordPress admin
$this->seller_id1, $this->seller_id2 — Vendor users
$this->customer_id — Customer user
REST request helpers:
$this->get_request( $route ) — GET
$this->post_request( $route, $body ) — POST
$this->put_request( $route, $body ) — PUT
$this->delete_request( $route ) — DELETE
Test Factories (tests/php/src/Factories/):
$this->factory()->seller->create() — Create vendor
$this->factory()->order->create() — Create order
$this->factory()->product->create() — Create product
$this->factory()->customer->create() — Create customer
$this->factory()->coupon->create() — Create coupon
$this->factory()->shipping->create() — Create shipping
Order helpers:
$this->create_multi_vendor_order() — Multi-vendor order
$this->create_single_vendor_order() — Single-vendor order
Custom assertions (tests/php/src/CustomAssertion/):
DBAssertionTrait — Database assertions
NestedArrayAssertionTrait — Nested array comparisons
Unit tests (no DB/REST)
Set $is_unit_test = true to skip REST server and database setup:
class MyUnitTest extends DokanTestCase {
protected $is_unit_test = true;
}
Playwright E2E Tests
Config: tests/pw/playwright.config.ts
npx playwright test
npx playwright test --grep @lite
npx playwright test --grep @pro
Test Tags
@lite — Lite plugin tests
@liteOnly — Lite-only features
@pro — Pro plugin tests
@serial — Must run sequentially
Page Object Model
70+ page objects in tests/pw/pages/. Follow the POM pattern:
test('admin can set commission', { tag: ['@lite', '@admin'] }, async () => {
await admin.navigateToCommissionPage();
});
E2E Utilities (tests/pw/utils/)
apiUtils.ts — REST API client
dbUtils.ts — Direct database access
testData.ts, payloads.ts — Test fixtures
helpers.ts — Common helpers
Development Workflow
- Make code changes
- Run
composer phpcs for PHP changes
- Run
npm run lint:js for JS/TS changes
- Run
npm run phpunit for unit tests
- Fix any issues (
composer phpcbf, manual fixes)
- Commit only after all checks pass
CI Pipeline (GitHub Actions)
phpcs.yml — Runs on PRs: PHPCS on changed files + PHPUnit
e2e_api_tests.yml — Playwright E2E/API tests
deploy.yml — Release deployment