Conditions | 1 |
Paths | 1 |
Total Lines | 75 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
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 |
||
42 | public function testCrudDocument(): void |
||
43 | { |
||
44 | // $counterpartyModel = new \SergeyNezbritskiy\NovaPoshta\Models\Counterparty($this->getConnection()); |
||
45 | // $addressModel = new \SergeyNezbritskiy\NovaPoshta\Models\Address($this->getConnection()); |
||
46 | |||
47 | // $recipient = $counterpartyModel->savePrivatePerson([ |
||
48 | // 'FirstName' => 'Петро', |
||
49 | // 'MiddleName' => 'Григорович', |
||
50 | // 'LastName' => 'Порошенко', |
||
51 | // 'Phone' => 380501112233, |
||
52 | // 'Email' => '[email protected]', |
||
53 | // 'CounterpartyProperty' => Counterparty::COUNTERPARTY_PROPERTY_RECIPIENT, |
||
54 | // ]); // 4d21c8c7-b88e-11ed-a60f-48df37b921db |
||
55 | $recipientRef = '4d21c8c7-b88e-11ed-a60f-48df37b921db'; |
||
56 | |||
57 | // $address = $addressModel->save($recipientRef, [ |
||
58 | // 'StreetRef' => self::KHRESHCHATYK_STREET_REF, |
||
59 | // 'BuildingNumber' => '20', |
||
60 | // 'Flat' => '12', |
||
61 | // ]); |
||
62 | $addressRef = 'cecaac32-25bb-11ee-a60f-48df37b921db'; |
||
63 | |||
64 | // $contactPersons = $counterpartyModel->getCounterpartyContactPersons(self::COUNTERPARTY_REF); |
||
65 | $senderContactRef = '4d06cbac-b88e-11ed-a60f-48df37b921db'; |
||
66 | |||
67 | // $contactPersons = $counterpartyModel->getCounterpartyContactPersons($recipientRef); |
||
68 | $recipientContactRef = '45b55250-25bb-11ee-a60f-48df37b921db'; |
||
69 | |||
70 | //create document |
||
71 | $params = [ |
||
72 | 'Sender' => self::COUNTERPARTY_REF, |
||
73 | 'CitySender' => self::CITY_REF_KHARKIV, |
||
74 | 'SenderAddress' => self::ADDRESS_REF_KHARKIV, |
||
75 | 'ContactSender' => $senderContactRef, |
||
76 | 'SendersPhone' => 380505511696, |
||
77 | |||
78 | 'Recipient' => $recipientRef, |
||
79 | 'CityRecipient' => self::CITY_REF_KYIV, |
||
80 | 'RecipientAddress' => $addressRef, |
||
81 | 'ContactRecipient' => $recipientContactRef, |
||
82 | 'RecipientsPhone' => 380505511696, |
||
83 | |||
84 | 'DateTime' => date('d.m.Y'), |
||
85 | 'CargoType' => InternetDocument::CARGO_TYPE_CARGO, |
||
86 | 'Weight' => '0.5', |
||
87 | 'SeatsAmount' => '1', |
||
88 | 'ServiceType' => InternetDocument::SERVICE_TYPE_DOORS_DOORS, |
||
89 | 'PayerType' => InternetDocument::PAYER_TYPE_RECIPIENT, |
||
90 | 'PaymentMethod' => InternetDocument::PAYMENT_TYPE_CASH, |
||
91 | 'Description' => 'Це тестове замовлення, не треба його обробляти' |
||
92 | ]; |
||
93 | |||
94 | $actualResult = $this->model->save($params); |
||
95 | $this->assertNotEmpty($actualResult['Ref']); |
||
96 | |||
97 | $params['PayerType'] = InternetDocument::PAYER_TYPE_SENDER; |
||
98 | $params['Ref'] = $actualResult['Ref']; |
||
99 | |||
100 | $this->gulp(); |
||
101 | |||
102 | $actualResult = $this->model->update($params); |
||
103 | |||
104 | $this->gulp(); |
||
105 | |||
106 | $document = $this->getDocumentByRef($actualResult['Ref']); |
||
107 | $this->assertSame($params['PayerType'], $document['PayerType']); |
||
108 | |||
109 | $this->gulp(); |
||
110 | |||
111 | //delete document |
||
112 | $this->deleteDocument($actualResult['Ref']); |
||
113 | |||
114 | $this->gulp(); |
||
115 | |||
116 | $this->assertDocumentDeleted($actualResult['Ref']); |
||
117 | } |
||
201 |