Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Symfony Panther an introduction and review Symfony User Group Berlin Erik Witthauer

Slide 3

Slide 3 text

About me Erik Witthauer PHP developer for > 10 years Twitter: ewnx01 Web aka: dknx01 Speakerdeck: speackerdeck.com/dknx01 currently work: FTI

Slide 4

Slide 4 text

How to test a web application

Slide 5

Slide 5 text

How to test a web application with(out) PHP ● use external E2E tools ● use monkeys (testing everything manual) ● use PHPUnit with ○ WebTestCase ○ BrowserKit, DomCrawler ○ CssSelector ● Behat ● other testing frameworks

Slide 6

Slide 6 text

What about ...? Behat ● uses CssSelection ● hard to handle Javascript (loading) ● sees “everything” ● does not behave like a real browser WebTestCase ● use local setup (booting Kernel) ● hard to handle Javascript (loading) ● sees “everything” ● does not behave like a real browser

Slide 7

Slide 7 text

What about ...? Goutte ● uses CssSelection ● no Javascript handling ● sees “everything” ● does not behave like a real browser

Slide 8

Slide 8 text

How to test a web application with(out) PHP ● Problems: ○ detection of hidden elements, by CSS ○ JavaScript changes or error prevent loading ○ browser blocking (XSS ...)

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Solution: Symfony Panther

Slide 11

Slide 11 text

What is Symfony Panther? ● a Browser Testing and Web Scrapping Library for PHP ● library for E2E testing ● executes a real browser (with full JS and CSS support) ● build on top of Facebook PHP WebDriver and WebDriver protocol ● supports JavaScript execution ● implements BrowserKit API ● standalone lib

Slide 12

Slide 12 text

What is Symfony Panther? ● shipped with ChromeDriver binaries ● uses local Chrome ● runs headless ● compatibles with Selenium server, remote testing services (e.g. BrowserStack, SauceLabs) ● experimental GeckoDriver ● uses builtin PHP web server

Slide 13

Slide 13 text

What is Symfony Panther? ● can use external based URLs (any URL) ● can take screenshots ● injecting and execute JavaScript on the fly (even asynchrone) ● simulate different resolutions (responsive testing)

Slide 14

Slide 14 text

How to use it class BlogPostControllerTest extends WebTestCase { public function testSeeHeadline() { $client = static::createClient(); // Here goes the Code } } class BlogPostControllerPantherTest extends PantherTestCase { public function testSeeHeadline() { $client = static::createPantherClient(); // Here goes the Code } }

Slide 15

Slide 15 text

Demo time

Slide 16

Slide 16 text

Links https://symfony.com/blog/introducing-symfony-panther-a-browser-testing-and-web -scrapping-library-for-php https://github.com/symfony/panther https://www.youtube.com/watch?v=bpKUApk8cNw (SymfonyLive London 2018 - Kévin Dunglas)

Slide 17

Slide 17 text

Question and talk time

Slide 18

Slide 18 text

End