1. Go to this page and download the library: Download syde/wp-phpunit-integration library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
syde / wp-phpunit-integration example snippets
declare(strict_types=1);
use Syde\WpPhpUnitIntegration\Bootstrap;
$packagePath = dirname(__DIR__, 2);
$vendorPath = "{$packagePath}/vendor";
if (!realpath($vendorPath)) {
die('Please install via Composer before running tests.');
}
use Syde\WpPhpUnitIntegration\Bootstrap;
use Syde\WpPhpUnitIntegration\BootstrapLifecycle;
use Syde\WpPhpUnitIntegration\WpTestEnv;
Bootstrap::init(
$packagePath,
new BootstrapLifecycle(
setup: function (): void {
// Run some setup tasks before the default ones.
WpTestEnv::setup();
},
load: function () use ($packagePath): void {
// Omit the default WpTestEnv::load() to use your own custom logic.