snicco/testing-bundle

v2.0.0-beta.9 2024-09-07 14:27 UTC

README

codecov Psalm Type-Coverage Psalm level PhpMetrics - Static Analysis PHP-Versions

The testing bundle provides a full testing framework for WordPress applications based on the snicco/kernel library.

Installation

composer install snicco/testing-bundle

Usage

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();
        
    }    
}

Contributing

This repository is a read-only split of the development repo of the Snicco project.

This is how you can contribute.

Reporting issues and sending pull requests

Please report issues in the Snicco monorepo.

Security

If you discover a security vulnerability within BetterWPCache, please follow our disclosure procedure.