ConvertPaymentActionTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 19
dl 0
loc 92
rs 10
c 1
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A provideNotSupportedRequests() 0 8 1
A provideSupportedRequests() 0 6 1
A shouldImplementGenericTokenFactoryAwareInterface() 0 4 1
A shouldImplementActionInterface() 0 4 1
A couldBeConstructedWithoutAnyArguments() 0 4 1
1
<?php
2
3
4
namespace PTS\Paysera\Tests\Action;
5
6
7
use Payum\Core\Action\ActionInterface;
8
use Payum\Core\Bridge\Symfony\Security\TokenFactory;
9
use Payum\Core\Model\Identity;
10
use Payum\Core\Model\Payment;
11
use Payum\Core\Model\Token;
12
use Payum\Core\Request\Convert;
13
use Payum\Core\Security\GenericTokenFactory;
14
use Payum\Core\Security\GenericTokenFactoryAwareInterface;
15
use Payum\Core\Security\GenericTokenFactoryInterface;
16
use Payum\Core\Security\TokenFactoryInterface;
17
use Payum\Core\Security\TokenInterface;
18
use Payum\Core\Tests\GenericActionTest;
19
use PTS\Paysera\Action\ConvertPaymentAction;
20
21
class ConvertPaymentActionTest extends GenericActionTest
22
{
23
    protected $requestClass = Convert::class;
24
25
    protected $actionClass = ConvertPaymentAction::class;
26
27
    /**
28
     * @test
29
     */
30
    public function shouldImplementActionInterface()
31
    {
32
        $rc = new \ReflectionClass(ConvertPaymentAction::class);
33
        $this->assertTrue($rc->isSubclassOf(ActionInterface::class));
34
    }
35
36
    public function provideSupportedRequests()
37
    {
38
        return array(
39
            array(new $this->requestClass(new Payment(), 'array')),
40
            array(new $this->requestClass($this->createMock('Payum\Core\Model\PaymentInterface'), 'array')),
41
            array(new $this->requestClass(new Payment(), 'array', $this->createMock('Payum\Core\Security\TokenInterface'))),
42
        );
43
    }
44
45
    public function provideNotSupportedRequests()
46
    {
47
        return array(
48
            array('foo'),
49
            array(array('foo')),
50
            array(new \stdClass()),
51
            array($this->getMockForAbstractClass('Payum\Core\Request\Generic', array(array()))),
52
            array(new $this->requestClass($this->createMock('Payum\Core\Model\PaymentInterface'), 'notArray')),
53
        );
54
    }
55
56
    /**
57
     * @test
58
     */
59
    public function shouldImplementGenericTokenFactoryAwareInterface()
60
    {
61
        $rc = new \ReflectionClass(ConvertPaymentAction::class);
62
        $this->assertTrue($rc->isSubclassOf(GenericTokenFactoryAwareInterface::class));
63
    }
64
65
    /*
66
67
    public function shouldConvertModelToOrder()
68
    {
69
        $tokenFactory = $this->createMock(TokenFactoryInterface::class);
70
        $tokenFactoryInterface = $this->getMockBuilder('Payum\Core\Security\GenericTokenFactory')
71
            ->setConstructorArgs([$tokenFactory, ['notify' => 'payum_notify_do']])
72
            ->getMock();
73
74
        $token = new Token();
75
        $payment = new Payment();
76
77
        $token->setTargetUrl('captureUrl');
78
        $token->setAfterUrl('afterUrl');
79
        $token->setGatewayName('theGatewayName');
80
81
        $token->setDetails($identity = new Identity('1', $payment));
82
83
        $payment->setNumber('theNumber');
84
        $payment->setCurrencyCode('USD');
85
        $payment->setTotalAmount(123);
86
        $payment->setDescription('the description');
87
        $payment->setClientId('theClientId');
88
        $payment->setClientEmail('theClientEmail');
89
90
        $action = new ConvertPaymentAction();
91
92
        $action->setGenericTokenFactory($tokenFactoryInterface);
93
94
        $convert = new Convert($payment, 'array', $token);
95
96
        $action->execute($convert);
97
98
        $details = $convert->getResult();
99
100
        var_dump($details);
101
102
        $this->assertNotEmpty($details);
103
    }
104
    */
105
106
    /**
107
     * @test
108
     */
109
    public function couldBeConstructedWithoutAnyArguments()
110
    {
111
        $this->expectNotToPerformAssertions();
112
        new $this->actionClass();
113
    }
114
115
116
}