Search by

pieceofcake2 / panther

ttsuru

End-to-End tests for CakePHP 2 applications with Symfony Panther and PHPUnit

Package info

github.com/pieceofcake2/panther

Homepage

pkg:composer/pieceofcake2/panther

Statistics

Installs: 403

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v1.0.4 2026-10-16 20:40 UTC

README

GitHub License Packagist Version PHP CakePHP PHPStan CI Codecov

End-to-End tests for pieceofcake2/cakephp applications with Symfony Panther, the way Symfony applications run them.

PantherTestCase is a CakeTestCase that uses Panther's PantherTestCaseTrait: static::createPantherClient() starts your application with PHP's built-in web server and drives it with Chrome, and $fixtures work as usual because the web server uses the test datasource. Everything else is Panther: its client, its PANTHER_* environment variables, its PHPUnit extension and its assertions.

<?php
declare(strict_types=1);

namespace App\Test\TestCase\EndToEnd;

use PieceOfCake2\Panther\TestSuite\PantherTestCase;

class ArticlesTest extends PantherTestCase
{
    /**
     * @var array<string>
     */
    public $fixtures = ['app.article'];

    /**
     * @return void
     */
    public function testIndex(): void
    {
        $client = static::createPantherClient();
        $client->request('GET', '/articles');

        $this->assertPageTitleContains('Articles');
        $this->assertSelectorTextContains('table', 'First article');
    }
}

Documentation

The Markdown documentation is also included in the Composer package, at vendor/pieceofcake2/panther/docs/README.md.

Requirements

  • PHP 8.0+ (Panther 2.1 on PHP 8.0, Panther 2.4 on PHP 8.1+)
  • pieceofcake2/cakephp 2.12+
  • PHPUnit 9.6
  • Google Chrome or Chromium and a matching chromedriver

Installation

composer require --dev pieceofcake2/panther dbrekelmans/bdi
vendor/bin/bdi detect drivers

It is a library (PSR-4, PieceOfCake2\Panther\), not a CakePHP plugin: there is nothing to load with CakePlugin::load().

Quick start

  1. Register the extension in phpunit.xml.dist (see docs/examples/phpunit.xml.dist):

    <extensions>
        <extension class="PieceOfCake2\Panther\ServerExtension"/>
    </extensions>
  2. Set DATABASE_URL to the test database in config/.env.test. The tests run with APP_ENV=test by default (pieceofcake2/app's tests/bootstrap.php), and the web server inherits it, so both load that file, as in Symfony (pieceofcake2/app has this setup; see Test Database):

    # config/.env.test
    DATABASE_URL="mysql://user:password@localhost:3306/test_database_name?encoding=utf8mb4"
  3. Write tests that extend PieceOfCake2\Panther\TestSuite\PantherTestCase in tests/TestCase/EndToEnd/ and run them with vendor/bin/phpunit --testsuite EndToEnd.

Reporting Issues

Please open an issue on GitHub. To report a security vulnerability, use private vulnerability reporting.

Contributing

See the contribution guidelines.

Origin

This package was created by pieceofcake2, which also maintains it. It is not a fork of another project and is not based on one. It builds on Symfony Panther as a Composer dependency, and it replaces pieceofcake2/e2e-test.

License

The MIT License. See LICENSE.