About me
Freek Van der Herten
Partner & developer at SPATIE
@freekmurze
https://murze.be
Slide 3
Slide 3 text
About me
phpantwerp.be
Dries Vints
@driesvints
Frederick Vanbrabant
@TheEdonian
Slide 4
Slide 4 text
Since 2003
Websites, applications and webshops
Team
4 developers, 1 manager
Specialization
Laravel development
Slide 5
Slide 5 text
OPEN SOURCE SOFTWARE
Slide 6
Slide 6 text
± 120 packages on Packagist
Laravel, Framework agnostic PHP
± 4 000 000 downloads in total, growing ±500 000 a month
We create a lot of it
Open source software
Slide 7
Slide 7 text
http://github-awards.com/users?type=world&language=php
Open source software
Slide 8
Slide 8 text
LET’S TALK SNAPSHOT TESTING
Slide 9
Slide 9 text
A file on disk, let’s call in snapshot
Test succeeds if output matches snapshot
If not, test will fail
What?
Slide 10
Slide 10 text
Old name: characterization testing
Popularized by Facebook
Jest
Testing interfaces
Where does it come from?
Slide 11
Slide 11 text
https://github.com/spatie/phpunit-snapshot-assertions
assertMatchesSnapshot
assertMatchesJsonSnapshot
assertMatchesXmlSnapshot
How can we do it in PHP?
Slide 12
Slide 12 text
DEMO
Slide 13
Slide 13 text
WRAPPING UP
Slide 14
Slide 14 text
Advantages
Very easy to get started with
Can be used to validate complex output
Easily update all the tests in one go
Slide 15
Slide 15 text
Disadvantages
Brittle
Hard to pinpoint exact point of failure
Bugs can be easily written in the snapshots