Database storage is done using sqlite and middlewares used to showcase restrictions on how many transactions/amounts are allowed like a bank.
- Php needs to be installed. If not installed download Laragon
- Make sure php7.1-sqlite3 driver is installed and enable pdo-sqlite in your php.ini file
- To run code coverage make sure to install Xdebug and edit php.ini to enable extension
- Clone the repo and run
composer install
. Installation instructions for Composer - After creating
.env file
runphp artisan key:generate
- Run
php artisan serve
to serve application - Use a tool such as Postman to send http requests
Available End Points
- localhost::8000/balance [GET]
- localhost::8000/deposit [POST] Sample Post Data - {"bank_account_id": 1, "amount":10001, "reason":"initial deposit"}
- localhost::8000/withdraw [POST] Required in post data amount should numeric Sample Post Data - {"bank_account_id": 1, "amount":10001, "reason":"clear balance"}
Path simple_bank_rest_api\tests\Http\ApiTest.php
- Run
vendor/bin/phpunit
- To get code coverage run
vendor\bin\phpunit --coverage-html tests\reports
. Open the folder and you can open theindex.html file
on your browser to view how many lines of code are covered during testing.