PHP7.2+ close to the JS code in refactoring ch.1

This commit is contained in:
Pen-y-Fan
2020-05-18 23:11:00 +01:00
parent 5bef5c1bf6
commit d5664e3d37
2 changed files with 50 additions and 50 deletions

View File

@@ -1,50 +1,51 @@
<?php
use PHPUnit\Framework\TestCase;
use ApprovalTests\Approvals;
declare(strict_types=1);
use Theatrical\StatementPrinter;
use Theatrical\Play;
use Theatrical\Performance;
namespace Tests;
use ApprovalTests\Approvals;
use Error;
use PHPUnit\Framework\TestCase;
use Theatrical\Invoice;
use Theatrical\Performance;
use Theatrical\Play;
use Theatrical\StatementPrinter;
final class StatementPrinterTest extends TestCase
{
public function testCanPrintInvoice() : void
public function testCanPrintInvoice(): void
{
$plays = [
"hamlet" => new Play("Hamlet", "tragedy"),
"as-like" => new Play("As You Like It", "comedy"),
"othello" => new Play("Othello", "tragedy")
'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)
new Performance('hamlet', 55),
new Performance('as-like', 35),
new Performance('othello', 40),
];
$invoice = new Invoice("BigCo", $performances);
$invoice = new Invoice('BigCo', $performances);
$statementPrinter = new StatementPrinter();
$result = $statementPrinter->print($invoice, $plays);
Approvals::verifyString($result);
}
public function testNewPlayTypes() : void
public function testNewPlayTypes(): void
{
$plays = [
"henry-v" => new Play("Henry V", "history"),
"as-like" => new Play("As You Like It", "comedy"),
'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)
];
$performances = [new Performance('henry-v', 53), new Performance('as-like', 55)];
$invoice = new Invoice("BigCo", $performances);
$invoice = new Invoice('BigCo', $performances);
$statementPrinter = new StatementPrinter();
$this->expectException(\Error::class);
$this->expectException(Error::class);
$statementPrinter->print($invoice, $plays);
}
}