Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abenevaut/php-fizzbuzz-kata
Get started with PHPUnit through FizzBuzz exercises
https://github.com/abenevaut/php-fizzbuzz-kata
Last synced: 7 days ago
JSON representation
Get started with PHPUnit through FizzBuzz exercises
- Host: GitHub
- URL: https://github.com/abenevaut/php-fizzbuzz-kata
- Owner: abenevaut
- Created: 2023-10-17T14:55:20.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-11-20T17:01:30.000Z (about 1 year ago)
- Last Synced: 2024-12-21T05:34:56.897Z (15 days ago)
- Language: PHP
- Homepage:
- Size: 46.9 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# KATA: Test your FizzBuzz
- [Exercise Summary](https://codingdojo.org/kata/FizzBuzz/)
## Setup your computer
- [Download PHP](https://windows.php.net/downloads/releases/php-8.2.11-nts-Win32-vs16-x64.zip)
- [Download Composer](https://getcomposer.org/download/)## Initialize the project
```
git clone
cd kata-phpunit
composer install
php src/main.php
```# Do the KATA
Following [this exercise summary](https://codingdojo.org/kata/FizzBuzz/):
## 0. clone the repository
## 1. setup [PHPUnit](https://phpunit.de/)
## 2. code & test the FizzBuzz inside the FizzBuzz class (`src/FizzBuzz.php`)
## 3. create your first mockexecute fizzbuzz inside `transformFromDatabase()` on an integers list provided by Database::getNumbers().
but.. you cannot change `Database::getNumbers()`, so mock it!### Add followings files:
- `src/DatabaseInterface.php`
```
database->getNumbers();throw new \Exception('Execute the FizzBuzz on your array of numbers');
}
```- `src/main.php`
```
countTo100();
foreach ($lines as $line) {
echo $line . PHP_EOL;
}
} catch (Exception $e) {
echo $e->getMessage();
}try {
$lines = $fizzBuzz->transformFromDatabase();
} catch (Exception $e) {
if (501 === $e->getCode()) {
echo 'Database::getNumbers() not implemented';
}
}
```## 4. bonus: do a mock of a database interface that should return a list of Numbers, based on `DatabaseInterface`
## 5. bonus: install & use [infection](https://infection.github.io/guide/)You are stuck in a step ? Checkout `stepX` branch to get help