| Conditions | 1 |
| Paths | 1 |
| Total Lines | 66 |
| Code Lines | 38 |
| 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 |
||
| 44 | public function testCrudDocument(): void |
||
| 45 | { |
||
| 46 | // In order to get sender and recipient refs create a document in UI and fetch this document |
||
| 47 | // $documents = $this->getAllDocuments(); |
||
| 48 | // 'Sender' => '85d0d7a2-b8fa-11ed-a60f-48df37b921db', |
||
| 49 | // 'ContactSender' => 'e8253e73-cc91-11ed-a60f-48df37b921db', |
||
| 50 | // 'SenderAddress' => 'dbbc2098-25b3-11ee-a60f-48df37b921db', |
||
| 51 | // 'Recipient' => '85d18dbb-b8fa-11ed-a60f-48df37b921db', |
||
| 52 | // 'RecipientAddress' => '1ec09d88-e1c2-11e3-8c4a-0050568002cf', |
||
| 53 | // 'ContactRecipient' => '4184cb87-59ec-11f0-a1d5-48df37b921da', |
||
| 54 | |||
| 55 | $senderRef = '85d0d7a2-b8fa-11ed-a60f-48df37b921db'; |
||
| 56 | $senderContactRef = 'e8253e73-cc91-11ed-a60f-48df37b921db'; |
||
| 57 | $senderAddressRef = 'dbbc2098-25b3-11ee-a60f-48df37b921db'; |
||
| 58 | |||
| 59 | $recipientRef = '85d18dbb-b8fa-11ed-a60f-48df37b921db'; |
||
| 60 | $recipientContactRef = '4184cb87-59ec-11f0-a1d5-48df37b921da'; |
||
| 61 | $recipientAddressRef = '1ec09d88-e1c2-11e3-8c4a-0050568002cf'; |
||
| 62 | |||
| 63 | //create document |
||
| 64 | $params = [ |
||
| 65 | 'Sender' => $senderRef, |
||
| 66 | 'CitySender' => self::CITY_REF_KHARKIV, |
||
| 67 | 'SenderAddress' => $senderAddressRef, |
||
| 68 | 'ContactSender' => $senderContactRef, |
||
| 69 | 'SendersPhone' => 380507778797, |
||
| 70 | |||
| 71 | 'Recipient' => $recipientRef, |
||
| 72 | 'CityRecipient' => self::CITY_REF_KYIV, |
||
| 73 | 'RecipientAddress' => $recipientAddressRef, |
||
| 74 | 'ContactRecipient' => $recipientContactRef, |
||
| 75 | 'RecipientsPhone' => 380507778797, |
||
| 76 | |||
| 77 | 'DateTime' => date('d.m.Y'), |
||
| 78 | 'CargoType' => InternetDocument::CARGO_TYPE_CARGO, |
||
| 79 | 'Weight' => '0.5', |
||
| 80 | 'SeatsAmount' => '1', |
||
| 81 | 'ServiceType' => InternetDocument::SERVICE_TYPE_DOORS_DOORS, |
||
| 82 | 'PayerType' => InternetDocument::PAYER_TYPE_RECIPIENT, |
||
| 83 | 'PaymentMethod' => InternetDocument::PAYMENT_TYPE_CASH, |
||
| 84 | 'Description' => 'ЦЕ ТЕСТОВЕ ЗАМОВЛЕННЯ, В ЖОДНОМУ РАЗІ НЕ ОБРОБЛЯТИ !!!' |
||
| 85 | ]; |
||
| 86 | |||
| 87 | $actualResult = $this->model->save($params); |
||
| 88 | $this->assertNotEmpty($actualResult['Ref']); |
||
| 89 | |||
| 90 | $params['PayerType'] = InternetDocument::PAYER_TYPE_SENDER; |
||
| 91 | $params['Ref'] = $actualResult['Ref']; |
||
| 92 | |||
| 93 | $this->gulp(); |
||
| 94 | |||
| 95 | $actualResult = $this->model->update($params); |
||
| 96 | |||
| 97 | $this->gulp(); |
||
| 98 | |||
| 99 | $document = $this->getDocumentByRef($actualResult['Ref']); |
||
| 100 | $this->assertSame($params['PayerType'], $document['PayerType']); |
||
| 101 | |||
| 102 | $this->gulp(); |
||
| 103 | |||
| 104 | //delete document |
||
| 105 | $this->deleteDocument($actualResult['Ref']); |
||
| 106 | |||
| 107 | $this->gulp(); |
||
| 108 | |||
| 109 | $this->assertDocumentDeleted($actualResult['Ref']); |
||
| 110 | } |
||
| 194 |