Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
5519ddc
config: first basic setup
MarcinGladkowski Apr 4, 2020
44f3c37
config: setup coding standards
MarcinGladkowski Apr 4, 2020
5af90f1
config: add setup to php-cs-fixer
MarcinGladkowski Apr 4, 2020
27995ef
config: fix php-cs-fixer
MarcinGladkowski Apr 4, 2020
5117fa1
test: fix basic test
MarcinGladkowski Apr 4, 2020
47bbc1d
feat: add simple classes for commands, coins, change namespaces,
MarcinGladkowski Apr 5, 2020
d6da82e
feat: create item classes
MarcinGladkowski Apr 5, 2020
bfa0262
feat: create ConsoleRequest
MarcinGladkowski Apr 5, 2020
9d75d5f
feat: add InputParser interface, add ConsoleInputParser
MarcinGladkowski Apr 5, 2020
b6e708f
feat: create object to contain parsed request
MarcinGladkowski Apr 5, 2020
e0abfed
feat: add Item interface
MarcinGladkowski Apr 6, 2020
b5c1587
feat: return Money from Request
MarcinGladkowski Apr 6, 2020
a3ffa29
feat: ItemRepository interface
MarcinGladkowski Apr 6, 2020
aa83fde
feat: move methods to abstract class for Item
MarcinGladkowski Apr 8, 2020
d5b181c
test: add simple Item unit tests
MarcinGladkowski Apr 8, 2020
8748d8d
feat: implementation of in memory repository
MarcinGladkowski Apr 8, 2020
edb9006
feat: Dime extends Money
MarcinGladkowski Apr 8, 2020
d8c1ec2
test: in memory repository
MarcinGladkowski Apr 8, 2020
ecc3a05
feat: add values to Money classes
MarcinGladkowski Apr 8, 2020
c36e710
feat: add enum with available money
MarcinGladkowski Apr 12, 2020
0fcf7a0
feat: add ShortCode to money
MarcinGladkowski Apr 12, 2020
9088be3
feat: console parser with tests
MarcinGladkowski Apr 12, 2020
e11f34a
feat: BuyItemCommand implementation on interfaces, simple test
MarcinGladkowski Apr 13, 2020
2ac0b06
feat: method for simple model creation
MarcinGladkowski Apr 13, 2020
18ab086
fix: short code for Nickel
MarcinGladkowski Apr 13, 2020
45d7d4e
feat: Collection to managing money
MarcinGladkowski Apr 13, 2020
334dce1
test: MoneyCollectionTest
MarcinGladkowski Apr 13, 2020
3c05828
feat: implement Interface for Request
MarcinGladkowski Apr 13, 2020
da033e2
test: test for calculating rest with exact and not
MarcinGladkowski Apr 13, 2020
28f4818
test: BuyItemCommand valid return type
MarcinGladkowski Apr 13, 2020
ac6f452
ref: remove unused use statements
MarcinGladkowski Apr 13, 2020
300bb04
feat: PaymentCoordinator - calculate rest of payment
MarcinGladkowski Apr 13, 2020
51a1b84
feat: VendingMachine - execute BuyItemCommand service
MarcinGladkowski Apr 13, 2020
279b7f1
feat: InputParser add MoneyCollection typing
MarcinGladkowski Apr 13, 2020
a412351
feat: simple class for Response
MarcinGladkowski Apr 13, 2020
2b348d3
feat: Request for buy services
MarcinGladkowski Apr 13, 2020
5ee6cb6
feat: implementation for simple Request interface
MarcinGladkowski Apr 13, 2020
ee56193
feat: ConsoleRequest - use MoneyCollection
MarcinGladkowski Apr 13, 2020
fe3c53c
feat: Item list, method to valid money to buy item
MarcinGladkowski Apr 13, 2020
0b8fcd5
fix: first commit from 13/04/2020 with tests fixes
Jan 10, 2022
46b2fa6
test: working with parsing tests, extends for more examples
MarcinGladkowski Jan 16, 2022
ef0840e
tests: add two test cases to parser test
MarcinGladkowski Jan 16, 2022
4272151
ref: remove type annotation
MarcinGladkowski Jan 16, 2022
95581fe
ref: add comments about new class instances
MarcinGladkowski Jan 16, 2022
6de56ad
tests: use data provider
MarcinGladkowski Jan 16, 2022
0933322
tests: add payment coordinator property
MarcinGladkowski Jan 16, 2022
3d5d34c
tests: pay for product without any money
MarcinGladkowski Jan 16, 2022
e6b148a
tests: next test to try for paying for product
MarcinGladkowski Jan 16, 2022
e797f33
tests: test with minus value of money
MarcinGladkowski Jan 16, 2022
d7d11e6
ref: format
MarcinGladkowski Jan 16, 2022
4f86bd1
ref: load autoload based on lang const
MarcinGladkowski Jan 16, 2022
bcb99f2
ref: return console object, remove annotations
MarcinGladkowski Jan 16, 2022
7840e5f
ref: set product classes as final, add strict types
MarcinGladkowski Jan 16, 2022
d0ff43e
config: update php image to php:8.1, update dependencies
MarcinGladkowski Jan 16, 2022
c1b8952
config: commit lock file
MarcinGladkowski Jan 16, 2022
41a50cd
ref: formatting of code, add test to test buy command
MarcinGladkowski Jan 16, 2022
7f5ae9d
config: update image to 8.1
MarcinGladkowski Jan 25, 2022
779c637
build: update on building environment using docker
MarcinGladkowski Jan 25, 2022
d346480
build: possibility to install dependencies on host
MarcinGladkowski Jan 25, 2022
e45a1d9
ref: fix phpunit errors
MarcinGladkowski Jan 25, 2022
1c28aae
ref: passing tests, two assertions commented, to fix
MarcinGladkowski Jan 25, 2022
78881f3
ref: fix sorting after 8.1 changes, all tests passed
MarcinGladkowski Jan 25, 2022
0f7b9ac
tests: add assertion to MoneyCollection
MarcinGladkowski Jan 25, 2022
36bbb38
tests: invalid case with parsing get input
MarcinGladkowski Jan 25, 2022
4a7b9f1
feat: recognize product code from input, change values in items to co…
MarcinGladkowski Jan 25, 2022
8627062
ref: remove command factory
MarcinGladkowski Jan 26, 2022
a599630
test: formatting of exception, add test to expecting exception
MarcinGladkowski Jan 26, 2022
63ef9f1
test: check returning output
MarcinGladkowski Jan 26, 2022
d9347a1
test: order with dollar without exact change, and get rest
MarcinGladkowski Jan 29, 2022
181dd66
ref: extract buy command
MarcinGladkowski Jan 29, 2022
03a68b9
feat: implement interfaces and CoinReturnCommand tests
MarcinGladkowski Jan 29, 2022
13f824c
feat: first implementation of return coins command
MarcinGladkowski Jan 29, 2022
246b949
feat: coin return response
MarcinGladkowski Jan 29, 2022
93cc8e2
feat: return rest with ordered product
MarcinGladkowski Jan 29, 2022
b3ac1f1
ref: change name to result
MarcinGladkowski Jan 29, 2022
cba537d
ref: implement Stringable interface
MarcinGladkowski Jan 29, 2022
19e7e64
ref: set items shortcodes to regex
MarcinGladkowski Jan 29, 2022
8760377
ref: move method with available coins to specialized class
MarcinGladkowski Jan 29, 2022
10c5484
ref: php 8 arguments
MarcinGladkowski Jan 29, 2022
3a7e692
tests: add A item
MarcinGladkowski Jan 29, 2022
fdfc0a3
ref: PSR-12 changes
MarcinGladkowski Jan 29, 2022
170c255
ref: replace to invokable, contravariance complicated class inheritance
MarcinGladkowski Jan 29, 2022
60a2cb3
ref: run code sniffer quality PSR rules
MarcinGladkowski Jan 30, 2022
7d288cd
ref: phpstan, undefined abstract class properties
MarcinGladkowski Jan 30, 2022
0bbbc1e
ref: replace creating money by constructor to static method
MarcinGladkowski Jan 30, 2022
6647d44
ref: money creation interface
MarcinGladkowski Jan 30, 2022
ce91b68
ref: formatting code
MarcinGladkowski Jan 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM php:8.1

