-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #340 from GSadee/improvements
Minor improvements and clean up
- Loading branch information
Showing
8 changed files
with
63 additions
and
42 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
namespace spec\Sylius\InvoicingPlugin\CommandHandler; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
use Sylius\Component\Core\Model\CustomerInterface; | ||
use Sylius\Component\Core\Model\OrderInterface; | ||
use Sylius\Component\Core\Repository\OrderRepositoryInterface; | ||
|
@@ -41,16 +42,45 @@ function it_requests_an_email_with_an_invoice_to_be_sent( | |
CustomerInterface $customer, | ||
): void { | ||
$orderRepository->findOneByNumber('0000001')->willReturn($order); | ||
|
||
$invoiceRepository->findOneByOrder($order)->willReturn($invoice); | ||
|
||
$order->getCustomer()->willReturn($customer); | ||
|
||
$customer->getEmail()->willReturn('[email protected]'); | ||
$invoiceRepository->findOneByOrder($order)->willReturn($invoice); | ||
|
||
$emailSender->sendInvoiceEmail($invoice, '[email protected]')->shouldBeCalled(); | ||
|
||
$this->__invoke(new SendInvoiceEmail('0000001', new \DateTime('now'))); | ||
$this(new SendInvoiceEmail('0000001')); | ||
} | ||
|
||
function it_does_not_request_an_email_to_be_sent_if_order_was_not_found( | ||
InvoiceRepositoryInterface $invoiceRepository, | ||
OrderRepositoryInterface $orderRepository, | ||
InvoiceEmailSenderInterface $emailSender, | ||
CustomerInterface $customer, | ||
): void { | ||
$orderRepository->findOneByNumber('0000001')->willReturn(null); | ||
|
||
$invoiceRepository->findOneByOrder(Argument::any())->shouldNotBeCalled(); | ||
$customer->getEmail()->shouldNotBeCalled(); | ||
$emailSender->sendInvoiceEmail(Argument::any(), Argument::any())->shouldNotBeCalled(); | ||
|
||
$this(new SendInvoiceEmail('0000001')); | ||
} | ||
|
||
function it_does_not_request_an_email_to_be_sent_if_customer_was_not_found( | ||
InvoiceRepositoryInterface $invoiceRepository, | ||
OrderRepositoryInterface $orderRepository, | ||
InvoiceEmailSenderInterface $emailSender, | ||
OrderInterface $order, | ||
CustomerInterface $customer, | ||
): void { | ||
$orderRepository->findOneByNumber('0000001')->willReturn($order); | ||
$order->getCustomer()->willReturn(null); | ||
|
||
$invoiceRepository->findOneByOrder($order)->shouldNotBeCalled(); | ||
$customer->getEmail()->shouldNotBeCalled(); | ||
$emailSender->sendInvoiceEmail(Argument::any(), Argument::any())->shouldNotBeCalled(); | ||
|
||
$this(new SendInvoiceEmail('0000001')); | ||
} | ||
|
||
function it_does_not_request_an_email_to_be_sent_if_invoice_was_not_found( | ||
|
@@ -61,11 +91,12 @@ function it_does_not_request_an_email_to_be_sent_if_invoice_was_not_found( | |
CustomerInterface $customer, | ||
): void { | ||
$orderRepository->findOneByNumber('0000001')->willReturn($order); | ||
$order->getCustomer()->willReturn($customer); | ||
$invoiceRepository->findOneByOrder($order)->willReturn(null); | ||
|
||
$order->getCustomer()->shouldNotBeCalled(); | ||
$customer->getEmail()->shouldNotBeCalled(); | ||
$emailSender->sendInvoiceEmail(Argument::any(), Argument::any())->shouldNotBeCalled(); | ||
|
||
$this->__invoke(new SendInvoiceEmail('0000001', new \DateTime('now'))); | ||
$this(new SendInvoiceEmail('0000001')); | ||
} | ||
} |
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
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
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
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
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
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
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