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

Modelling an Extension by Example

Marco Lopes
February 10, 2015

Modelling an Extension by Example

Marco Lopes

February 10, 2015
Tweet

More Decks by Marco Lopes

Other Decks in Programming

Transcript

  1. Feature: Uploading images to cloudinary
 In order to be able

    to provide images via cloudinary 
 As a Store Admin
 I want to be able to upload images to cloudinary
  2. Feature: Uploading images to cloudinary
 In order to optimise images

    for specific web clients 
 As a Store Admin
 I want to be able to upload images to cloudinary
  3. Feature: Uploading images to an image provider
 In order to

    optimise images for specific web clients
 As a Store Admin
 I want to be able to upload images to the image provider
  4. Scenario: Uploading an image to cloudinary
 Given I have an

    image "product1.gif"
 When I upload the image
 Then the image should be uploaded to cloudinary

  5. Scenario: Uploading an image to an image provider
 Given I

    have an image "product1.gif"
 When I upload the image
 Then the image should be uploaded to cloudinary

  6. Scenario: Uploading an image to an image provider
 Given I

    have an image "product1.gif"
 When I upload the image
 Then the image should be available at the provider

  7. /**
 * @Given I have an image :anImage
 */
 public

    function iHaveAnImage(Image $anImage)
 {
 $this->image = $anImage;
 }
  8. /**
 * @When I upload the image
 */
 public function

    iUploadTheImage()
 {
 $this->imageProvider->upload($this->image);
 }

  9. /**
 * @Then the image should be available at the

    provider
 */
 public function theImageShouldBeAvailableAtTheProvider()
 {
 expect( $this->imageProvider ->isImageAvailable($this->image) )->toBe(true);
 }

  10. /**
 * @Given I have an image :anImage
 */
 public

    function iHaveAnImage(Image $anImage)
 {
 $this->image = $anImage;
 } Given I have an image "product1.gif"
  11. /**
 * @Given I have an image :anImage
 */
 public

    function iHaveAnImage(Image $anImage)
 {
 $this->image = $anImage;
 } Given I have an image "product1.gif"
  12. $image = Image::fromPath($path); $image = new Image($path); When I create

    an image from the path “path/to/image.gif”

  13. 
 
 @critical Scenario: Uploading an image to an image

    provider
 Given I have an image "product1.gif"
 When I upload the image
 Then the image should be available at the provider

  14. /**
 * @When I upload the image
 */
 public function

    iUploadTheImage()
 {
 $this->imageProvider->upload($this->image);
 }

  15. /**
 * @When I upload the image
 */
 public function

    iUploadTheImage()
 {
 $loginPage->getPage(‘AdminLogin'); $loginPage->open(); $loginPage->login();
 $uploadPage->getPage('ImageUpload'); $uploadPage->open(); $uploadPage->uploadImage(); }
  16. Bhalin Ramabhadran - QA at SessionDigital “I saw those feature

    files written by you almost when everything was over. I could not believe myself how much better it would have been if I have had a chance to see them before starting the QA, as those where mostly the questions I was trying to get an answer for. Those features and scenarios were very well written and I could easily understand what the system was trying to achieve. It also gave me thoughts about more edge cases.”
  17. Questions? Twitter: @mpmlopes Social Introducing Modelling By Example - http://everzet.com/post/99045129766/introducing-modelling-by-example

    Named Constructors in PHP - http://verraes.net/2014/06/named-constructors-in-php/ Related Links Short intro to BDD by everzet - https://www.youtube.com/watch?v=njcHzGYv7nI