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

Driving Your Domain By Examples

Driving Your Domain By Examples

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 Developers Paradise conference in Opatija, Croatia on Apr 26, 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

April 26, 2016
Tweet

More Decks by Marco Lopes

Other Decks in Programming

Transcript

  1. DevelopersParadise 2016 / Opatija / Croatia 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”
  2. DevelopersParadise 2016 / Opatija / Croatia 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”
  3. DevelopersParadise 2016 / Opatija / Croatia 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”
  4. DevelopersParadise 2016 / Opatija / Croatia 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”
  5. DevelopersParadise 2016 / Opatija / Croatia 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”
  6. DevelopersParadise 2016 / Opatija / Croatia 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”
  7. DevelopersParadise 2016 / Opatija / Croatia 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
  8. DevelopersParadise 2016 / Opatija / Croatia /**
 * @Given the

    payment gateway has credit card payments enabled
 */
 public function thePaymentGatewayHasCreditCardPaymentsEnabled()
 {
 $this->paymentGateway = new FakePaymentGateway();
 expect( $this->paymentGateway->HasCreditCardPaymentsEnabled() )->toBe(true);
 }
  9. DevelopersParadise 2016 / Opatija / Croatia /**
 * @Given I

    have credit card :aCreditCard
 */
 public function iHaveCreditCard(CreditCard $aCreditCard)
 {
 $this->creditCard = $aCreditCard;
 }
  10. DevelopersParadise 2016 / Opatija / Croatia /**
 * @Transform :aCreditCard


    */
 public function transformNumberToCreditCard($cardNumber)
 {
 return CreditCard::fromNumber($cardNumber);
 }
  11. DevelopersParadise 2016 / Opatija / Croatia /**
 * @Given the

    credit card has unlimited funds on payment gateway
 */
 public function theCreditCardHasUnlimitedFundsOnPaymentGateway()
 {
 $this->paymentGateway->cardHasUnlimitedCredit( $this->creditCard );
 }
  12. DevelopersParadise 2016 / Opatija / Croatia 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
  13. DevelopersParadise 2016 / Opatija / Croatia 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
  14. DevelopersParadise 2016 / Opatija / Croatia /**
 * @Given the

    payment gateway has unlimited credit for that card
 */
 public function thePaymentGatewayHasUnlimitedCreditForThatCard()
 {
 $this->paymentGateway->hasUnlimitedCreditFor( $this->creditCard );
 }
  15. DevelopersParadise 2016 / Opatija / Croatia default:
 suites:
 domain:
 contexts:

    [DomainContext] 
 web:
 contexts: [WebContext]
 filters: { tags: '@web' }
  16. DevelopersParadise 2016 / Opatija / Croatia default:
 suites:
 domain:
 contexts:

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

    [DomainContext] filters: { tags: '~@ui' }
 web:
 contexts: [WebContext]
 filters: { tags: '@web' } mobile:
 contexts: [MobileContext]
 filters: { tags: '@mobile' }
  18. DevelopersParadise 2016 / Opatija / Croatia 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. DevelopersParadise 2016 / Opatija / Croatia 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