Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sherlockboy/laravel-unit-testing
Unit Testing, Exception Handling example in Laravel
https://github.com/sherlockboy/laravel-unit-testing
exception-handling laravel php php-unit unit-testing
Last synced: 21 days ago
JSON representation
Unit Testing, Exception Handling example in Laravel
- Host: GitHub
- URL: https://github.com/sherlockboy/laravel-unit-testing
- Owner: Sherlockboy
- Created: 2022-01-17T17:44:15.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-19T20:42:02.000Z (about 3 years ago)
- Last Synced: 2024-12-04T08:08:18.843Z (3 months ago)
- Topics: exception-handling, laravel, php, php-unit, unit-testing
- Language: PHP
- Homepage:
- Size: 81.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PHPUnit example
### Task descriptionYou have products database:
| Product code | Name | Price |
|--------------|--------------|--------|
| FR1 | Fruit Tea | $3.11 |
| SR1 | Strawberries | $5.00 |
| CF1 | Coffee | $11.23 |1. CEO wants that if you buy at least one tea, next should be free.
2. CTO wants low prices, so that, if you buy 3 or more strawberries price should drop to $4.50.Your code should be flexible, because CTO and CEO often changes the rules.
The service should look like this:
```
$ch = new Checkout($pricing_rules);
$co->scan($item1);
$co->scan($item2);
$price = $ch->total();
```Implement a checkout system that fulfils these requirements.
### Test data
Basket: FR1,SR1,FR1,FR1,CF1
Total price expected: $22.45Basket: FR1,FR1
Total price expected: $3.11Basket: SR1,SR1,FR1,SR1
Total price expected: $16.61