mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
Backstage regular product runs quality max test
and quality dip down to 0 test OK.
This commit is contained in:
parent
4d2389857a
commit
cd58aa0141
@ -62,32 +62,32 @@ final class GildedRose
|
|||||||
if ($item->name === 'Sulfuras, Hand of Ragnaros') {
|
if ($item->name === 'Sulfuras, Hand of Ragnaros') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item->name !== 'Aged Brie' && $item->name !== 'Backstage passes to a TAFKAL80ETC concert') {
|
if ($item->sell_in >= 0) {
|
||||||
if ($item->quality > 0) {
|
if ($item->name !== 'Aged Brie' && $item->name !== 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if (strstr($item->name, 'Conjured', true) === '') {
|
if ($item->quality > 0) {
|
||||||
$item->quality -= 2;
|
if (strstr($item->name, 'Conjured', true) === '') {
|
||||||
} else {
|
$item->quality -= 2;
|
||||||
$item->quality--;
|
} else {
|
||||||
|
$item->quality--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
if ($item->quality < 50) {
|
||||||
if ($item->quality < 50) {
|
if ($item->name === 'Aged Brie') {
|
||||||
if ($item->name === 'Aged Brie') {
|
|
||||||
$item->quality++;
|
|
||||||
} else if ($item->name === 'Backstage passes to a TAFKAL80ETC concert') {
|
|
||||||
if ($item->sell_in <= 10 && $item->sell_in > 5) {
|
|
||||||
$item->quality += 2;
|
|
||||||
} else if ($item->sell_in <= 5) {
|
|
||||||
$item->quality += 3;
|
|
||||||
} else if ($item->sell_in > 10) {
|
|
||||||
$item->quality++;
|
$item->quality++;
|
||||||
|
} else if ($item->name === 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
|
if ($item->sell_in <= 10 && $item->sell_in > 5) {
|
||||||
|
$item->quality += 2;
|
||||||
|
} else if ($item->sell_in <= 5) {
|
||||||
|
$item->quality += 3;
|
||||||
|
} else if ($item->sell_in > 10) {
|
||||||
|
$item->quality++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if ($item->sell_in < 0) {
|
|
||||||
if ($item->name !== 'Aged Brie') {
|
if ($item->name !== 'Aged Brie') {
|
||||||
if ($item->name === 'Backstage passes to a TAFKAL80ETC concert') {
|
if ($item->name === 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
$item->quality = 0;
|
$item->quality = 0;
|
||||||
|
|||||||
@ -173,4 +173,49 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase
|
|||||||
$this->assertEquals(9, $app->getItems()[2]->sell_in);
|
$this->assertEquals(9, $app->getItems()[2]->sell_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test stage prouct jumps to 0 quality after sale pass
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testQualityDipToZero()
|
||||||
|
{
|
||||||
|
$items = [
|
||||||
|
new Item('Backstage passes to a TAFKAL80ETC concert', 1, 14),
|
||||||
|
];
|
||||||
|
|
||||||
|
$interval = 3;
|
||||||
|
$app = new GildedRose($items);
|
||||||
|
|
||||||
|
for ($i = 0; $i < $interval; $i++) {
|
||||||
|
$app->updateQuality();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEquals(0, $app->getItems()[0]->quality);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regular products max quality assessment value limit
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testQualityMaxLimitOnSimpleProduct()
|
||||||
|
{
|
||||||
|
$items = [
|
||||||
|
new Item('Backstage passes to a TAFKAL80ETC concert', 20, 49),
|
||||||
|
new Item('Backstage passes to a TAFKAL80ETC concert', 20, 48),
|
||||||
|
new Item('Backstage passes to a TAFKAL80ETC concert', 20, 50),
|
||||||
|
];
|
||||||
|
|
||||||
|
$interval = 3;
|
||||||
|
$app = new GildedRose($items);
|
||||||
|
|
||||||
|
for ($i = 0; $i < $interval; $i++) {
|
||||||
|
$app->updateQuality();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEquals(50, $app->getItems()[0]->quality);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user