mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
Measured geometric progression metriccs.
This commit is contained in:
parent
91f8f6c62b
commit
7c001fbc5f
@ -63,7 +63,6 @@ final class GildedRose
|
||||
continue;
|
||||
}
|
||||
|
||||
$item->sell_in--;
|
||||
|
||||
if ($item->name !== 'Aged Brie' && $item->name !== 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if ($item->quality > 0) {
|
||||
@ -78,16 +77,18 @@ final class GildedRose
|
||||
if ($item->name === 'Aged Brie') {
|
||||
$item->quality++;
|
||||
} else if ($item->name === 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if ($item->sell_in <= 10) {
|
||||
if ($item->sell_in <= 10 && $item->sell_in > 5) {
|
||||
$item->quality += 2;
|
||||
}
|
||||
if ($item->sell_in <= 5) {
|
||||
} else if ($item->sell_in <= 5) {
|
||||
$item->quality += 3;
|
||||
} else if ($item->sell_in > 10) {
|
||||
$item->quality++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($item->sell_in < 0) {
|
||||
if ($item->name !== 'Aged Brie') {
|
||||
if ($item->name === 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
@ -103,6 +104,8 @@ final class GildedRose
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$item->sell_in--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,4 +52,34 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase
|
||||
$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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user