Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Driving Your Domain by Examples - London Magento Meetup

Driving Your Domain by Examples - London Magento Meetup

How to use Gherkin scenarios and Behat to drive your development into modelling the problem you're trying to solve rather than an arbitrary and possibly inadequate solution.
Slides for the version of the talk delivered at the London Magento user group meetup on May 25, 2016.

Related Links:
- Introducing Modelling by Example http://stakeholderwhisperer.com/posts/2014/10/introducing-modelling-by-example
- Named Constructors in PHP http://verraes.net/2014/06/named-constructors-in-php/
- An Introduction to BDD from Konstantin Kudryashov https://www.youtube.com/watch?v=njcHzGYv7nI

Marco Lopes

May 25, 2016
Tweet

More Decks by Marco Lopes

Other Decks in Programming

Transcript

  1. London Magento User Group Marco Lopes Technical Team Lead -

    Session Digital @mpmlopes Inviqa Group Marco Lopes
  2. BDD

  3. Scenario: Paying with a credit card
 Given AwesomePay has credit

    card payments enabled
 When I fill the credit card number with 4444333322221111 And I fill the expiry date with ”04/2018” And I fill the CCV with 123 And the credit card has unlimited funds on payment gateway
 And I press place order button
 Then the payment should be accepted And the magento order status should be ”processing”
  4. Scenario: Paying with a credit card
 Given AwesomePay has credit

    card payments enabled
 When I fill the credit card number with 4444333322221111 And I fill the expiry date with ”04/2018” And I fill the CCV with 123 And the credit card has unlimited funds on payment gateway
 Then the payment should be accepted And the magento order status should be ”processing”
  5. Scenario: Paying with a credit card
 Given AwesomePay has credit

    card payments enabled
 When I have credit card 4444333322221111 And the credit card has unlimited funds on payment gateway
 Then the payment should be accepted And the magento order status should be ”processing”
  6. Scenario: Paying with a credit card
 Given AwesomePay has credit

    card payments enabled
 And I have credit card 4444333322221111 And the credit card has unlimited funds on payment gateway When I pay £42 using that credit card
 Then the payment should be accepted And the magento order status should be ”processing”
  7. Scenario: Paying with a credit card
 Given the payment gateway

    has credit card payments enabled
 And I have credit card 4444333322221111 And the credit card has unlimited funds on payment gateway When I pay £42 using that credit card
 Then the payment should be accepted And the magento order status should be ”processing”
  8. Scenario: Paying with a credit card
 Given the payment gateway

    has credit card payments enabled
 And I have credit card 4444333322221111 And the credit card has unlimited funds on payment gateway When I pay £42 using that credit card
 Then the payment should be accepted And the magento order status should be ”processing”
  9. Scenario: Paying with a credit card
 Given the payment gateway

    has credit card payments enabled
 And I have credit card 4444333322221111 And the credit card has unlimited funds on payment gateway When I pay £42 using that credit card
 Then the payment should be accepted
  10. /**
 * @Given the payment gateway has credit card payments

    enabled
 */
 public function thePaymentGatewayHasCreditCardPaymentsEnabled()
 {
 $this->paymentGateway = new FakePaymentGateway();
 expect( $this->paymentGateway->HasCreditCardPaymentsEnabled() )->toBe(true);
 }
  11. /**
 * @Given I have credit card :aCreditCard
 */
 public

    function iHaveCreditCard(CreditCard $aCreditCard)
 {
 $this->creditCard = $aCreditCard;
 }
  12. /**
 * @Given the credit card has unlimited funds on

    payment gateway
 */
 public function theCreditCardHasUnlimitedFundsOnPaymentGateway()
 {
 $this->paymentGateway->cardHasUnlimitedCredit( $this->creditCard );
 }
  13. Scenario: Paying with a credit card
 Given the payment gateway

    has credit card payments enabled
 And I have credit card 4444333322221111 And the credit card has unlimited funds on payment gateway When I pay £42 using that credit card
 Then the payment should be accepted
  14. Scenario: Paying with a credit card
 Given the payment gateway

    has credit card payments enabled
 And I have credit card 4444333322221111
 And the payment gateway has unlimited credit for that card
 When I pay £42 using that credit card
 Then the payment should be accepted
  15. /**
 * @Given the payment gateway has unlimited credit for

    that card
 */
 public function thePaymentGatewayHasUnlimitedCreditForThatCard()
 {
 $this->paymentGateway->hasUnlimitedCreditFor( $this->creditCard );
 }
  16. default:
 suites:
 domain:
 contexts: [DomainContext] filters: { tags: '~@ui' }


    web:
 contexts: [WebContext]
 filters: { tags: '@web' }
  17. default:
 suites:
 domain:
 contexts: [DomainContext] filters: { tags: '~@ui' }


    web:
 contexts: [WebContext]
 filters: { tags: '@web' } mobile:
 contexts: [MobileContext]
 filters: { tags: '@mobile' }
  18. default:
 suites:
 domain:
 contexts: [DomainContext] filters: { tags: '~@ui' }


    web:
 contexts: [WebContext]
 filters: { tags: '@web' } mobile:
 contexts: [MobileContext]
 filters: { tags: '@mobile' } integration:
 contexts: [IntegrationContext]
 filters: { tags: '~@ui' }
  19. Questions? Related Links http://stakeholderwhisperer.com/posts/2014/10/introducing-modelling-by-example Introducing Modelling by Example Named Constructors

    in PHP http://verraes.net/2014/06/named-constructors-in-php/ Short Intro to BDD from Konstantin Kudryashov https://www.youtube.com/watch?v=njcHzGYv7nI Social Twitter: @mpmlopes