Conditions | 1 |
Paths | 1 |
Total Lines | 66 |
Code Lines | 58 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
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 |