mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
86 lines
2.4 KiB
PHP
86 lines
2.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* PHP version 7
|
|
*
|
|
* @category PHP_Unit
|
|
* @package Drill_Field
|
|
* @author Povilas Brilius <pbrilius@gmail.com>
|
|
* @license eupl-1.1 https://help.github.com/en/github/creating-cloning-and-archiving-repositories/licensing-a-repository
|
|
* @link pbgroupeu.wordpress.com
|
|
*/
|
|
namespace App;
|
|
|
|
/**
|
|
* Units cover up
|
|
*
|
|
* @category PHP_Unit
|
|
* @package GildenRose
|
|
* @author Povilas Brilius <pbrilius@gmail.com>
|
|
* @license eupl-1.1 https://help.github.com/en/github/creating-cloning-and-archiving-repositories/licensing-a-repository
|
|
* @link pbgroupeu.wordpress.com
|
|
*/
|
|
class GildedRoseTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
/**
|
|
* Product, that is unaffected by processing
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testStableUnaffected()
|
|
{
|
|
/**
|
|
* Stock items
|
|
*
|
|
* @var Item[] $items
|
|
*/
|
|
$items = [
|
|
new Item('Sulfuras, Hand of Ragnaros', 2, 80),
|
|
new Item('Sulfuras, Hand of Ragnaros', -1, 80),
|
|
];
|
|
|
|
$interval = 6;
|
|
$app = new GildedRose($items);
|
|
|
|
for ($i = 0; $i < $interval; $i++) {
|
|
$app->updateQuality();
|
|
}
|
|
|
|
$this->assertEquals(2, $app->getItems()[0]->sell_in);
|
|
$this->assertEquals(-1, $app->getItems()[1]->sell_in);
|
|
$this->assertEquals(80, $app->getItems()[0]->quality);
|
|
$this->assertEquals(80, $app->getItems()[1]->quality);
|
|
}
|
|
|
|
/**
|
|
* Test geometricc progression increasing quality
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testGeometricQualityProgression()
|
|
{
|
|
$items = [
|
|
new Item('Backstage passes to a TAFKAL80ETC concert', 12, 15),
|
|
new Item('Backstage passes to a TAFKAL80ETC concert', 7, 14),
|
|
new Item('Backstage passes to a TAFKAL80ETC concert', 3, 18),
|
|
];
|
|
|
|
$interval = 2;
|
|
$app = new GildedRose($items);
|
|
|
|
for ($i = 0; $i < $interval; $i++) {
|
|
$app->updateQuality();
|
|
}
|
|
|
|
$this->assertEquals(17, $app->getItems()[0]->quality);
|
|
$this->assertEquals(18, $app->getItems()[1]->quality);
|
|
$this->assertEquals(24, $app->getItems()[2]->quality);
|
|
|
|
$this->assertEquals(10, $app->getItems()[0]->sell_in);
|
|
$this->assertEquals(5, $app->getItems()[1]->sell_in);
|
|
$this->assertEquals(1, $app->getItems()[2]->sell_in);
|
|
|
|
}
|
|
|
|
}
|