2017 © Pedro Peláez
 

project aramis

image

emmanuel-ba/aramis

  • Sunday, August 14, 2016
  • by emmanuelBa
  • Repository
  • 0 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Welcome to Aramis Rest API


What's inside ?

A REST API developed using Symfony 3.1 , FosRestBundle and JMSSerializerBundle. The purpose is to handle a basic list of cars., (*1)


Installation

Make sure MySQL and PHP >=5.5.9 are installed., (*2)

  1. Choose your favorite way to get composer., (*3)

  2. Install project :, (*4)

    php composer.phar create-project emmanuel-ba/aramis aramis -sdev, (*5)

    database credentials should be asked during installation, (*6)

  3. Create database:, (*7)

    cd aramis, (*8)

    php bin/console doctrine:database:create, (*9)

    php bin/console doctrine:schema:update --force, (*10)

    you can alternatively use the mysql dump file provided (aramis.sql)., (*11)

  4. Load fixtures :, (*12)

    php bin/console doctrine:fixtures:load, (*13)

  5. Launch tests with phpunit:, (*14)

    phpunit, (*15)

  6. Start PHP's built-in web server using Symfony Command :, (*16)

    php bin/console server:run, (*17)

    Api should be available at http:localhost:8000, (*18)


Test API

Quick tests using Postman

You need to have postman installed. Have a look at the Chrome extension, (*19)

  1. Load the provided environment and collection in postman :
    • environment : Aramis.postman_collection.json
    • collection : TEST.postman_environment.json

Run the tests on the collection, (*20)

There should be 22 tests passed, (*21)

Manual tests using curl

  • GET cars (response code 200 expected)

> curl -X GET -H "Cache-Control: no-cache" "http://localhost:8000/cars", (*22)


  • GET car (response code 200 expected)

> curl -X GET -H "Cache-Control: no-cache" "http://localhost:8000/car/1", (*23)


  • POST car (response code 201 expected)

curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"car" : { "maker" : "Seat", "model" : "Leon", "price" : 15000, "option" : [{"name" : "Spoiler"}, {"name" : "GPS"}], "equipment" : [{"name" : "ABS"}, {"name" : "Turbo"}] } }' "http://localhost:8000/car", (*24)


  • INVALID POST car (response code 400 expected)

> curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"car" : { "model" : "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "price" : 15000, "option" : [{"name" : "Spoiler"}, {"name" : "GPS"}], "equipment" : [{"name" : "ABS"}, {"name" : "Turbo"}] } }' "http://localhost:8000/car", (*25)


  • PUT car (response code 204 expected)

> curl -X PUT -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"car" : { "maker" : "Audi", "model" : "Q7", "price" : 75000, "option" : [{"name" : "Camera recul"}, {"name" : "Pack cuir"}], "equipment" : [{"name" : "Boite auto"}, {"name" : "Climatisation"}] } }' "http://localhost:8000/car/3", (*26)


  • INVALID put car (response code 400 expected)

> curl -X PUT -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"car" : { "maker" : "Audi", "model" : "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "price" : 75000, "option" : [{"name" : "Camera recul"}, {"name" : "Pack cuir"}], "equipment" : [{"name" : "Boite auto"}, {"name" : "Climatisation"}] } }' "http://localhost:8000/car/3", (*27)


  • PATCH car (response code 204 expected)

> curl -X PATCH -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"car" : { "model" : "Q5" } }' "http://localhost:8000/car/3", (*28)


INVALID PATCH : (response code 400 expected), (*29)

> curl -X PATCH -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"car" : { "model" : "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx" } }' "http://localhost:8000/car/3", (*30)


DELETE a car : (response code 204 expected), (*31)

curl -X DELETE -H "Cache-Control: no-cache" "http://localhost:8000/car/3", (*32)

The Versions