Skip to content

Commit 4f72f77

Browse files
committed
add phpspec for convert payment action
1 parent 13eb52e commit 4f72f77

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace spec\Locastic\SyliusHTPayWayPlugin\Action;
4+
5+
use Locastic\SyliusHTPayWayPlugin\Action\ConvertPaymentAction;
6+
use Payum\Core\Action\ActionInterface;
7+
use Payum\Core\Model\PaymentInterface;
8+
use Payum\Core\Request\Convert;
9+
use PhpSpec\ObjectBehavior;
10+
11+
class ConvertPaymentActionSpec extends ObjectBehavior
12+
{
13+
function it_is_initializable()
14+
{
15+
$this->shouldHaveType(ConvertPaymentAction::class);
16+
}
17+
18+
function it_implements_action_interface(): void
19+
{
20+
$this->shouldHaveType(ActionInterface::class);
21+
}
22+
23+
function it_executes(
24+
Convert $request,
25+
PaymentInterface $payment
26+
): void {
27+
$request->getSource()->willReturn($payment);
28+
$request->getTo()->willReturn('array');
29+
30+
$payment->getDetails()->willReturn([]);
31+
$payment->getNumber()->willReturn(1);
32+
$payment->getTotalAmount()->willReturn(1);
33+
$payment->getClientEmail()->willReturn('john@locastic.com');
34+
35+
$request->setResult(["pgwOrderId" => 1, "pgwAmount" => 1, "pgwEmail" => "john@locastic.com"])->shouldBeCalled();
36+
37+
$this->execute($request);
38+
}
39+
40+
function it_supports_only_covert_request(
41+
Convert $request,
42+
PaymentInterface $payment
43+
): void {
44+
$request->getSource()->willReturn($payment);
45+
$request->getTo()->willReturn('array');
46+
47+
$this->supports($request)->shouldReturn(true);
48+
}
49+
}

0 commit comments

Comments
 (0)