Repository navigation
[i18n] Add pt-BR translation for PHPUnit testing guide #4587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| --- | ||
| title: Executando PHPUnit com o Playground CLI | ||
| slug: /guides/phpunit-testing | ||
| description: Execute testes PHPUnit para plugins e temas do WordPress usando o Playground CLI — sem precisar de banco de dados e com um ambiente limpo a cada execução. | ||
| sidebar_class_name: navbar-build-item | ||
| --- | ||
|
|
||
| <!-- | ||
| The [Playground CLI](/developers/local-development/wp-playground-cli) includes a `php` subcommand that runs PHP scripts directly inside the Playground environment. By mounting your plugin or theme into the Playground filesystem, you can run PHPUnit without a local database. Every run starts with a clean WordPress installation, so tests are fully isolated. | ||
| --> | ||
| O [Playground CLI](/developers/local-development/wp-playground-cli) inclui um subcomando `php` que executa scripts PHP diretamente no ambiente do Playground. Ao montar seu plugin ou tema no sistema de arquivos do Playground, você pode executar o PHPUnit sem a necessidade de um banco de dados local. Cada execução começa com uma instalação limpa do WordPress, garantindo que os testes fiquem totalmente isolados. | ||
|
|
||
| <div class="callout callout-info"> | ||
|
|
||
| <!-- | ||
| This guide assumes your plugin or theme has PHPUnit installed via Composer (`composer require --dev phpunit/phpunit`). The `vendor/bin/phpunit` path used below assumes a standard Composer setup. | ||
| --> | ||
| Este guia pressupõe que seu plugin ou tema tenha o PHPUnit instalado via Composer (`composer require --dev phpunit/phpunit`). O caminho `vendor/bin/phpunit` utilizado abaixo considera uma configuração padrão do Composer. | ||
|
|
||
| </div> | ||
|
|
||
| <!-- Running tests --> | ||
| ## Executando testes | ||
|
|
||
| <!-- | ||
| From your plugin or theme directory, run the following command. Replace `themes/THEME_NAME` with the path to your plugin or theme: | ||
| --> | ||
| A partir do diretório do seu plugin ou tema, execute o seguinte comando. Substitua `themes/THEME_NAME` pelo caminho para o seu plugin ou tema: | ||
|
|
||
| ```bash | ||
| npx @wp-playground/cli@latest php \ | ||
| --auto-mount \ | ||
| -- \ | ||
| /wordpress/wp-content/themes/THEME_NAME/vendor/bin/phpunit \ | ||
| -c /wordpress/wp-content/themes/THEME_NAME/phpunit.xml.dist | ||
| ``` | ||
|
|
||
| <!-- | ||
| The `--auto-mount` flag detects whether the current directory is a plugin, theme, or WordPress installation and mounts it at the correct path under `/wordpress/wp-content/`. The `--` separates CLI flags from arguments passed to the PHP interpreter, and you can pass any arguments supported by your PHPUnit configuration. | ||
| --> | ||
| A opção `--auto-mount` detecta se o diretório atual é um plugin, um tema ou uma instalação do WordPress e o monta no caminho correto dentro de `/wordpress/wp-content/`. O `--` separa as opções da CLI dos argumentos passados ao interpretador PHP, e você pode fornecer quaisquer argumentos compatíveis com sua configuração do PHPUnit. | ||
|
|
||
| <!-- For a plugin, the path would use `plugins/` instead: --> | ||
| Para um plugin, o caminho utilizaria `plugins/`: | ||
|
|
||
| ```bash | ||
| npx @wp-playground/cli@latest php \ | ||
| --auto-mount \ | ||
| -- \ | ||
| /wordpress/wp-content/plugins/MY_PLUGIN/vendor/bin/phpunit \ | ||
| -c /wordpress/wp-content/plugins/MY_PLUGIN/phpunit.xml.dist | ||
| ``` | ||
|
|
||
| <!-- You can also use `--mount` to explicitly map a local directory to a path inside the Playground filesystem: --> | ||
| Você também pode usar `--mount` para mapear explicitamente um diretório local a um caminho dentro do sistema de arquivos do Playground: | ||
|
|
||
| ```bash | ||
| npx @wp-playground/cli@latest php \ | ||
| --mount=.:/wordpress/wp-content/plugins/MY_PLUGIN \ | ||
| -- \ | ||
| /wordpress/wp-content/plugins/MY_PLUGIN/vendor/bin/phpunit \ | ||
| -c /wordpress/wp-content/plugins/MY_PLUGIN/phpunit.xml.dist | ||
| ``` | ||
|
|
||
| <!-- Choosing PHP and WordPress versions --> | ||
| ## Escolha de versões do PHP e do WordPress | ||
|
|
||
| <!-- Use the `--php` and `--wp` flags to test against specific versions: --> | ||
| Use as opções `--php` e `--wp` para executar testes com versões específicas: | ||
|
|
||
| ```bash | ||
| npx @wp-playground/cli@latest php \ | ||
| --auto-mount \ | ||
| --php=8.1 \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Match PHPUnit to the selected PHP version. The Composer command on Line 18 can install PHPUnit 12 on a PHP 8.3 host. PHPUnit 12 requires PHP 8.3, so this PHP 8.1 example will fail before running tests. (phpunit.de) Explain that readers must install a PHPUnit version compatible with the selected PHP version. Update the English guide too.
|
||
| --wp=6.5 \ | ||
| -- \ | ||
| /wordpress/wp-content/plugins/MY_PLUGIN/vendor/bin/phpunit \ | ||
| -c /wordpress/wp-content/plugins/MY_PLUGIN/phpunit.xml.dist | ||
| ``` | ||
|
|
||
| <!-- Supported PHP versions range from 7.4 to 8.5. For WordPress, you can use a specific version number, `latest`, `nightly`, or `beta`. --> | ||
| As versões suportadas do PHP variam de 7.4 a 8.5. Para o WordPress, você pode utilizar um número de versão específico, `latest`, `nightly` ou `beta`. | ||
|
|
||
| <!-- Next steps --> | ||
| ## Próximos passos | ||
|
|
||
| <!-- - [Playground CLI documentation](/developers/local-development/wp-playground-cli) — full CLI reference and configuration options --> | ||
| - [Documentação da CLI do Playground](/developers/local-development/wp-playground-cli) — referência completa da CLI e opções de configuração | ||
| <!-- - [E2E Testing with Playwright](/guides/e2e-testing-with-playwright) — browser-based end-to-end testing for WordPress plugins and themes --> | ||
| - [Testes E2E com Playwright](/guides/e2e-testing-with-playwright) — testes de ponta a ponta executados no navegador para plugins e temas do WordPress | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: WordPress/wordpress-playground
Length of output: 6303
Web query:
site:github.com/WordPress/wordpress-playground/issues/3783 WP_UnitTestCase bootstrap mounted files phpunitResult:
Script executed:
Repository: WordPress/wordpress-playground
Length of output: 29486
Script executed:
Repository: WordPress/wordpress-playground
Length of output: 22454
Script executed:
Repository: WordPress/wordpress-playground
Length of output: 27287
Script executed:
Repository: WordPress/wordpress-playground
Length of output: 11093
Script executed:
Repository: WordPress/wordpress-playground
Length of output: 8675
Document the WordPress integration-test bootstrap workaround.
If the WordPress test library is in the mounted project, its installer runs in a child that cannot see that mount. The integration-test bootstrap can then fail. Document the Playground-specific bootstrap workaround, including its test configuration.