RUN apt-get update && apt-get install --no-install-recommends -y \
wget \
vim \
git \
unzip

RUN pecl install xdebug && docker-php-ext-enable xdebug

COPY --from=composer /usr/bin/composer /usr/bin/composer

RUN mkdir -p /app

COPY composer.* /app/

WORKDIR /app

RUN composer install --no-interaction

COPY . .
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't a good idea:

  1. Without .dockerignore you're copy anything from context directory, with .env or temporary builded files.
  2. COPY . . triggers on each changing in context directory - It could be problem with cacheing layer.


CMD ["/bin/bash"]
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
check: phpunit phpcs phpstan fix

run:
docker-compose run --rm vending_machine bash

copy_vendor:
sudo docker cp vending_machine:/usr/src/app/vendor ./

phpunit:
./vendor/bin/phpunit

phpcs:
./vendor/bin/phpcs --standard=PSR1 ./src
./vendor/bin/phpcs --standard=PSR2 ./src

phpstan:
./vendor/bin/phpstan analyse src --level max

fix:
./vendor/bin/php-cs-fixer fix ./src --dry-run
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
#Coding Dojo Silesia #3

## Vending machine kata - PHP

Instructions: https://code.joejag.com/coding-dojo/vending-machine/
Tests: `./bin/vendor/phpunit`
Tests: `./vendor/bin/phpunit`

### Setup
Run commands:
* `docker-compose up`

### Run
Open interactive bash `docker-compose run --rm vending_machine bash`

### Development
Copy dependencies form volume: `sudo docker cp vending_machine:/usr/src/app/vendor ./`

### Install dependencies (to local developing)
`docker-compose run --rm vending_machine composer install`

### Run tests
`docker-compose run --rm vending_machine ./vendor/bin/phpunit`
18 changes: 14 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,23 @@
"email": "kontakt@dawidmazur.eu"
}
],
"require": {},
"require": {
"php": "8.*"
},
"require-dev": {
"phpunit/phpunit": "^7"
"phpunit/phpunit": "^9",
"friendsofphp/php-cs-fixer": "^2.16",
"squizlabs/php_codesniffer": "^3.5",
"phpstan/phpstan": "^1.4"
},
"autoload": {
"psr-0": {
"VendingMachine": ["src", "tests"]
"psr-4": {
"VendingMachine\\": "src/",
"Tests\\": "tests/"
}
},
"scripts": {
"code-quality": "php ./vendor/bin/phpcs && php ./vendor/bin/phpstan analyse src tests"
}

}
Loading