pieceofcake2 / panther
End-to-End tests for CakePHP 2 applications with Symfony Panther and PHPUnit
Requires
- php: >=8.0
- ext-dom: *
- phpunit/phpunit: ^9.6
- pieceofcake2/cakephp: ^2.12
- symfony/panther: ^2.1.1
Requires (Dev)
- cakephp/cakephp-codesniffer: ^5.0
- phpstan/phpstan: ^2.1
- pieceofcake2/phpstan-cakephp2: ^1.0
- symfony/dotenv: ^5.4 || ^6.4 || ^7.0 || ^8.0
Suggests
- dbrekelmans/bdi: Downloads a chromedriver that matches the installed Chrome into drivers/, where Panther finds it (vendor/bin/bdi detect drivers)
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-17 06:30:24 UTC
README
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
- Website: https://pieceofcake2.github.io/panther/ (日本語: https://pieceofcake2.github.io/panther/ja/)
- Markdown: docs/README.md (日本語: docs/ja/README.md) (for AI tools and offline reading)
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
-
Register the extension in
phpunit.xml.dist(see docs/examples/phpunit.xml.dist):<extensions> <extension class="PieceOfCake2\Panther\ServerExtension"/> </extensions>
-
Set
DATABASE_URLto the test database inconfig/.env.test. The tests run withAPP_ENV=testby default (pieceofcake2/app'stests/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"
-
Write tests that extend
PieceOfCake2\Panther\TestSuite\PantherTestCaseintests/TestCase/EndToEnd/and run them withvendor/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.