Quantity tests on simple products running.

This commit is contained in:
Povilas Brilius 2020-05-01 23:13:38 +03:00
parent 7c001fbc5f
commit 4e98c86590
2 changed files with 29 additions and 3 deletions

View File

@ -63,7 +63,6 @@ final class GildedRose
continue;
}
if ($item->name !== 'Aged Brie' && $item->name !== 'Backstage passes to a TAFKAL80ETC concert') {
if ($item->quality > 0) {
if (strstr($item->name, 'Conjured', true) === '') {
@ -88,7 +87,6 @@ final class GildedRose
}
}
if ($item->sell_in < 0) {
if ($item->name !== 'Aged Brie') {
if ($item->name === 'Backstage passes to a TAFKAL80ETC concert') {

View File

@ -80,6 +80,34 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(5, $app->getItems()[1]->sell_in);
$this->assertEquals(1, $app->getItems()[2]->sell_in);
}
}
/**
* Simple products quality and quantity test
*
* @return void
*/
public function testSimpleProducts()
{
$items = [
new Item('Elixir of the Mongoose', 16, 24),
new Item('Elixir of the Mongoose', 14, 32),
new Item('Elixir of the Mongoose', 12, 36),
new Item('Elixir of the Mongoose', 18, 25),
];
$interval = 5;
$app = new GildedRose($items);
for ($i = 0; $i < $interval; $i++) {
$app->updateQuality();
}
$this->assertEquals(11, $app->getItems()[0]->sell_in);
$this->assertEquals(9, $app->getItems()[1]->sell_in);
$this->assertEquals(7, $app->getItems()[2]->sell_in);
$this->assertEquals(13, $app->getItems()[3]->sell_in);
}
}