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\Component\Payment\Factory; |
15
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
17
|
|
|
use Sylius\Component\Payment\Factory\PaymentFactoryInterface; |
18
|
|
|
use Sylius\Component\Payment\Model\PaymentInterface; |
19
|
|
|
use Sylius\Component\Resource\Factory\FactoryInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author Łukasz Chruściel <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
final class PaymentFactorySpec extends ObjectBehavior |
25
|
|
|
{ |
26
|
|
|
function let(FactoryInterface $paymentFactory): void |
27
|
|
|
{ |
28
|
|
|
$this->beConstructedWith($paymentFactory); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
function it_implements_Sylius_shipment_factory_interface(): void |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
$this->shouldImplement(PaymentFactoryInterface::class); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
function it_implements_factory_interface(): void |
37
|
|
|
{ |
38
|
|
|
$this->shouldImplement(FactoryInterface::class); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
function it_delegates_creation_of_new_resource(FactoryInterface $paymentFactory, PaymentInterface $payment): void |
42
|
|
|
{ |
43
|
|
|
$paymentFactory->createNew()->willReturn($payment); |
44
|
|
|
|
45
|
|
|
$this->createNew()->shouldReturn($payment); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
function it_creates_payment_with_currency_and_amount( |
49
|
|
|
FactoryInterface $paymentFactory, |
50
|
|
|
PaymentInterface $payment |
51
|
|
|
): void { |
52
|
|
|
$paymentFactory->createNew()->willReturn($payment); |
53
|
|
|
|
54
|
|
|
$payment->setAmount(1234)->shouldBeCalled(); |
55
|
|
|
$payment->setCurrencyCode('EUR')->shouldBeCalled(); |
56
|
|
|
|
57
|
|
|
$this->createWithAmountAndCurrencyCode(1234, 'EUR'); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.