Giter VIP home page Giter VIP logo

r2d2's Introduction

r2d2 Build Status

R2D2 - DeathStar API consumer

Demo

example-output

Live API

https://death-star-api.herokuapp.com/

Requirements

  • docker
    or
  • composer && "php": ">=7.2", "ext-json": "*"

Installation & usage

  1. Clone repo
  2. Run composer install or make build
  3. Run bin/console r2d2 or make r2d2

Implementation

ApiConsumer

DeathStarApiConsumer

Contract testing

Contract - The set of pre-defined requests and expected responses. In order to ensure that our integration has been implemented correctly we might need to perform an end to end test between an API provider and an API consumer. This test can assert that the API provider returns expected responses for a set of pre-defined requests by the API consumer. Unfortunately, "end to end" tests with API provider and API consumer involved are expensive in terms of time and resources. In case of any change in our API provider we might need to perform e2e testing again. I think it is much better to test against shared contract rather than perform e2e test every time, so I decided to introduce contract test-suite instead of end to end test-suite.

Ports & Adapters Pattern

In order to satisfy goal of Contract testing and follow the single responsibility principle, I decided to extract DeathStarApiAdapter interface and use multiple implementations of this interface:

interface DeathStarApiAdapter
{
    /**
     * @param string $method
     * @param string $uri
     * @param array  $options
     *
     * @throws DeathStarApiException
     *
     * @return array
     */
    public function request(string $method, string $uri, array $options): array;
}

Implementations:

r2d2's People

Contributors

lzakrzewski avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.