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
Marek Matulka
January 14, 2015
Programming
2
310
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
Test Smarter, Not Harder
super_marek
0
67
Super Marek's Testing Strategy (LeedsPHP meetup)
super_marek
1
310
Applying DDD when building Drupal modules using Symfony components (DrupalCamp CS)
super_marek
1
1.2k
Mission (Im)possible: Quality Decoupled Code with Drupal 7 (PHP SW meetup)
super_marek
0
220
Mission (Im)possible: Quality Decoupled Code with Drupal 7 (Singapore PHP user group meetup)
super_marek
0
450
Flying in style without splashing out
super_marek
1
240
Mission (Im)possible: Quality Decoupled Code with Drupal 7 (DrupalCamp Scotland)
super_marek
0
170
Mission (Im)possible: Quality Decoupled Code with Drupal 7
super_marek
0
630
Modernising the Legacy (ZendCon)
super_marek
0
410
Other Decks in Programming
See All in Programming
Java_プロセスのメモリ監視の落とし穴_NMT_で見抜けない_glibc_キャッシュ問題_.pdf
ntt_dsol_java
0
210
PyCon mini 東海 2025「個人ではじめるマルチAIエージェント入門 〜LangChain × LangGraphでアイデアを形にするステップ〜」
komofr
3
1k
2026年向け会社紹介資料
misu
0
210
競馬で学ぶ機械学習の基本と実践 / Machine Learning with Horse Racing
shoheimitani
13
12k
Flutterチームから作る組織の越境文化
findy_eventslides
0
110
Honoを技術選定したAI要件定義プラットフォームAcsimでの意思決定
codenote
0
240
What’s Fair is FAIR: A Decentralised Future for WordPress Distribution
rmccue
0
180
Stay Hacker 〜九州で生まれ、Perlに出会い、コミュニティで育つ〜
pyama86
2
1.6k
Agentに至る道 〜なぜLLMは自動でコードを書けるようになったのか〜
mackee
5
1.6k
組織もソフトウェアも難しく考えない、もっとシンプルな考え方で設計する #phpconfuk
o0h
PRO
10
4.4k
複数チーム並行開発下でのコード移行アプローチ ~手動 Codemod から「生成AI 活用」への進化
andpad
0
170
CSC509 Lecture 10
javiergs
PRO
0
180
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
11
930
Docker and Python
trallard
46
3.7k
The Pragmatic Product Professional
lauravandoore
36
7k
Thoughts on Productivity
jonyablonski
73
4.9k
How to Ace a Technical Interview
jacobian
280
24k
YesSQL, Process and Tooling at Scale
rocio
174
15k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
Music & Morning Musume
bryan
46
6.9k
A Tale of Four Properties
chriscoyier
162
23k
Code Review Best Practice
trishagee
72
19k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
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