Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PHP CE 2018 - Building Symfony application with Ports and Adapters approach and BDD

36 views

Published on

Having code that is not coupled with any framework has a lot of profits. There is a small probability that you will be changing framework during your project lifecycle, but that kind of approach gives you easy way to reuse some of your functionalities across different styles of user interaction. GUI? API? Console command? Easy peasy with small effort. Everything with high understanding of domain you are working for.

Slides for workshop.

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

PHP CE 2018 - Building Symfony application with Ports and Adapters approach and BDD

  1. 1. Building Symfony application with Ports and Adapters approach and BDD Michał Pipa | Dariusz Drobisz PHP CE 2018, Prague
  2. 2. Ports and adapters aka Hexagonal Architecture
  3. 3. Hexagonal Architecture Application / Use cases Infrastructure Application / Use cases Core / Domain
  4. 4. Hexagonal Architecture Application / Use cases Infrastructure Application / Use cases Core / Domain
  5. 5. Application / Use cases Application / Use cases Core / Domain with BDD approach
  6. 6. BDD Behavior Driven Development
  7. 7. What is not BDD? ● Behat ● PHPSpec ● Gherkin scenarios ● Tests
  8. 8. “Behaviour-driven development is about implementing an application by describing its behaviour from the perspective of its stakeholders” ~ Dan North
  9. 9. So what is BDD? Describing application behaviour
  10. 10. For what BDD is? Developer Help understand BUSINESS and DESIGN Customer Help understand WHAT THEY NEED
  11. 11. So what is BDD? 2 levels
  12. 12. What BDD is? Story BDD Describing high level business application behaviour. Spec BDD Describing low level implementation behaviour.
  13. 13. What BDD is? StoryBDD SpecBDD
  14. 14. Story BDD Describing high level business application behaviour.
  15. 15. Story BDD - tools Gherkin language Describing features and scenarios Behat Automate scenarios written in Gherkin language
  16. 16. Gherkin language - *.feature
  17. 17. Gherkin language - Not BDD
  18. 18. Gherkin language - Not BDD
  19. 19. Gherkin language - BDD
  20. 20. Gherkin language - BDD
  21. 21. Gherkin language - BDD
  22. 22. Gherkin language - live example ● we have customer ● we have products catalogue ● customer can add some amount of products to cart ● products in given amount should be placed in customer cart
  23. 23. Gherkin language - exercise - 15 minutes git checkout feature-exercise ● we have products in catalogue ● customer have some of them in his cart ● customer checkouts his cart for given address ● order for given products and address should be created ● order should have total price
  24. 24. Gherkin language - exercise
  25. 25. Behat Context
  26. 26. Spec BDD Describing low level implementation behaviour.
  27. 27. PHPSpec - spec file
  28. 28. Test only unit behaviour Mock collaborators
  29. 29. PHPSpec - spec file: let, dummy
  30. 30. PHPSpec - spec file: matcher
  31. 31. PHPSpec - spec file: stub
  32. 32. PHPSpec - spec file: mock, spy
  33. 33. git checkout your-big-exercise Try to implement automation of steps from second scenario - cart checkout (CheckoutContext) Implement needed production code with Specs where needed. Exercise after workshop solution:gitcheckoutdomain-end
  34. 34. git checkout cart_checkout There is Notifier interafce used in CheckoutHandler. There is Fake implementation used in behat automation. You can try to create i.e. Mail adapter for this port for usage on app integrated with Symfony. Exercise after workshop
  35. 35. Feedback https://joind.in/talk/4a33e
  36. 36. Building Symfony application with Ports and Adapters approach and BDD Dariusz Drobisz dariusz.drobisz@gmail.com Michał Pipa michal@michalpipa.pl Questions?

×