mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
To restore coding standards of project, run ecs
This commit is contained in:
parent
e43a1a270f
commit
b6518c84c8
@ -17,16 +17,16 @@ final class GildedRose
|
|||||||
public function updateQuality(): void
|
public function updateQuality(): void
|
||||||
{
|
{
|
||||||
foreach ($this->items as $item) {
|
foreach ($this->items as $item) {
|
||||||
if ($item->name != 'Aged Brie' and $item->name != 'Backstage passes to a TAFKAL80ETC concert') {
|
if ($item->name !== 'Aged Brie' and $item->name !== 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if ($item->quality > 0) {
|
if ($item->quality > 0) {
|
||||||
if ($item->name != 'Sulfuras, Hand of Ragnaros') {
|
if ($item->name !== 'Sulfuras, Hand of Ragnaros') {
|
||||||
$item->quality = $item->quality - 1;
|
$item->quality = $item->quality - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($item->quality < 50) {
|
if ($item->quality < 50) {
|
||||||
$item->quality = $item->quality + 1;
|
$item->quality = $item->quality + 1;
|
||||||
if ($item->name == 'Backstage passes to a TAFKAL80ETC concert') {
|
if ($item->name === 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if ($item->sellIn < 11) {
|
if ($item->sellIn < 11) {
|
||||||
if ($item->quality < 50) {
|
if ($item->quality < 50) {
|
||||||
$item->quality = $item->quality + 1;
|
$item->quality = $item->quality + 1;
|
||||||
@ -41,15 +41,15 @@ final class GildedRose
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item->name != 'Sulfuras, Hand of Ragnaros') {
|
if ($item->name !== 'Sulfuras, Hand of Ragnaros') {
|
||||||
$item->sellIn = $item->sellIn - 1;
|
$item->sellIn = $item->sellIn - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item->sellIn < 0) {
|
if ($item->sellIn < 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') {
|
||||||
if ($item->quality > 0) {
|
if ($item->quality > 0) {
|
||||||
if ($item->name != 'Sulfuras, Hand of Ragnaros') {
|
if ($item->name !== 'Sulfuras, Hand of Ragnaros') {
|
||||||
$item->quality = $item->quality - 1;
|
$item->quality = $item->quality - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests;
|
namespace Tests;
|
||||||
|
|
||||||
|
use ApprovalTests\Approvals;
|
||||||
use GildedRose\GildedRose;
|
use GildedRose\GildedRose;
|
||||||
use GildedRose\Item;
|
use GildedRose\Item;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use ApprovalTests\Approvals;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This unit test uses [Approvals](https://github.com/approvals/ApprovalTests.php).
|
* This unit test uses [Approvals](https://github.com/approvals/ApprovalTests.php).
|
||||||
*
|
*
|
||||||
* There are two test cases here with different styles:
|
* There are two test cases here with different styles:
|
||||||
* <li>"foo" is more similar to the unit test from the 'Java' version
|
* <li>"foo" is more similar to the unit test from the 'Java' version
|
||||||
* <li>"thirtyDays" is more similar to the TextTest from the 'Java' version
|
* <li>"thirtyDays" is more similar to the TextTest from the 'Java' version
|
||||||
@ -20,23 +20,22 @@ use ApprovalTests\Approvals;
|
|||||||
*/
|
*/
|
||||||
class ApprovalTest extends TestCase
|
class ApprovalTest extends TestCase
|
||||||
{
|
{
|
||||||
|
public function testFoo(): void
|
||||||
public function testFoo(): void
|
|
||||||
{
|
{
|
||||||
$items = [new Item('foo', 0, 0)];
|
$items = [new Item('foo', 0, 0)];
|
||||||
$app = new GildedRose($items);
|
$app = new GildedRose($items);
|
||||||
$app->updateQuality();
|
$app->updateQuality();
|
||||||
|
|
||||||
Approvals::verifyList($items);
|
Approvals::verifyList($items);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testThirtyDays(): void
|
public function testThirtyDays(): void
|
||||||
{
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
$argv = ["", "30"];
|
$argv = ['', '30'];
|
||||||
include(__DIR__.'/../fixtures/texttest_fixture.php');
|
include(__DIR__ . '/../fixtures/texttest_fixture.php');
|
||||||
|
|
||||||
$output = ob_get_clean();
|
$output = ob_get_clean();
|
||||||
|
|
||||||
Approvals::approveString($output);
|
Approvals::approveString($output);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user