Technical Assessment 05/22. OOP PHP.
- Using
spatie/data-transfer-objectsas a backbone (model) to create a basket containing products, and optionally discounts/offers. - Using
league/containerto instantiate baskets- Implemented an
InMemoryBasketwhich is essentially a collection of DTOs usingArrayAccessoperations - Stubbed an
SqliteMemoryBasketwhich is a more real-world integration
- Implemented an
- Using
phpunit/phpunitfor unit testscomposer run testsormake testfor running test suitecomposer run coverageormake coveragefor generating code coverage report
- Using
overtrue/phplintfor checking code syntaxcomposer run phplintormake phplint
- Using
squizlabs/php_codesnifferto detect code style violationscomposer run phpcsormake phpcs
git clone [email protected]:alistaircol/hta.git ac-technical-test
cd ac-technical-test
# if php 8 and composer is installed locally:
composer install
composer run tests
composer run coverage
# else run in container:
make install
make test
make coveragecomposer installormake installcomposer run testsormake test
composer run testsormake test
composer run phplintormake phplintcomposer run phpcsormake phpcs
composer run coverageormake coverage
You can see the coverage report here
The checkout system allows users to pay upfront for products added to their property management agreement. The system should also allow users to take advantage of special offers. An initial offer will be “users who have agreed to a 12-month contract are entitled to a 10% discount off the basket total”
The products are below:
| Product Code | Name | Price |
|---|---|---|
| P001 | Photography | 200 |
| P002 | Floorplan | 100 |
| P003 | Gas Certificate | 83.50 |
| P004 | EICR Certificate | 51.00 |
Your job is to implement the basket which should have the following interface:
- Basket can be initialised with offer(s) user is eligible for
- It has an add method to add a product
- Each individual product can only be added to the basket one time
- It has a total method that returns the total cost of the basket - remember to take into account any valid offers




