- Docker (php + nginx + postgres + adminer + redis)
- Codeception
- XDebug
- Docker, docker-compose.
- Http ports 8084, 8085 available on the host machine.
- Create
.env
file from.env.dist
file and set correct vars values in it - Run:
$ ./prepare_environment.sh
Located in config/services.yaml
:
app.currency.rates_provider: 'cbr' # ecb|cbr
app.currency.base_currency: 'RUB' # EUR|RUB
Run console command to refresh rates after any changes of those two parameters.
Run command:
docker-compose exec -T php bin/console app:currency:load-rates
Send POST http://localhost:8085/convert
with JSON:
{
"from_currency_code": "RUB",
"to_currency_code": "EUR",
"amount": "77.1239"
}
Success Response HTTP 200:
{
"success": true,
"data": {
"amount_converted": 1.0318
}
}
Error Response HTTP 400:
{
"success": false,
"data": {
},
"error": "Unknown currency code: XYZ"
}
-
http://localhost:8085/ - REST Api base URL
-
http://localhost:8084/ - adminer
Adminer credentials:
- System: PostgreSQL
- Server: postgres
- Username: symfony
- Password: 123456
run all tests under folder
$ cd codeception
$ php ../vendor/bin/codecept run tests/Functional
run one test in debug mode
$ cd codeception
$ php ../vendor/bin/codecept run tests/Functional/RestTestCest.php --debug
build tester classes
$ cd codeception
$ php ../vendor/bin/codecept build
- Copy
phpunit.xml.dist
tophpunit.xml
, change parameters as you like. - Run
phpunit
.
- Add logging support
- Implement Redis caching for conversion
- Add IaC deployment script
- Add DB index on
currency_rate
.currency_code
field - Implement validation for incoming XML data (currency code 3 characters max, rate should be a number)
- Wrap currency converter into a bundle to be able to embed it
- Implement more strict types in Utils functions
Copyright 2019 Stanislav Erokhin