Coder Social home page Coder Social logo

test_task_calculate_price's Introduction

Test task: calculate product price

Commands

### Start
docker compose up -d
docker compose exec sio_test bash

### Migrations
bin/console doctrine:migrations:migrate
bin/console doctrine:fixtures:load

### Run tests
bin/phpunit

Fixtures load countries, coupons and test products

Countries
  • Germany, code: GE, tax rate - 19
  • France, code: FR, tax rate - 20
  • Italy, code: IT, tax rate - 22
  • Greece, code: GR, tax rate - 24
Coupons
  • P10 (10% coupon)
  • P15 (15% coupon)
  • F50 (50 fixed discount)
  • F25 (25 fixed discount)
Coupons
  • iPhone, 100 (id - 1)
  • Headphones, 20 (id - 2)

Commands to check the functionality (CURL)

Calculate examples

curl -X POST http://localhost:8337/calculate-price \
-H "Content-Type: application/json" \
-d '{
    "product": 1,
    "taxNumber": "FR123456789",
    "couponCode": "F50"
}'

Free product in total

curl -X POST http://localhost:8337/calculate-price \
-H "Content-Type: application/json" \
-d '{
    "product": 2,
    "taxNumber": "FR123456789",
    "couponCode": "F50"
}'

Without coupon

curl -X POST http://localhost:8337/calculate-price \
-H "Content-Type: application/json" \
-d '{
    "product": 2,
    "taxNumber": "FR123456789"
}'

Percent discount

curl -X POST http://localhost:8337/calculate-price \
-H "Content-Type: application/json" \
-d '{
    "product": 2,
    "taxNumber": "IT12345678900",
    "couponCode": "P10"
}'

and purchase example

curl -X POST http://localhost:8337/purchase \
-H "Content-Type: application/json" \
-d '{
    "product": 1,
    "taxNumber": "FR123456789",
    "couponCode": "F50",
    "paymentProcessor": "paypal"
}'

test_task_calculate_price's People

Watchers

Vitalii Khomiakov 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.