Starting code for the GildedRose Refactoring Kata in many programming languages.
Go to file
2023-09-23 18:16:51 +07:00
.docker/php Refactor Code and write Unit test 2023-03-02 13:07:09 +07:00
config Refactor Code and write Unit test 2023-03-02 14:30:12 +07:00
fixtures Refactor Code and write Unit test 2023-03-02 13:07:09 +07:00
src Refactor Code and write Unit test 2023-03-02 14:30:12 +07:00
tests Refactor Code and write Unit test 2023-03-02 14:30:12 +07:00
.gitignore Refactor Code and write Unit test 2023-03-02 13:07:09 +07:00
composer.json Refactor Code and write Unit test 2023-03-02 13:07:09 +07:00
docker-compose.yml Create readme 2023-03-02 13:31:18 +07:00
ecs.php Refactor Code and write Unit test 2023-03-02 13:07:09 +07:00
GildedRoseRequirements.txt fix typo in requirements 2016-01-25 20:42:55 +01:00
license.txt added MIT license 2015-07-07 19:46:17 +02:00
phpstan.neon Refactor Code and write Unit test 2023-03-02 13:07:09 +07:00
phpunit.xml Refactor Code and write Unit test 2023-03-02 13:07:09 +07:00
README.md Already squashed 2023-09-23 18:16:51 +07:00

NFQ Group

GildedRose Kata - PHP Version

Installation

The kata uses:

See GitHub cloning a repository for details on how to create a local copy of this project on your computer.

git clone git@github.com:thang-tran-nfq/GildedRose-Refactoring-Kata.git

or

git clone https://github.com/thang-tran-nfq/GildedRose-Refactoring-Kata.git
Setup docker-compose
docker-compose up -d
Exec the docker container
docker exec -it php-cli bash 
Install all the dependencies using composer
cd ./GildedRose-Refactoring-Kata
composer install

Dependencies

The project uses composer to install:

Folders

  • src - contains the two classes:
    • Item.php - this class should not be changed
    • GildedRose.php - this class needs to be refactored, and the new feature added
    • Items - This folder contains all Items Class
      • Abstract - This folder store Abstract of all Item Class
      • Interface - This folder store Interface of all Item Class
      • Factory - This folder store Factory, create Item instance
      • AgedBrieItem.php
      • BackstagePassItem.php
      • ConjuredItem.php
      • NormalItem.php
      • SulfurasItem.php
  • tests - contains the tests
  • Fixture
    • texttest_fixture.php this could be used by an ApprovalTests, or run from the command line

Fixture

To run the fixture from the php directory:
php .\fixtures\texttest_fixture.php 10

Change 10 to the required days.

Testing

PHPUnit is configured for testing, a composer script has been provided. To run the unit tests, from the root of the PHP project run:

composer tests

Tests with Coverage Report

To run all test and generate a html coverage report run:

composer test-coverage

The test-coverage report will be created in /builds, it is best viewed by opening /builds/index.html in your browser.

The XDEbug extension is required for generating the coverage report.

Code Standard

Easy Coding Standard (ECS) is configured for style and code standards, PSR-12 is used. The current code is not upto standard!

Check Code

To check code, but not fix errors:

composer check-cs

Fix Code

ECS provides may code fixes, automatically, if advised to run --fix, the following script can be run:

composer fix-cs

Static Analysis

PHPStan is used to run static analysis checks:

composer phpstan

Happy coding! test 1 test 2 test 3 test 4 test 5