alleyinteractive/pest-plugin-wordpress
Composer 安装命令:
composer require --dev alleyinteractive/pest-plugin-wordpress
包简介
WordPress Pest Integration
README 文档
README
Supports integrating Pest with your WordPress code base through the Mantle Framework. Read about the Mantle Testing Framework here.
If you want to start testing your application with Pest, visit the main Pest Repository.
Pest was created by Nuno Maduro under the Sponsorware license. It got open-sourced and is now licensed under the MIT license.
Overview
The WordPress Pest Plugin allows WordPress to be tested using the Pest testing framework. Tests can be written in a very simple manner to 'bring the joy of testing to PHP'.
Getting Started
The WordPress Pest Plugin does not require the Mantle Framework to be used on your site (though having the framework greatly enhances your ability to use Pest).
Install the WordPress plugin via the Composer package manager:
composer require alleyinteractive/pest-plugin-wordpress --dev
Setting up Pest
Note: if you are using the Mantle Framework, skip ahead to Using With the Mantle Framework.
Let's get started integrating your project with Mantle and Pest. This guide assumes that your project is placed inside an existing WordPress installation as a plugin or a theme. Read more information about setting up the test framework here.
The default configuration will install WordPress using a
localhostdatabase namedwordpress_unit_testswith the username/password pair ofroot/root. All constants can be overridden using thewp-tests-config.phpfile or your unit test's bootstrap file.
Assuming you do not have Pest setup in your project, create a tests folder and
run the pest --init command:
./vendor/bin/pest --init
Replacing the Pest Test Case
Open up the tests/Pest.php file in your project the above command created for you. Look for a line that looks like this:
// uses(Tests\TestCase::class)->in('Feature');
Replace that with the following:
uses(\Mantle\Testkit\TestCase::class)->in(__DIR__); // Install WordPress via Mantle. \Mantle\Testing\install();
Finally, you can run Pest directly from the command line:
./vendor/bin/pest
You can now use the Mantle Testing Framework with Pest to test your WordPress plugin with ease and simplicity. Your IDE will be able to type-hint you as well to allow you to use the testing framework.
See how this plugin uses Pest with Mantle for reference.
Using with the Mantle Framework
Requiring the WordPress Pest Plugin on an existing Mantle project will allow you to install Pest with a few commands.
Install the WordPress plugin via the Composer package manager and run the mantle pest:install WP-CLI command:
composer require alleyinteractive/pest-plugin-wordpress --dev wp mantle pest:install
That's it! Pest is installed successfully on your Mantle project. You can run your pest tests through Pest now:
./vendor/bin/pest
Mantle can also generate a Pest-friendly test by running the pest:test
WP-CLI command:
wp mantle pest:test <TestName>
Writing Tests
More information can be found on the Testing Framework page.
use function Pest\PestPluginWordPress\from; use function Pest\PestPluginWordPress\get; it( 'should load the homepage', function () { get( '/' ) ->assertStatus( 200 ) ->assertSee( 'home' ); } ); it( 'should load with a referrer', function () { from( 'https://laravel.com/' ) ->get( '/' ) ->assertStatus( 200 ); });
alleyinteractive/pest-plugin-wordpress 适用场景与选型建议
alleyinteractive/pest-plugin-wordpress 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.97k 次下载、GitHub Stars 达 27, 最近一次更新时间为 2021 年 10 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「php」 「testing」 「plugin」 「test」 「wordpress」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 alleyinteractive/pest-plugin-wordpress 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alleyinteractive/pest-plugin-wordpress 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alleyinteractive/pest-plugin-wordpress 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Testing Suite For Lumen like Laravel does.
The PHP SDK for Checkmango
Alfabank REST API integration
The testing extension of TYPO3voilà.
Auto-generate dummy data with realistic relationships per Model-like config classes
统计信息
- 总下载量: 3.97k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 27
- 点击次数: 14
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-29