From 91f8f6c62bed4ec97614e621a3efabb0ba751582 Mon Sep 17 00:00:00 2001 From: Povilas Brilius Date: Fri, 1 May 2020 21:33:08 +0300 Subject: [PATCH] Stable product running OK. --- php7/src/GildedRose.php | 10 ++++++++++ php7/test/GildedRoseTest.php | 33 ++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/php7/src/GildedRose.php b/php7/src/GildedRose.php index 40127d29..542f2640 100644 --- a/php7/src/GildedRose.php +++ b/php7/src/GildedRose.php @@ -41,6 +41,16 @@ final class GildedRose $this->_items = $items; } + /** + * Items getter + * + * @return array + */ + public function getItems() + { + return $this->_items; + } + /** * Advance by a time frame of 1 day * diff --git a/php7/test/GildedRoseTest.php b/php7/test/GildedRoseTest.php index f5760cbb..84a36f65 100644 --- a/php7/test/GildedRoseTest.php +++ b/php7/test/GildedRoseTest.php @@ -22,11 +22,34 @@ namespace App; */ class GildedRoseTest extends \PHPUnit\Framework\TestCase { - public function testFoo() + /** + * Product, that is unaffected by processing + * + * @return void + */ + public function testStableUnaffected() { - $items = [new Item("foo", 0, 0)]; - $gildedRose = new GildedRose($items); - $gildedRose->updateQuality(); - $this->assertEquals("fixme", $items[0]->name); + /** + * 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); } + }