PaypalControllerTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 80
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUpBeforeClass() 0 4 1
A webhook() 0 66 1
1
<?php
2
3
/**
4
 * @author    Markus Tacker <[email protected]>
5
 * @copyright 2013-2016 Verein zur Förderung der Netzkultur im Rhein-Main-Gebiet e.V. | http://netzkultur-rheinmain.de/
6
 */
7
8
namespace BCRM\WebBundle\Tests\Functional;
9
10
use BCRM\BackendBundle\Entity\Payment;
11
12
class PaypalControllerTest extends Base
13
{
14
    /**
15
     */
16
    public static function setUpBeforeClass()
17
    {
18
        static::resetDatabase();
19
    }
20
21
    /**
22
     * @test
23
     * @group functional
24
     */
25
    public function webhook()
26
    {
27
        $client = static::createClient();
28
        $data   = [
29
            'address_city'           => 'Freiburg',
30
            'address_country'        => 'Germany',
31
            'address_country_code'   => 'DE',
32
            'address_name'           => 'Demo Kunde',
33
            'address_state'          => 'Empty',
34
            'address_status'         => 'unconfirmed',
35
            'address_street'         => 'ESpachstr. 1',
36
            'address_zip'            => '79111',
37
            'business'               => '[email protected]',
38
            'charset'                => 'windows-1252',
39
            'custom'                 => null,
40
            'first_name'             => 'Demo',
41
            'handling_amount'        => '0.00',
42
            'ipn_track_id'           => 'bb805611bddb3',
43
            'item_name'              => 'BarCamp 2015 04./05.08.2015 Ticket für Markus Tacker gültig am Samstag',
44
            'item_number'            => 'df8384ed4507c4a04819cd2e3281191e5a43a3b6',
45
            'last_name'              => 'Kunde',
46
            'mc_currency'            => 'EUR',
47
            'mc_fee'                 => '1.06',
48
            'mc_gross'               => '37.50',
49
            'notify_version'         => '3.8',
50
            'payer_email'            => '[email protected]',
51
            'payer_id'               => 'CARV38JGU7NGS',
52
            'payer_status'           => 'unverified',
53
            'payment_date'           => '08:44:55 Jul 05, 2015 PDT',
54
            'payment_fee'            => null,
55
            'payment_gross'          => null,
56
            'payment_status'         => 'Completed',
57
            'payment_type'           => 'instant',
58
            'protection_eligibility' => 'Eligible',
59
            'quantity'               => '1',
60
            'receiver_email'         => '[email protected]',
61
            'receiver_id'            => 'MADLHS6XJAZFS',
62
            'residence_country'      => 'DE',
63
            'shipping'               => '0.00',
64
            'tax'                    => '0.00',
65
            'test_ipn'               => '1',
66
            'transaction_subject'    => null,
67
            'txn_id'                 => '3F3525487J2452828',
68
            'txn_type'               => 'web_accept',
69
            'verify_sign'            => 'AoNB-1eMvfdupacZeervP-FX318PAk65Kf02iyB8668ErUUxsHFUm6sO',
70
        ];
71
        $client->request('POST', '/paypal', $data);
72
        $response = $client->getResponse();
73
        $this->assertEquals(200, $response->getStatusCode());
74
75
        $container = $client->getContainer();
76
        /* @var $em \Doctrine\Common\Persistence\ObjectManager */
77
        $em = $container
78
            ->get('doctrine')
79
            ->getManager();
80
81
        $payments = $em->getRepository('BCRMBackendBundle:Payment')->findAll();
82
        $this->assertEquals(1, count($payments));
83
84
        /** @var Payment $payment */
85
        $payment = $payments[0];
86
        $this->assertEquals('3F3525487J2452828', $payment->getTransactionId());
87
        $this->assertEquals($data, $payment->getPayload()->toArray());
88
        $this->assertEquals('paypal', $payment->getMethod());
89
        $this->assertFalse($payment->isVerified());
90
    }
91
}
92