Skip to content

Commit

Permalink
Merge pull request #86 from khru/php-update
Browse files Browse the repository at this point in the history
Php update
  • Loading branch information
sandromancuso committed Jun 19, 2024
2 parents 3885483 + f2dcb07 commit 746b55e
Show file tree
Hide file tree
Showing 9 changed files with 814 additions and 621 deletions.
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

0 comments on commit 746b55e

Please sign in to comment.