1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace spec\Sylius\Bundle\AdminBundle\EmailManager; |
15
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
17
|
|
|
use Sylius\Bundle\AdminBundle\EmailManager\ShipmentEmailManagerInterface; |
18
|
|
|
use Sylius\Component\Core\Model\ChannelInterface; |
19
|
|
|
use Sylius\Component\Core\Model\CustomerInterface; |
20
|
|
|
use Sylius\Component\Core\Model\OrderInterface; |
21
|
|
|
use Sylius\Component\Core\Model\ShipmentInterface; |
22
|
|
|
use Sylius\Component\Mailer\Sender\SenderInterface; |
23
|
|
|
|
24
|
|
|
final class ShipmentEmailManagerSpec extends ObjectBehavior |
25
|
|
|
{ |
26
|
|
|
function let(SenderInterface $sender): void |
27
|
|
|
{ |
28
|
|
|
$this->beConstructedWith($sender); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
function it_implements_a_shipment_email_manager_interface(): void |
32
|
|
|
{ |
33
|
|
|
$this->shouldImplement(ShipmentEmailManagerInterface::class); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
function it_sends_a_shipment_confirmation_email( |
37
|
|
|
SenderInterface $sender, |
38
|
|
|
ShipmentInterface $shipment, |
39
|
|
|
OrderInterface $order, |
40
|
|
|
ChannelInterface $channel, |
41
|
|
|
CustomerInterface $customer |
42
|
|
|
): void { |
43
|
|
|
$shipment->getOrder()->willReturn($order); |
44
|
|
|
$order->getChannel()->willReturn($channel); |
45
|
|
|
$order->getLocaleCode()->willReturn('en_US'); |
46
|
|
|
$order->getCustomer()->willReturn($customer); |
47
|
|
|
$customer->getEmail()->willReturn('[email protected]'); |
48
|
|
|
|
49
|
|
|
$sender |
50
|
|
|
->send('shipment_confirmation', ['[email protected]'], [ |
51
|
|
|
'shipment' => $shipment, |
52
|
|
|
'order' => $order, |
53
|
|
|
'channel' => $channel, |
54
|
|
|
'localeCode' => 'en_US', |
55
|
|
|
]) |
56
|
|
|
->shouldBeCalled() |
57
|
|
|
; |
58
|
|
|
|
59
|
|
|
$this->sendConfirmationEmail($shipment); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|