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