The testing bundle provides a full testing framework for WordPress applications based on the snicco/kernel
library.
composer install snicco/testing-bundle
This package provides a WebTestCase
that can be used for functional
tests of your application. It's based on lucatume/wp-browser
and symfony/browser-kit
.
use Snicco\Bundle\Testing\Functional\Browser;
use Snicco\Bundle\Testing\Functional\WebTestCase;
class SomeTest extends WebTestCase {
protected function extensions() : array{
return []; // Return an array of class names implementing TestExtension
}
protected function createKernel(){
return '/path/to/kernel-bootstrap.php' // Path to kernel bootstrap file (assuming this file returns a closure).
}
public function testHomePage(){
/** @var Browser $browser */
$browser = $this->getBrowser();
$browser->request('/');
$browser->lastResponse()
->assertOk()
->assertSeeText('Some text');
$browser->lastDOM()->assertSelectorExists('body > h1');
$browser->reload();
$browser->back();
}
}
This repository is a read-only split of the development repo of the Snicco project.
This is how you can contribute.
Please report issues in the Snicco monorepo.
If you discover a security vulnerability within BetterWPCache, please follow our disclosure procedure.