wp scaffold theme-tests

Generates files needed for running PHPUnit tests in a theme.

Generated Files

  • phpunit.xml.dist – PHPUnit configuration
  • .circleci/config.yml – CircleCI configuration (or other CI via --ci)
  • bin/install-wp-tests.sh – WordPress test suite and database setup
  • tests/bootstrap.php – Makes current theme active when running tests
  • tests/test-sample.php – Sample file with actual tests
  • .phpcs.xml.dist – PHP_CodeSniffer rules

Learn more from the plugin unit tests documentation.

Environment

The tests/bootstrap.php file looks for the WP_TESTS_DIR environment variable.

Synopsis

wp scaffold theme-tests [<theme>] [--dir=<dirname>] [--ci=<provider>] [--force]

Options

[]
The name of the theme to generate test files for.

[–dir=]
Generate test files for a non-standard theme path. If no theme slug is specified, the directory name is used.

[–ci=]
Choose a configuration file for a continuous integration provider.

  • default: circle
  • options: circle, gitlab, bitbucket, github

[–force]
Overwrite files that already exist.

Examples

# Generate unit test files for theme 'twentysixteenchild'
$ wp scaffold theme-tests twentysixteenchild
Success: Created test files.