mirror of
https://github.com/ysoftdevs/Theatrical-Players-Refactoring-Kata.git
synced 2026-03-13 05:45:56 +01:00
Add PHP version of kata
This commit is contained in:
61
php/tests/StatementPrinterTest.php
Normal file
61
php/tests/StatementPrinterTest.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ApprovalTests\Approvals;
|
||||
|
||||
use Theatrical\StatementPrinter;
|
||||
use Theatrical\Play;
|
||||
use Theatrical\Performance;
|
||||
use Theatrical\Invoice;
|
||||
|
||||
final class StatementPrinterTest extends TestCase
|
||||
{
|
||||
public function testListOfPlayIsCorrect() : void
|
||||
{
|
||||
$plays = [
|
||||
"hamlet" => new Play("Hamlet", "tragedy"),
|
||||
"as-like" => new Play("As You Like It", "comedy"),
|
||||
"othello" => new Play("Othello", "tragedy")
|
||||
];
|
||||
|
||||
Approvals::approveList($plays);
|
||||
}
|
||||
|
||||
public function testCanPrintInvoice() : void
|
||||
{
|
||||
$plays = [
|
||||
"hamlet" => new Play("Hamlet", "tragedy"),
|
||||
"as-like" => new Play("As You Like It", "comedy"),
|
||||
"othello" => new Play("Othello", "tragedy")
|
||||
];
|
||||
|
||||
$performances = [
|
||||
new Performance("hamlet", 55),
|
||||
new Performance("as-like", 35),
|
||||
new Performance("othello", 40)
|
||||
];
|
||||
$invoice = new Invoice("BigCo", $performances);
|
||||
$statementPrinter = new StatementPrinter();
|
||||
$result = $statementPrinter->print($invoice, $plays);
|
||||
|
||||
Approvals::approveString($result);
|
||||
}
|
||||
|
||||
public function testNewPlayTypes() : void
|
||||
{
|
||||
$plays = [
|
||||
"henry-v" => new Play("Henry V", "history"),
|
||||
"as-like" => new Play("As You Like It", "comedy"),
|
||||
];
|
||||
|
||||
$performances = [
|
||||
new Performance("henry-v", 53),
|
||||
new Performance("as-like", 55)
|
||||
];
|
||||
|
||||
$invoice = new Invoice("BigCo", $performances);
|
||||
$statementPrinter = new StatementPrinter();
|
||||
$this->expectException(\Error::class);
|
||||
$statementPrinter->print($invoice, $plays);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user