Les-Tilleuls.coop @dunglas
Kévin Dunglas
❏ Les-Tilleuls.coop’s Founder
❏ Symfony Core Team
❏ API Platform creator
@dunglas
Les-Tilleuls.coop @dunglas
Les-Tilleuls.coop
❏ Self-managed company, since 2011
❏ Entirely owned by the employees
❏ 30 people, 1,000% growth in 6 years!
❏ Hiring in Paris & London:

jobs@les-tilleuls.coop
Les-Tilleuls.coop @dunglas
A Very Simple Blog
Les-Tilleuls.coop @dunglas
Install the Website Skeleton
Symfony + Twig + Doctrine + common dev & debug tools
Les-Tilleuls.coop @dunglas
Enable Bootstrap
Les-Tilleuls.coop @dunglas
Testing a Symfony
App
Les-Tilleuls.coop @dunglas
Les-Tilleuls.coop @dunglas
3 Components to
Emulate a Browser
Les-Tilleuls.coop @dunglas
Les-Tilleuls.coop @dunglas
A Web Scraping Library
Les-Tilleuls.coop @dunglas
A Functional Test
Les-Tilleuls.coop @dunglas
Generate a Test Skeleton
Les-Tilleuls.coop @dunglas
Les-Tilleuls.coop @dunglas
Run the Test
Les-Tilleuls.coop @dunglas
Functional Tests in Symfony
❏ KernelTestcase:
❏ Extends PHPUnit’s TestCase
❏ boots the Symfony app
❏ WebTestCase:
❏ extends KernelTestcase
❏ uses BrowserKit (that uses DomCrawler and CssSelector)
❏ creates HTTP Foundation’s Request and allows to inspect
Response through a clean API
Les-Tilleuls.coop @dunglas
WebTestCase is elegant, developer-friendly and fast,

but what if:
❏ something is hidden by a faulty CSS rule
❏ a JS error prevents the page to load
❏ the browser blocks the form (XSS
detection…) ?
Les-Tilleuls.coop @dunglas
You’ll never know!
Les-Tilleuls.coop @dunglas
And what if you rely on:
?
Symfony Encore
+
You can’t test it!
Les-Tilleuls.coop @dunglas
Why?
Because BowserKit doesn’t
support
JavaScriptnor CSS
Les-Tilleuls.coop @dunglas
Introducing
Symfony Panther 😺
Les-Tilleuls.coop @dunglas
Panther, in a few words
❏ Executes real web browsers
❏ So, same features than browsers including JS and CSS
❏ Implements BrowserKit’s API
❏ Built on top of Facebook’s PHP WebDriver and the
WebDriver Protocol, implements PHP WebDriver’s API
❏ Provide convenient methods for JS testing:
❏ wait, execute script, screenshot…
❏ Standalone lib, for testing and web scraping
Les-Tilleuls.coop @dunglas
Guess what?
You already
master Panther!
Les-Tilleuls.coop @dunglas
Les-Tilleuls.coop @dunglas
Run the Test
Les-Tilleuls.coop @dunglas
Drop-in replacement
for existing
WebTestCase tests
and Gouttescripts
Les-Tilleuls.coop @dunglas
Choose your Weapon 🔪 🔫 💣
Les-Tilleuls.coop @dunglas
Extra Capabilities %
Les-Tilleuls.coop @dunglas
Access your Services
Les-Tilleuls.coop @dunglas
Easy to use, Developer-friendly
❏ Nothing to install
❏ Nothing to configure
❏ neither Selenium,
❏ nor a web server
❏ Panther just works!
Les-Tilleuls.coop @dunglas
You only Believe
What you See?
Les-Tilleuls.coop @dunglas
How Does it Work?
Les-Tilleuls.coop @dunglas
ChromeDriver
❏ Panther is shipped with ChromeDriver binaries
❏ It’s a standalone server, exposing

a Selenium/W3C compliant WebDriver API
❏ It automatically finds the local Chrome install
❏ It can start Chrome in headless mode!
Les-Tilleuls.coop @dunglas
Panther Supports Any WebDriver API
❏ ChromeDriver is not mandatory
❏ Experimental support for Geckodriver

(same as ChromeDriver, but for Firefox)
❏ Compatible with the Selenium server and
Selenium Grid
❏ Compatible with remote testing services such as:
Les-Tilleuls.coop @dunglas
The Builtin Web Server
❏ Panther transparently serves your project using
the builtin PHP web server
❏ it finds the PHP binary
❏ it finds the document root (public/ with Flex)
❏ it starts the project in test environment
❏ Yes, it works even on Windows!
Les-Tilleuls.coop @dunglas
Panther Can Work with Any Web Server
❏ You use Docker, or Vagrant?
❏ Panther has got you covered
❏ You can configure the URL to use…
❏ …and disable the builtin web server!
Les-Tilleuls.coop @dunglas
Continuous
Integration
Les-Tilleuls.coop @dunglas
Panther Is Compatible With:
❏ Travis CI
❏ AppVeyor (Windows)
❏ Docker (GitLab CI, Circle CI, custom…)
❏ SauceLabs, BrowserStack and other browser
testing services
Les-Tilleuls.coop @dunglas
Travis
Les-Tilleuls.coop @dunglas
Docker
Les-Tilleuls.coop @dunglas
Test Environment
Les-Tilleuls.coop @dunglas
Config and Environment Variables
The builtin web server inherits from env vars set in the current context:
Les-Tilleuls.coop @dunglas
We’re trying to make this easier, and you can help us:
Les-Tilleuls.coop @dunglas
Database Testing
and Fixtures
Les-Tilleuls.coop @dunglas
Introducing AliceBundle,

Panther & WebTestCase’s new best friend
Les-Tilleuls.coop @dunglas
Install AliceBundle
Les-Tilleuls.coop @dunglas
AliceBundle: What’s Inside?
❏ Faker: pseudo-random data generator
❏ Alice: an expressive syntax on top of Faker
❏ Symfony integration (new: Flex integration)
❏ Support for Doctrine ORM, ODM and Eloquent
❏ New: DB testing helpers (inspired by Laravel)
Les-Tilleuls.coop @dunglas
Describe the Data you Want
Les-Tilleuls.coop @dunglas
Purge the DB and Load Fixtures before every test:
Les-Tilleuls.coop @dunglas
Faster Panther
Tests
Les-Tilleuls.coop @dunglas
Starts and stops the web server for every test suite,
instead of every test class.
Contributed by @Pierstoval (symfony/panther#30)
Les-Tilleuls.coop @dunglas
github.com/symfony/panther
Available right now!
Thanks! Any question?

Panther: test your Symfony apps with real web browsers