From 4e98c86590eab91e6438357a476343bf1acc2768 Mon Sep 17 00:00:00 2001 From: Povilas Brilius Date: Fri, 1 May 2020 23:13:38 +0300 Subject: [PATCH] Quantity tests on simple products running. --- php7/src/GildedRose.php | 2 -- php7/test/GildedRoseTest.php | 30 +++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/php7/src/GildedRose.php b/php7/src/GildedRose.php index 35df3743..261ff79b 100644 --- a/php7/src/GildedRose.php +++ b/php7/src/GildedRose.php @@ -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') { diff --git a/php7/test/GildedRoseTest.php b/php7/test/GildedRoseTest.php index 1b1ede0e..18e93b51 100644 --- a/php7/test/GildedRoseTest.php +++ b/php7/test/GildedRoseTest.php @@ -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); + + } }