An example of Laravel "Unit" testing for a blog post ->
Usually I see tutorials to tests Laravel which are just functional tests, I think unit testing should be given priority too. Done for this blog post.
To clone and run this locally do the following:
composer install --prefer-dist
http://localhost:8000/place/Cash
on your browser you should see Checkout for Cash with total 100
http://localhost:8000/place/CreditCard
on your browser you should see Checkout for CreditCard with total 95
PHPUnit is used to write the unit tests, to run the tests run the following command after composer install is done.
>./vendor/bin/phpunit
To run with docker and nginx proxy at virtual host laravel.dev do the following steps
laravel.dev
to your /etc/hosts
with sudo echo '120.0.0.1 laravel.dev' >> /etc/hosts
docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro -v ~/projects/nginx-proxy/logs:/var/log/nginx jwilder/nginx-proxy
it will have logs in the ~/projects/nginx-proxy/logs
folderhttp://laravel.dev/place/Cash
to see the desired output. (you might need to 777 your storage folderdocker run -d -p 3306:3306 -v ~/Projects/data:/var/lib/data --name=mysql dydx/alpine-mariadb
external_links:
- mysql:mysql
mysql