1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file has been created by developers from BitBag. |
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
6
|
|
|
* another great project. |
7
|
|
|
* You can find more information about us on https://bitbag.shop and write us |
8
|
|
|
* an email on [email protected]. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace spec\BitBag\SyliusMolliePlugin\Action\Api; |
14
|
|
|
|
15
|
|
|
use BitBag\SyliusMolliePlugin\Action\Api\BaseApiAwareAction; |
16
|
|
|
use BitBag\SyliusMolliePlugin\Action\Api\CreateCustomerAction; |
17
|
|
|
use BitBag\SyliusMolliePlugin\Client\MollieApiClient; |
18
|
|
|
use BitBag\SyliusMolliePlugin\Request\Api\CreateCustomer; |
19
|
|
|
use Mollie\Api\Endpoints\CustomerEndpoint; |
20
|
|
|
use Mollie\Api\Resources\Customer; |
21
|
|
|
use Payum\Core\Action\ActionInterface; |
22
|
|
|
use Payum\Core\ApiAwareInterface; |
23
|
|
|
use Payum\Core\Bridge\Spl\ArrayObject; |
24
|
|
|
use PhpSpec\ObjectBehavior; |
25
|
|
|
|
26
|
|
|
final class CreateCustomerActionSpec extends ObjectBehavior |
27
|
|
|
{ |
28
|
|
|
function it_is_initializable(): void |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
$this->shouldHaveType(CreateCustomerAction::class); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
function it_implements_action_interface(): void |
34
|
|
|
{ |
35
|
|
|
$this->shouldHaveType(ActionInterface::class); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
function it_implements_api_aware_interface(): void |
39
|
|
|
{ |
40
|
|
|
$this->shouldHaveType(ApiAwareInterface::class); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
function it_extends_base_api_aware(): void |
44
|
|
|
{ |
45
|
|
|
$this->shouldHaveType(BaseApiAwareAction::class); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
function it_executes( |
49
|
|
|
CreateCustomer $request, |
50
|
|
|
MollieApiClient $mollieApiClient, |
51
|
|
|
CustomerEndpoint $customerEndpoint, |
52
|
|
|
Customer $customer, |
53
|
|
|
ArrayObject $arrayObject |
54
|
|
|
): void { |
55
|
|
|
$mollieApiClient->customers = $customerEndpoint; |
56
|
|
|
$this->setApi($mollieApiClient); |
|
|
|
|
57
|
|
|
$customer->id = 'id_1'; |
58
|
|
|
$arrayObject->offsetGet('fullName')->willReturn('Jan Kowalski'); |
59
|
|
|
$arrayObject->offsetGet('email')->willReturn('[email protected]'); |
60
|
|
|
$request->getModel()->willReturn($arrayObject); |
61
|
|
|
$customerEndpoint->create(['name' => 'Jan Kowalski', 'email' => '[email protected]'])->willReturn($customer); |
|
|
|
|
62
|
|
|
|
63
|
|
|
$arrayObject->offsetSet('customer_mollie_id', 'id_1')->shouldBeCalled(); |
|
|
|
|
64
|
|
|
|
65
|
|
|
$this->execute($request); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
function it_supports_only_create_customer_request_and_array_access( |
69
|
|
|
CreateCustomer $request, |
70
|
|
|
\ArrayAccess $arrayAccess |
71
|
|
|
): void { |
72
|
|
|
$request->getModel()->willReturn($arrayAccess); |
73
|
|
|
|
74
|
|
|
$this->supports($request)->shouldReturn(true); |
|
|
|
|
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.