Run tests, linting, quality checks, and manage the wp-env development environment for Woodev Framework. Use when running tests, fixing code style, managing the Docker environment, or following the development workflow.
Recursos
5Instal·la
npx skillscat add kalbac/woodev-plugin-framework/woodev-framework-dev-cycle Instal·la des del registre de SkillsCat.
Woodev Framework Development Cycle
When to Use This Skill
ALWAYS invoke this skill when:
- Starting or stopping the local development environment
- Running linting on PHP or Markdown files
- Running PHPUnit tests (Unit and Integration)
- Fixing code style issues
- Writing commit messages in Conventional Commits format
- Troubleshooting wp-env or Docker issues
DO NOT use this skill for:
- Git operations (use
woodev-framework-git) - Writing PHP code (use
woodev-framework-backend-dev) - Code review (use
woodev-framework-code-review)
Instructions
- Environment management -- start/stop wp-env, troubleshoot Docker
- Running tests -- see running-tests.md for PHPUnit commands
- Testing guide -- see testing-guide.md for Brain Monkey/Mockery patterns and test writing conventions
- Code quality -- see code-quality.md for linting and code style fixes
- PHP linting patterns -- see php-linting-patterns.md for common PHP linting issues and fixes
- Markdown linting -- see markdown-linting.md for markdown file linting and formatting
Environment Configuration
The project uses @wordpress/env (wp-env) to run WordPress + WooCommerce in Docker.
.wp-env.json
{
"core": null,
"phpVersion": "7.4",
"plugins": ["https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip"],
"mappings": {
"woodev-framework": ".",
"wp-content/plugins/woodev-test-plugin": "./tests/_fixtures/woodev-test-plugin",
"wp-content/plugins/woodev-test-plugin/woodev": "./woodev",
"wp-content/plugins/woodev-test-payment-gateway": "./tests/_fixtures/woodev-test-payment-gateway",
"wp-content/plugins/woodev-test-payment-gateway/woodev": "./woodev",
"wp-content/plugins/woodev-test-shipping-method": "./tests/_fixtures/woodev-test-shipping-method",
"wp-content/plugins/woodev-test-shipping-method/woodev": "./woodev"
},
"env": {
"tests": { "config": { "WP_DEBUG": true, "WP_DEBUG_LOG": true, "SCRIPT_DEBUG": true } },
"development": { "config": { "WP_DEBUG": true, "SCRIPT_DEBUG": true } }
}
}Key points:
core: null-- uses latest stable WordPress from WordPress.orgphpVersion: "7.4"-- matches compatibility requirements (platform target is PHP 8.1)- WooCommerce installed from wordpress.org ZIP (latest stable)
- Fixture plugins mapped individually; each gets the shared
woodev/directory mapped in - Separate
testsanddevelopmentenvironment configs
wp-env Commands
# Install wp-env globally (one-time)
npm install -g @wordpress/env
# Start environment
npx wp-env start
# Stop environment
npx wp-env stop
# Check status / URLs
npx wp-env status
# Clean and rebuild
npx wp-env destroy && npx wp-env start
# Run WP-CLI inside the container
npx wp-env run cli "wp plugin list"
# Check PHP version
npx wp-env run cli "php -v"Default URLs:
- Development:
http://localhost:8973(port from the gitignored.wp-env.override.json) (admin:admin/password) - Tests:
http://localhost:8889
Development Workflow
1. Start wp-env --> npx wp-env start
2. Make code changes
3. Run linting --> composer phpcs
4. Fix linting issues --> composer phpcbf
5. Run tests --> composer test:unit / composer test:integration
6. Commit changes --> Conventional Commits format
7. Stop environment --> npx wp-env stop (optional)IMPORTANT: Always ensure wp-env is running before running integration tests.
Pre-commit Checks
# Check all (PHPCS + PHPStan + Unit Tests)
composer check
# Lint (PHPCS)
composer phpcs
# Fix auto-fixable issues
composer phpcbf
# Lint specific file
composer phpcs -- woodev/path/to/File.php
# Static analysis
composer phpstanNEVER commit PHP changes without passing linting.
Code Quality Commands
PHP Linting
Linting does NOT require wp-env to be running:
composer phpcs # check all
composer phpcbf # auto-fix
composer phpcs -- woodev/path/to/File.php # specific filePHPStan
composer phpstan
composer exec -- phpstan analyse woodev/path/to/File.php --memory-limit=2GMarkdown Linting
npx markdownlint "**/*.md"
npx markdownlint --fix "**/*.md"Testing
Three Test Levels
Unit Tests (Brain Monkey, no WordPress):
composer test:unitIntegration Tests (WP_UnitTestCase + wp-env):
composer test:integrationFixture Plugins in
tests/_fixtures/:woodev-test-plugin(general)woodev-test-payment-gateway(payment gateway)woodev-test-shipping-method(shipping method)
Running Specific Tests
# Specific test file
./vendor/bin/phpunit tests/unit/BootstrapTest.php
# Filter by class or method name
TEST_SUITE=unit ./vendor/bin/phpunit --filter BootstrapTestConventional Commits
All commits MUST follow Conventional Commits format for git-cliff CHANGELOG generation.
{type}: {description}
[optional body]
[optional footer]| Type | Description | CHANGELOG Section |
|---|---|---|
feat: |
New feature | Features |
fix: |
Bug fix | Bug Fixes |
docs: |
Documentation | Documentation |
refactor: |
Code refactoring | Refactoring |
test: |
Tests | Tests |
chore: |
Auxiliary tasks | Chores |
ci: |
CI/CD changes | CI/CD |
Breaking changes: add ! after type (feat!:) and BREAKING CHANGE: footer.
Troubleshooting
wp-env Won't Start
- Ensure Docker Desktop is running:
docker ps - Check ports 8888/8889 are free
- Destroy and rebuild:
npx wp-env destroy && npx wp-env start - Update wp-env:
npm install -g @wordpress/env
Tests Fail Unexpectedly
- Ensure wp-env is running:
npx wp-env status - Clean database:
npx wp-env clean database - Rebuild:
npx wp-env destroy && npx wp-env start - Check test isolation -- tests must not depend on each other
Linting Issues
- File encoding must be UTF-8
- Line endings must be Unix (LF)
- Indentation must use tabs
- Run verbose:
composer phpcs -- -v woodev/path/to/File.php
Key Principles
- Always run linting after making changes to verify code style
- Fix linting errors for code in your current branch only
- Never lint the entire codebase -- only changed or specific files
- Always start wp-env before integration tests
- Commits MUST follow Conventional Commits format