Conditions | 1 |
Paths | 1 |
Total Lines | 60 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
31 | public function testCrudDocument(): void |
||
32 | { |
||
33 | |||
34 | // $counterpartyModel = new \SergeyNezbritskiy\NovaPoshta\Models\Counterparty($this->getConnection()); |
||
35 | // $addressModel = new \SergeyNezbritskiy\NovaPoshta\Models\Address($this->getConnection()); |
||
36 | |||
37 | // $recipient = $counterpartyModel->savePrivatePerson([ |
||
38 | // 'FirstName' => 'Петро', |
||
39 | // 'MiddleName' => 'Григорович', |
||
40 | // 'LastName' => 'Порошенко', |
||
41 | // 'Phone' => 380501112233, |
||
42 | // 'Email' => '[email protected]', |
||
43 | // 'CounterpartyProperty' => Counterparty::COUNTERPARTY_PROPERTY_RECIPIENT, |
||
44 | // ]); // 4d21c8c7-b88e-11ed-a60f-48df37b921db |
||
45 | $recipientRef = '4d21c8c7-b88e-11ed-a60f-48df37b921db'; |
||
46 | |||
47 | // $address = $addressModel->save($recipientRef, [ |
||
48 | // 'StreetRef' => self::KHRESHCHATYK_STREET_REF, |
||
49 | // 'BuildingNumber' => '20', |
||
50 | // 'Flat' => '12', |
||
51 | // ]); |
||
52 | $addressRef = 'cecaac32-25bb-11ee-a60f-48df37b921db'; |
||
53 | |||
54 | // $contactPersons = $counterpartyModel->getCounterpartyContactPersons(self::COUNTERPARTY_REF); |
||
55 | $senderContactRef = '4d06cbac-b88e-11ed-a60f-48df37b921db'; |
||
56 | |||
57 | // $contactPersons = $counterpartyModel->getCounterpartyContactPersons($recipientRef); |
||
58 | $recipientContactRef = '45b55250-25bb-11ee-a60f-48df37b921db'; |
||
59 | |||
60 | //create document |
||
61 | $params = [ |
||
62 | 'Sender' => self::COUNTERPARTY_REF, |
||
63 | 'CitySender' => self::CITY_REF_KHARKIV, |
||
64 | 'SenderAddress' => self::ADDRESS_REF_KHARKIV, |
||
65 | 'ContactSender' => $senderContactRef, |
||
66 | 'SendersPhone' => 380505511696, |
||
67 | |||
68 | 'Recipient' => $recipientRef, |
||
69 | 'CityRecipient' => self::CITY_REF_KYIV, |
||
70 | 'RecipientAddress' => $addressRef, |
||
71 | 'ContactRecipient' => $recipientContactRef, |
||
72 | 'RecipientsPhone' => 380505511696, |
||
73 | |||
74 | 'DateTime' => date('d.m.Y'), |
||
75 | 'CargoType' => InternetDocument::CARGO_TYPE_CARGO, |
||
76 | 'Weight' => '0.5', |
||
77 | 'SeatsAmount' => '1', |
||
78 | 'ServiceType' => 'DoorsDoors', |
||
79 | 'PayerType' => 'Recipient', |
||
80 | 'PaymentMethod' => 'Cash', |
||
81 | 'Description' => 'TEST, DO NOT PROCEED WITH THIS' |
||
82 | ]; |
||
83 | |||
84 | $actualResult = $this->model->save($params); |
||
85 | $this->assertNotEmpty($actualResult['Ref']); |
||
86 | |||
87 | //delete document |
||
88 | $this->deleteDocument($actualResult['Ref']); |
||
89 | |||
90 | $this->assertDocumentDeleted($actualResult['Ref']); |
||
91 | } |
||
137 |