Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
47 lines (38 sloc)
1.3 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace TestingWithoutMockingFrameworks\InterfacedDependencies; | |
use DateTimeImmutable; | |
use PHPUnit\Framework\TestCase; | |
class InvoiceServiceTest extends TestCase | |
{ | |
/** | |
* @test | |
*/ | |
public function invoicing_a_client_successfully(): void | |
{ | |
// Arrange | |
$invoicePortal = new FakeInvoicePortal(); | |
$invoiceService = new InvoiceService($invoicePortal); | |
$invoicePeriod = InvoicePeriod::fromDateTime(DateTimeImmutable::createFromFormat('!Y-m', '2020-03')); | |
// Act | |
$invoiceService->invoiceClient('abc', $invoicePeriod); | |
// Assert | |
$expectedInvoice = new Invoice('abc', 42, $invoicePeriod); | |
$this->assertTrue($invoicePortal->wasInvoiceSubmit($expectedInvoice)); | |
} | |
/** | |
* @test | |
*/ | |
public function failing_to_invoice_a_client(): void | |
{ | |
// Expect | |
$this->expectException(UnableToInvoiceClient::class); | |
// Arrange | |
$invoicePortal = new FakeInvoicePortal(); | |
$invoicePortal->failNextSubmission(); | |
$invoiceService = new InvoiceService($invoicePortal); | |
$invoicePeriod = InvoicePeriod::fromDateTime(DateTimeImmutable::createFromFormat('!Y-m', '2020-03')); | |
// Act | |
$invoiceService->invoiceClient('abc', $invoicePeriod); | |
} | |
} |