Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ddd refactor #1

Open
wants to merge 76 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
7ff7b63
- Added DDD initial commit. Added unit tests.
mnsami Oct 30, 2018
b84675b
- require ramsey/uuid to use UUID as ids.
mnsami Oct 30, 2018
994af8b
- Fix makefile for travis
mnsami Oct 30, 2018
226a0ab
try to make travis happy
mnsami Oct 30, 2018
ac583bf
make travis happy
mnsami Oct 30, 2018
ada1a6f
use php 7.2
mnsami Oct 30, 2018
4e98ac0
make phpcs happy
mnsami Oct 30, 2018
62ee466
better Makefile
mnsami Oct 30, 2018
90139a5
- red tests for creating valid player
mnsami Oct 30, 2018
4c144f5
- green tests for getting player token after creation.
mnsami Oct 30, 2018
4d8ee46
- green tests after refactor function.
mnsami Oct 30, 2018
bf9c95f
- green tests for Player.
mnsami Oct 30, 2018
db84ced
More player tests.
mnsami Oct 30, 2018
eb34079
Green Board / Cell tests.
mnsami Nov 1, 2018
e9fce81
Green Board tests
mnsami Nov 1, 2018
91d82b2
push modified files
mnsami Nov 21, 2018
1160d3a
add phpstan for static analysis
mnsami Nov 21, 2018
2f730bc
add phpstan for doctrine
mnsami Nov 21, 2018
bb1c8f6
add support for phpstan
mnsami Nov 21, 2018
70cd3bc
better travis job
mnsami Nov 21, 2018
44be350
fix readme
mnsami Nov 22, 2018
17297a2
adding first Domain event and AggregateRoot
mnsami Jun 11, 2019
e82a7f6
Record PlayerCreated event.
mnsami Jun 11, 2019
a945305
green tests for PlayerId.
mnsami Jun 11, 2019
27b2279
green tests for PlayerCreated.
mnsami Jun 11, 2019
9506df5
green tests for PlayerCreated.
mnsami Jun 11, 2019
9204058
docker make commands.
mnsami Jun 11, 2019
a98bb81
better makefile.
mnsami Jun 12, 2019
7e91cea
green tests GameId.
mnsami Jun 12, 2019
7c70d73
green tests Game.
mnsami Jun 12, 2019
18892db
fixes
mnsami Jun 12, 2019
fd52704
red game tests
mnsami Jun 12, 2019
bd7f0d4
green game tests
mnsami Jun 12, 2019
dd35b18
adding CreatePlayerCommand and Handler.
mnsami Jun 12, 2019
a291898
adding EventStore.
mnsami Jun 12, 2019
2809122
Add CommandBus.
mnsami Jun 12, 2019
db8385c
red tests after folder restructure.
mnsami Jun 12, 2019
3b40955
green board tests
mnsami Jun 12, 2019
2dbf3b8
green Game tests
mnsami Jun 12, 2019
3d4c6ff
green GameId tests
mnsami Jun 12, 2019
7466f5f
green PlayerCreated tests
mnsami Jun 12, 2019
f247b43
green PlayerIdTest tests
mnsami Jun 12, 2019
53974c5
green PlayerNameTest tests
mnsami Jun 12, 2019
c7f675b
green PlayerTest tests
mnsami Jun 12, 2019
977d093
green PlayerTokenTest tests
mnsami Jun 12, 2019
da42593
fixes
mnsami Jun 12, 2019
2991941
CreatePlayer Dto, command and handler.
mnsami Jun 12, 2019
f112a0a
more player tests.
mnsami Jun 12, 2019
06d6cff
Game repository.
mnsami Jun 13, 2019
e0e327a
green PlayerRepository tests.
mnsami Jun 13, 2019
89b83d9
red Game tests.
mnsami Jun 13, 2019
0af4f3f
green Game tests.
mnsami Jun 13, 2019
77fc561
CreateNewGame command and handler.
mnsami Jun 13, 2019
67901f9
throw error if wrong command passed.
mnsami Jun 13, 2019
bc67e75
Input interface.
mnsami Jun 13, 2019
e018f65
CreateNewPlayerHandler test.
mnsami Jun 14, 2019
4638b86
fix composer.
mnsami Jun 14, 2019
189b356
update composer packages
mnsami Jun 18, 2019
08892e1
play is not available in ddd branch yet.
mnsami Jul 1, 2019
b1b8de6
more verbosity in Makefile
mnsami Jul 10, 2019
45c158b
make cell accept string and not playertoken.
mnsami Oct 22, 2019
0719165
add move and position.
mnsami Oct 23, 2019
795b937
add player turn
mnsami Oct 24, 2019
71014f7
use php alpine for lighter image.
mnsami Mar 13, 2020
e2a2ae6
upgrade to php 4
mnsami Mar 13, 2020
db597e7
add phpstan and upgrade to php 8.0
mnsami Sep 29, 2022
3ee370b
set php version
mnsami Sep 29, 2022
9b2b5ab
remove cell set
mnsami Sep 29, 2022
ed14a22
refactor player play
mnsami Oct 4, 2022
601842d
refactor to create application commandbus
mnsami Oct 4, 2022
f56ae57
refactor to create application commandbus
mnsami Oct 4, 2022
4c296cd
Merge branch 'ddd-refactor' of github.com:mnsami/tic-tac-toe into ddd…
mnsami Oct 4, 2022
65f0e32
remove env
mnsami Oct 4, 2022
a56c959
add it again
mnsami Oct 4, 2022
8feceb6
remove travis
mnsami Oct 5, 2022
b6caa80
add github actions
mnsami Oct 5, 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
70 changes: 70 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Testing

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Validate composer.json and composer.lock
run: make lint-composer

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
run: make composer

