PHP: Add an Approval base test similar to Java-Approvals and CS-xunit-verify.

This commit is contained in:
Peter Kofler committed 2023-11-29 12:13:35 +01:00
1 parent 7d758b5dc0
commit 4d5ca7b311
3 files changed
+45 -374

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace Tests;
use GildedRose\GildedRose;
use GildedRose\Item;
use PHPUnit\Framework\TestCase;
use ApprovalTests\Approvals;
/**
* This unit test uses [Approvals](https://github.com/approvals/ApprovalTests.php).
*
* There are two test cases here with different styles:
* <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
*
* I suggest choosing one style to develop and deleting the other.
*/
class ApprovalTest extends TestCase
{
public function testFoo(): void
{
$items = [new Item('foo', 0, 0)];
$app = new GildedRose($items);
$app->updateQuality();
Approvals::verifyList($items);
}
public function testThirtyDays(): void
{
ob_start();
$argv = ["", "30"];
include(__DIR__.'/../fixtures/texttest_fixture.php');
$output = ob_get_clean();
Approvals::approveString($output);
}
}