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

Php update #86

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ Imagine a social networking website for travellers:
- We CANNOT introduce state in the TripService
- TripService is stateless. Introducing state may cause multi-thread issues

## Problem to solve
Unit tests for TripService must not call the real UserSession and TripDAO. It should solely focus on the TripService. The real classes have dependencies on resources (HTTP session, database) that are not available at unit test level. Unit tests will break if involving the real collaborators.

![image](https://user-images.githubusercontent.com/6353105/232825748-52649c10-eb15-40c2-bdf7-3cb42874980e.png)


[Extracted rules from here](https://miro.com/app/board/uXjVOanLakQ=/)
22 changes: 20 additions & 2 deletions php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,31 @@ wget http://getcomposer.org/composer.phar
php composer.phar install
```

Next, to execute the unit tests you need run this from the *php* directory
Next, to execute the unit tests you need run this from the *php* directory
```shell
php bin/phpunit
./vendor/bin/phpunit
```
or

you could use composer for this
```shell
composer test
```

## Coverage

To run with coverage you will have to configure your system with this:

Linux and macOS
```shell
export XDEBUG_MODE=coverage
```

Windows
```shell
set XDEBUG_MODE=coverage
```

When running the tests a coverage report should be generated automatically in simple text format and html report. If you want
to visualize it from the browser you can open the `coverage/report/index.html` file in a browser after running the tests.

Expand Down
11 changes: 8 additions & 3 deletions php/composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
{
"name": "sandromancuso/trip-service-kata",
"description": "Kata for a legacy code hands-on session. The objective is to write tests and refactor the given legacy code.",
"type": "project",
"keywords": ["TripService", "kata"],
"require": {
"php": ">=8.3"
},
"require-dev": {
"php": "^7.0",
"phpunit/phpunit": "^6.5"
"phpunit/phpunit": "^10.3"
},
"scripts": {
"test": "phpunit"
"test": "./vendor/bin/phpunit",
"test-coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html coverage"
},
"authors": [
{
Expand Down
Loading