diff --git a/php/tests/behat/contexts/ServiceLevelContext.php b/php/tests/behat/contexts/ServiceLevelContext.php index 1253d94a..bfce862f 100644 --- a/php/tests/behat/contexts/ServiceLevelContext.php +++ b/php/tests/behat/contexts/ServiceLevelContext.php @@ -16,36 +16,72 @@ class ServiceLevelContext implements Context private Item $item; private GildedRose $gildedRose; + private function createItem(string $name, int $initialSellIn, int $initialQuality): void + { + $this->item = new Item($name, $initialSellIn, $initialQuality); + $this->gildedRose = new GildedRose([$this->item]); + } + #[Then('I should see :expectedOutput')] public function iShouldSee(string $expectedOutput): void { Assert::assertEquals([$expectedOutput], $this->result); } - #[Given('an item with a sell_in of :initialellIn and a quality of :initialQuality')] - public function anItemWithASellInOfAndAQualityOf(int $initialellIn, int $initialQuality) + #[Given('an item with a sell-in of :initialSellIn and a quality of :initialQuality')] + public function anItemWithASellInOfAndAQualityOf(int $initialSellIn, int $initialQuality): void { - $this->item = new Item('foo', $initialellIn, $initialQuality); - $this->gildedRose = new GildedRose([$this->item]); + $this->createItem('foo', $initialSellIn, $initialQuality); + } + + #[Given('an item with a sell-in of :initialSellIn')] + public function anItemWithASellInOf(int $initialSellIn): void + { + $this->createItem('foo', $initialSellIn, 20); } #[When('I update the quality')] - public function iUpdateTheQuality() + #[When('I update the sell-in')] + public function iUpdateTheQuality(): void { $this->gildedRose->updateQuality(); } #[Then('the item should have a quality of :expectedQuality')] - public function theItemShouldHaveAQualityOf($expectedQuality) + public function theItemShouldHaveAQualityOf($expectedQuality): void { Assert::assertEquals($expectedQuality, $this->item->quality); } #[When('I update the quality :noOfDays times')] - public function iUpdateTheQualityTimes(int $noOfDays) + public function iUpdateTheQualityTimes(int $noOfDays): void { for ($i = 0; $i < $noOfDays; $i++) { $this->gildedRose->updateQuality(); } } + + #[Then('the item should have a sell-in of :expectedSellIn')] + public function theItemShouldHaveASellInOf(int $sellIn): void + { + Assert::assertEquals($sellIn, $this->item->sellIn); + } + + #[Given('some brie with a sell-in of :initialSellIn and a quality of :initialQuality')] + public function someBrieWithASellInOfAndAQualityOf(int $initialSellIn, int $initialQuality): void + { + $this->createItem('Aged Brie', $initialSellIn, $initialQuality); + } + + #[Given('a backstage pass with a sell-in of :initialSellIn and a quality of :initialQuality')] + public function aBackstagePassWithASellInOfAndAQualityOf(int $initialSellIn, int $initialQuality): void + { + $this->createItem('Backstage passes to a TAFKAL80ETC concert', $initialSellIn, $initialQuality); + } + + #[Given('a sulfura with a sell-in of :initialSellIn and a quality of :initialQuality')] + public function aSulfuraWithASellInOfAndAQualityOf(int $initialSellIn, int $initialQuality): void + { + $this->createItem('Sulfuras, Hand of Ragnaros', $initialSellIn, $initialQuality); + } } diff --git a/php/tests/behat/feature_files/backstage-passes.feature b/php/tests/behat/feature_files/backstage-passes.feature new file mode 100644 index 00000000..36795e32 --- /dev/null +++ b/php/tests/behat/feature_files/backstage-passes.feature @@ -0,0 +1,28 @@ +Feature: Backstage passes quality changes + In order to keep track of backstage passes + As a shopkeeper + I want to see the quality of backstage passes change appropriately + + + Scenario: Backstage pass quality update + Given a backstage pass with a sell-in of 20 and a quality of 20 + When I update the quality + Then the item should have a quality of 21 + + + Scenario: Backstage pass with 10 days left + Given a backstage pass with a sell-in of 10 and a quality of 20 + When I update the quality + Then the item should have a quality of 22 + + + Scenario: Backstage pass with 5 days left + Given a backstage pass with a sell-in of 5 and a quality of 20 + When I update the quality + Then the item should have a quality of 23 + + + Scenario: Backstage pass after the concert + Given a backstage pass with a sell-in of 0 and a quality of 20 + When I update the quality + Then the item should have a quality of 0 diff --git a/php/tests/behat/feature_files/brie.feature b/php/tests/behat/feature_files/brie.feature new file mode 100644 index 00000000..7314ee1f --- /dev/null +++ b/php/tests/behat/feature_files/brie.feature @@ -0,0 +1,16 @@ +Feature: Brie quality changes + In order to keep track of aged brie + As a shopkeeper + I want to see the quality of aged brie increase + + + Scenario: Aged brie quality update + Given some brie with a sell-in of 20 and a quality of 20 + When I update the quality + Then the item should have a quality of 21 + + + Scenario: Aged brie at maximum quality + Given some brie with a sell-in of 20 and a quality of 50 + When I update the quality + Then the item should have a quality of 50 diff --git a/php/tests/behat/feature_files/default-quality-degradation.feature b/php/tests/behat/feature_files/default-quality-degradation copy 2.feature similarity index 58% rename from php/tests/behat/feature_files/default-quality-degradation.feature rename to php/tests/behat/feature_files/default-quality-degradation copy 2.feature index 6ce4dbe4..4d712852 100644 --- a/php/tests/behat/feature_files/default-quality-degradation.feature +++ b/php/tests/behat/feature_files/default-quality-degradation copy 2.feature @@ -5,12 +5,18 @@ Feature: Default quality degradation Scenario: Single quality update - Given an item with a sell_in of 20 and a quality of 20 + Given an item with a sell-in of 20 and a quality of 20 When I update the quality Then the item should have a quality of 19 Scenario: Quality updates over multiple days - Given an item with a sell_in of 20 and a quality of 20 + Given an item with a sell-in of 20 and a quality of 20 When I update the quality 5 times Then the item should have a quality of 15 + + +Scenario: Quality cannot be negative + Given an item with a sell-in of 20 and a quality of 0 + When I update the quality + Then the item should have a quality of 0 diff --git a/php/tests/behat/feature_files/sellin-tracking.feature b/php/tests/behat/feature_files/sellin-tracking.feature new file mode 100644 index 00000000..de8ddc32 --- /dev/null +++ b/php/tests/behat/feature_files/sellin-tracking.feature @@ -0,0 +1,10 @@ +Feature: Sell-in tracking + In order to keep track of the sell-by date of an item + As a shopkeeper + I want to see the sell-in value decremented each day + + + Scenario: Basic sell-in tracking + Given an item with a sell-in of 20 + When I update the sell-in + Then the item should have a sell-in of 19 diff --git a/php/tests/behat/feature_files/sulfuras.feature b/php/tests/behat/feature_files/sulfuras.feature new file mode 100644 index 00000000..88e165da --- /dev/null +++ b/php/tests/behat/feature_files/sulfuras.feature @@ -0,0 +1,11 @@ +Feature: Sulfuras + In order to keep track of sulfuras + As a shopkeeper + I want to see the quality and sell-in of sulfuras stay the same + + + Scenario: Sulfuras quality and sell-in not changing + Given a sulfura with a sell-in of 20 and a quality of 20 + When I update the quality + Then the item should have a quality of 20 + And the item should have a sell-in of 20