Technical Assessment 05/22. OOP PHP.
- Using
spatie/data-transfer-objects
as a backbone (model) to create a basket containing products, and optionally discounts/offers. - Using
league/container
to instantiate baskets- Implemented an
InMemoryBasket
which is essentially a collection of DTOs usingArrayAccess
operations - Stubbed an
SqliteMemoryBasket
which is a more real-world integration
- Implemented an
- Using
phpunit/phpunit
for unit testscomposer run tests
ormake test
for running test suitecomposer run coverage
ormake coverage
for generating code coverage report
- Using
overtrue/phplint
for checking code syntaxcomposer run phplint
ormake phplint
- Using
squizlabs/php_codesniffer
to detect code style violationscomposer run phpcs
ormake 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 coverage
composer install
ormake install
composer run tests
ormake test
composer run tests
ormake test
composer run phplint
ormake phplint
composer run phpcs
ormake phpcs
composer run coverage
ormake 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