Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Behat Layered Cake - KaunasPHP
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Marek Matulka
January 14, 2015
Programming
2
330
Behat Layered Cake - KaunasPHP
Speed up Behat tests with a clever use of the layered architecture - KaunasPHP meetup edition!
Marek Matulka
January 14, 2015
Tweet
Share
More Decks by Marek Matulka
See All by Marek Matulka
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
61
Test Smarter, Not Harder
super_marek
0
81
Super Marek's Testing Strategy (LeedsPHP meetup)
super_marek
1
340
Applying DDD when building Drupal modules using Symfony components (DrupalCamp CS)
super_marek
1
1.3k
Mission (Im)possible: Quality Decoupled Code with Drupal 7 (PHP SW meetup)
super_marek
0
240
Mission (Im)possible: Quality Decoupled Code with Drupal 7 (Singapore PHP user group meetup)
super_marek
0
470
Flying in style without splashing out
super_marek
1
260
Mission (Im)possible: Quality Decoupled Code with Drupal 7 (DrupalCamp Scotland)
super_marek
0
180
Mission (Im)possible: Quality Decoupled Code with Drupal 7
super_marek
0
650
Other Decks in Programming
See All in Programming
PHPで TLSのプロトコルを実装してみる
higaki_program
0
370
SourceGeneratorのマーカー属性問題について
htkym
0
210
Feature Toggle は捨てやすく使おう
gennei
0
240
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
120
Goの型安全性で実現する複数プロダクトの権限管理
ishikawa_pro
2
900
「効かない!」依存性注入(DI)を活用したAPI Platformのエラーハンドリング奮闘記
mkmk884
0
160
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
610
Claude Codeログ基盤の構築
giginet
PRO
7
3.5k
条件判定に名前、つけてますか? #phperkaigi #c
77web
2
670
Migration to Signals, Signal Forms, Resource API, and NgRx Signal Store @Angular Days 03/2026 Munich
manfredsteyer
PRO
0
130
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
3
410
Laravel Nightwatchの裏側 - Laravel公式Observabilityツールを支える設計と実装
avosalmon
1
140
Featured
See All Featured
Test your architecture with Archunit
thirion
1
2.2k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
200
Building AI with AI
inesmontani
PRO
1
810
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
150
A designer walks into a library…
pauljervisheath
210
24k
Abbi's Birthday
coloredviolet
2
5.6k
Tell your own story through comics
letsgokoyo
1
860
Prompt Engineering for Job Search
mfonobong
0
210
Transcript
Behat Layered Cake KaunasPHP edition Kaunas, 14 Jan 2015
Labas vakaras!
@super_marek Marek Matulka
at SensioLabsUK Software Engineer
part of Inviqa Group SensioLabsUK
None
a tool that makes BDD possible
With Behat you can...
With Behat you can... ...write human-readable stories that describe behaviour
of your application.
With Behat you can... ...automate testing of your application’s behaviour
with human-readable examples.
With Behat you can... ...change behaviour of your application with
confidence.
None
Typical dev stack - Vagrant VM - Symfony framework -
mysql or mongodb storage - Linux/OS X host - scrutiniser-ci
A project
That’s sloooow!
Should I get a faster computer?
What is the problem?
Where’s the problem? it takes too much time
Where’s the problem? Guest VM
Where’s the problem? MySQL
Where’s the problem? MySQL inside Guest VM
Let’s try it on the host!
A project
(63 scenarios in 320 steps) vs
But!
What if... my project grows and I’ll have 3000+ steps?
What if I had 3000+ steps? 300 steps took over
10 minutes 3000 steps will take over 100 minutes! (inside guest VM)
What if I had 3000+ steps? 300 steps took over
1 minute 3000 steps will take over 10 minutes! (on host)
How to make it faster?
Disable xdebug extension 30-40% improvement
Replace slow modules with... Replace slow DB with fast in-memory
or file-system persistent storage
Example Controller
Example Controller
(short introduction to) Layered Architecture
Layered Architecture User Interface Application Domain Infrastructure
Dependency Inversion “High level modules should not depend on lower
level implementation” – Good old Uncle Bob
Dependency Inversion Policy Layer <interface> Policy Service Mechanism Layer <interface>
Mechanism Service Utility Layer
(short introduction to) Hexagonal Architecture
Hexagonal Architecture Browser Logs Database Auth Domain
Hexagonal Architecture UI Adapter Log Adapter Data Storage Adapter External
Data Adapter Domain
Hexagonal Architecture UI Adapter Log Adapter Data Storage Adapter Domain
UI client port log adapter port persistence layer port Data Provider Adapter data provider port
Hexagonal Architecture UI Adapter Log Adapter Test Adapter Test Adapter
Data Storage Adapter Test Adapter Domain External Data Adapter Test Adapter
How to do that?
Repository Interface Acme\Learning\Conference Acme\Learning\ConferenceRepository
Repository Interface Acme\Learning\Conference Acme\Learning\ConferenceRepository Domain Port
Describe Communication
Your controller
Spec Controller to use Interface
Spec Controller to use Interface Port
Implement your repository
Implement your repository Port Adapter
Register repository as a Service!
Add another Adapter
Implement your repository
Implement your repository Port Adapter
Register repository as a Service!
Configure the Test env
Prepare Test Infrastructure config_test.yml:
Configure dependency injection
How fast can it be?
MySql Inside Guest VM
MySql On Host
Mocked Storage Inside Guest VM
Mocked Storage On Host
Things to remember
Hexagonal Architecture UI Adapter Log Adapter Test Adapter Test Adapter
Data Storage Adapter Test Adapter Domain External Data Adapter Test Adapter
Integration tests Don’t forget to test your adapters! Use PhpUnit
for that.
Talk to me after presentation! Demo
Questions?
Thank you! https://speakerdeck.com/super_marek @super_marek