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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Test Smarter, Not Harder
super_marek
0
75
Super Marek's Testing Strategy (LeedsPHP meetup)
super_marek
1
330
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
230
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
Modernising the Legacy (ZendCon)
super_marek
0
430
Other Decks in Programming
See All in Programming
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
460
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
430
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
400
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
3.9k
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
200
AI時代の認知負荷との向き合い方
optfit
0
160
高速開発のためのコード整理術
sutetotanuki
1
400
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
120
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
200
組織で育むオブザーバビリティ
ryota_hnk
0
180
今から始めるClaude Code超入門
448jp
8
8.7k
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
610
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
A Soul's Torment
seathinner
5
2.3k
Designing for Timeless Needs
cassininazir
0
130
Making Projects Easy
brettharned
120
6.6k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
110
What does AI have to do with Human Rights?
axbom
PRO
0
2k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
430
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Designing Experiences People Love
moore
144
24k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
280
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