17
17
use Prophecy \Argument ;
18
18
use Sylius \Component \Core \Model \OrderInterface ;
19
19
use Sylius \Component \Core \Model \PaymentInterface ;
20
- use Sylius \InvoicingPlugin \DateTimeProvider ;
21
20
use Sylius \InvoicingPlugin \Doctrine \ORM \InvoiceRepositoryInterface ;
22
21
use Sylius \InvoicingPlugin \Entity \InvoiceInterface ;
23
22
use Sylius \InvoicingPlugin \Event \OrderPaymentPaid ;
23
+ use Symfony \Component \Clock \ClockInterface ;
24
24
use Symfony \Component \Messenger \Envelope ;
25
25
use Symfony \Component \Messenger \MessageBusInterface ;
26
26
27
27
final class OrderPaymentPaidProducerSpec extends ObjectBehavior
28
28
{
29
29
function let (
30
30
MessageBusInterface $ eventBus ,
31
- DateTimeProvider $ dateTimeProvider ,
31
+ ClockInterface $ clock ,
32
32
InvoiceRepositoryInterface $ invoiceRepository ,
33
33
): void {
34
- $ this ->beConstructedWith ($ eventBus , $ dateTimeProvider , $ invoiceRepository );
34
+ $ this ->beConstructedWith ($ eventBus , $ clock , $ invoiceRepository );
35
35
}
36
36
37
37
function it_dispatches_order_payment_paid_event_for_payment (
38
38
MessageBusInterface $ eventBus ,
39
- DateTimeProvider $ dateTimeProvider ,
39
+ ClockInterface $ clock ,
40
40
PaymentInterface $ payment ,
41
41
OrderInterface $ order ,
42
42
InvoiceRepositoryInterface $ invoiceRepository ,
@@ -45,8 +45,8 @@ function it_dispatches_order_payment_paid_event_for_payment(
45
45
$ payment ->getOrder ()->willReturn ($ order );
46
46
$ order ->getNumber ()->willReturn ('0000001 ' );
47
47
48
- $ dateTime = new \DateTime ();
49
- $ dateTimeProvider -> __invoke ()->willReturn ($ dateTime );
48
+ $ dateTime = new \DateTimeImmutable ();
49
+ $ clock -> now ()->willReturn ($ dateTime );
50
50
51
51
$ event = new OrderPaymentPaid ('0000001 ' , $ dateTime );
52
52
@@ -59,21 +59,21 @@ function it_dispatches_order_payment_paid_event_for_payment(
59
59
60
60
function it_does_not_dispatch_event_when_payment_is_not_related_to_order (
61
61
MessageBusInterface $ eventBus ,
62
- DateTimeProvider $ dateTimeProvider ,
62
+ ClockInterface $ clock ,
63
63
PaymentInterface $ payment ,
64
64
): void {
65
65
$ payment ->getOrder ()->willReturn (null );
66
66
67
67
$ eventBus ->dispatch (Argument::any ())->shouldNotBeCalled ();
68
68
69
- $ dateTimeProvider -> __invoke ()->shouldNotBeCalled ();
69
+ $ clock -> now ()->shouldNotBeCalled ();
70
70
71
71
$ this ->__invoke ($ payment );
72
72
}
73
73
74
74
function it_does_not_dispatch_event_when_there_is_no_invoice_related_to_order (
75
75
MessageBusInterface $ eventBus ,
76
- DateTimeProvider $ dateTimeProvider ,
76
+ ClockInterface $ clock ,
77
77
PaymentInterface $ payment ,
78
78
OrderInterface $ order ,
79
79
InvoiceRepositoryInterface $ invoiceRepository ,
@@ -83,7 +83,7 @@ function it_does_not_dispatch_event_when_there_is_no_invoice_related_to_order(
83
83
$ invoiceRepository ->findOneByOrder ($ order )->willReturn (null );
84
84
85
85
$ eventBus ->dispatch (Argument::any ())->shouldNotBeCalled ();
86
- $ dateTimeProvider -> __invoke ()->shouldNotBeCalled ();
86
+ $ clock -> now ()->shouldNotBeCalled ();
87
87
88
88
$ this ->__invoke ($ payment );
89
89
}
0 commit comments