- name: Pack and upload the build
uses: actions/upload-artifact@v2
with:
name: website
path: .

test:
if: ${{ success() }}
needs: build
runs-on: ubuntu-latest
steps:
- name: Download site build
uses: actions/download-artifact@v2
with:
name: website
path: .

- name: Cache Composer packages
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Lint PHP files
run: make lint-php

- name: Check PHP styles
run: make phpcs

- name: Static Analysis
run: make stan

- name: Unit Tests
run: make tests

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
vendor/*
coverage/*
bin/*

!bin/.gitkeep
.phpunit.result.cache
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

66 changes: 53 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,72 @@
COMPOSER ?= composer
PROJECT = "Tic-Tac-Toe"
DOCKER_COMPOSE = docker-compose
PROJECT = "TicTacToe."
COMPOSE_PROJECT_NAME ?= $(notdir $(shell pwd))
PHP_SERVICE = php
PHP_CMD = php

all: clear lint-composer lint-php composer phpcs test coverage
ifeq ($(RUNNER), travis)
CMD :=
else
CMD := docker-compose exec $(PHP_SERVICE)
endif

all: container-up clear composer lint-composer lint-php phpcs tests

lint-composer:
@echo "\n==> Validating composer.json and composer.lock:"
$(COMPOSER) validate --strict
$(CMD) $(COMPOSER) validate --strict

lint-php:
@echo "\n==> Validating all php files:"
@find src -type f -name \*.php | while read file; do php -l "$$file" || exit 1; done
$(CMD) find src tests -type f -iname '*php' -exec $(PHP_CMD) -l {} \;

composer:
$(COMPOSER) install
@echo "\n==> Running composer install, runner $(RUNNER)"
$(CMD) $(COMPOSER) install

lint: lint-composer lint-php

clear:
rm -rf vendor
$(CMD) rm -rf vendor
$(CMD) rm -rf bin/php*

phpcs:
php vendor/bin/phpcs . -np
@echo "\n==> Checking style guidelines"
$(CMD) bin/phpcs --standard=phpcs.xml -p

phpcbf:
vendor/bin/phpcbf src/*

test:
vendor/bin/phpunit
$(CMD) bin/phpcbf

coverage:
vendor/bin/phpunit --coverage-html coverage
@echo "\n==> Generating coverage report"
$(CMD) bin/phpunit --coverage-html coverage

tests:
@echo "\n==> Running tests"
$(CMD) bin/phpunit

stan:
@echo "\n==> Running stan for analysis"
$(CMD) bin/phpstan analyse --memory-limit=-1 src

container-stop:
@echo "\n==> Stopping docker container"
$(DOCKER_COMPOSE) stop

container-down:
@echo "\n==> Removing docker container"
$(DOCKER_COMPOSE) down

container-remove:
@echo "\n==> Removing docker container(s)"
$(DOCKER_COMPOSE) rm

container-up:
@echo "\n==> Docker container building and starting ..."
$(DOCKER_COMPOSE) up --build -d

tear-down: clear container-stop container-down container-remove


.PHONY: lint-php lint-composer phpcs phpcbf test coverage composer clear
.PHONY: lint-php lint-composer phpcs phpcbf composer clear tests coverage container-up container-stop container-down container-remove
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# tic-tac-toe-sami

[![Build Status](https://travis-ci.org/mnsami/tic-tac-toe.svg?branch=master)](https://travis-ci.org/mnsami/tic-tac-toe)
# tic-tac-toe

### Description

A php-cli Tic-Tac-Toe simple two players game.

### Requirements

1. `php >= 7.0` (required for `phpunit v6.1`)
1. `php >= 8`
2. `Docker`

### Installation

Expand All @@ -18,11 +17,11 @@ Run `make all` will do all the magic for you.

### Start playing

To start playing the game, you need to run `php main.php`
TODO, refactoring has to be finished first.

### Unit tests

To generate tests report, run `make test`.
To generate tests report, run `make tests`.

### Coverage

Expand Down
Empty file added bin/.gitkeep
Empty file.
29 changes: 22 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,34 @@
"type": "project",
"authors": [
{
"name": "Mina Nabil Sami"
"name": "Mina Nabil Sami",
"email": "[email protected]"
}
],
"require": {
"php": ">=7",
"squizlabs/php_codesniffer": "2.*"
},
"require-dev": {
"phpunit/phpunit": "6.1.*"
"php": ">=8",
"ramsey/uuid": "^3.8"
},
"autoload": {
"psr-0": {
"TicTacToe": "src/"
"TicTacToe": "./src/"
}
},
"autoload-dev": {
"psr-4": {
"unit\\TicTacToe\\": "./tests/unit"
}
},
"config": {
"bin-dir": "bin",
"platform": {
"php": "8"
},
"sort-packages": true
},
"require-dev": {
"phpstan/phpstan": "^1.8",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.7"
}
}
Loading