This project is to print the names of people whose birthday is today from the JSON list. If a person is born on 29th February, his birthday will be considered as 28th February in a leap year.
Project is created with:
- PHP
8.1.16 - PHPUnit
10.0.15 - Composer
2.5.4
To install dependencies run,
composer install To run the project in http://localhost:8080
php -S localhost:8080 -t .To run unit tests,
phpunit testsHere is the input file birthdays.json
[
["Doe", "John", "1982/10/08"],
["Wayne", "Bruce", "1965/01/30"],
["Gaga", "Lady", "1986/03/28"],
["Curry", "Mark", "1988/02/29"],
["Can", "Hurry", "1980/03/10" ],
["Saha", "Aparna", "2000/03/10"],
["Smith", "John", "2022/03/10"]
]
Here's the folder structure,
|____index.php
|____tests
| |____Controller
| | |____BirthdayControllerTest.php
| |____Service
| | |____DateServiceTest.php
| |____Assets
|____README.md
|____.gitignore
|____data
| |____birthdays.json
|____composer.json
|____src
| |____Config
| | |____Config.php
| |____Controller
| | |____BirthdayController.php
| |____Service
| | |____JsonDataService.php
| | |____DateService.php
./tests/Assets folder should have read-write permission. Run chmod 755
Here's output on 10.03.2023,
Can,Hurry
Saha,Aparna
Smith,John
Here's tests output,
PHPUnit 10.0.15 by Sebastian Bergmann and contributors.
Runtime: PHP 8.1.16
........ 8 / 8 (100%)
Time: 00:00.004, Memory: 22.30 MB
OK (8 tests, 9 assertions)
- Use
Mockeryin tests - Implement factory to remove
required_once()statements. - Output could be dockerized