| Conditions | 1 |
| Paths | 1 |
| Total Lines | 56 |
| Code Lines | 35 |
| 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 |
||
| 63 | public function testBuildCallsTheBuilderModel() |
||
| 64 | { |
||
| 65 | $sender = new ParticipantTestHelper(1); |
||
| 66 | $recipient = new ParticipantTestHelper(2); |
||
| 67 | |||
| 68 | $builderModel = $this->getMockBuilder('Miliooo\Messaging\Builder\Model\ThreadBuilderModel') |
||
| 69 | ->disableOriginalConstructor() |
||
| 70 | ->getMock(); |
||
| 71 | |||
| 72 | $builderModel->expects($this->at(0))->method('getSender') |
||
| 73 | ->will($this->returnValue($sender)); |
||
| 74 | |||
| 75 | $builderModel->expects($this->at(1))->method('getRecipients') |
||
| 76 | ->will($this->returnValue([$recipient])); |
||
| 77 | |||
| 78 | $builderModel->expects($this->at(2))->method('getThreadData') |
||
| 79 | ->with(null); |
||
| 80 | |||
| 81 | $builderModel->expects($this->at(3))->method('getThreadMeta') |
||
| 82 | ->with('all'); |
||
| 83 | |||
| 84 | $builderModel->expects($this->at(4))->method('getThreadMeta') |
||
| 85 | ->with('sender'); |
||
| 86 | |||
| 87 | //the recipient update updates first the values that are happening for all... |
||
| 88 | $builderModel->expects($this->at(5))->method('getThreadMeta') |
||
| 89 | ->with('all'); |
||
| 90 | |||
| 91 | $builderModel->expects($this->at(6))->method('getThreadMeta') |
||
| 92 | ->with('recipients'); |
||
| 93 | |||
| 94 | $builderModel->expects($this->at(7))->method('getMessageData') |
||
| 95 | ->with(null); |
||
| 96 | |||
| 97 | $builderModel->expects($this->at(8))->method('getMessageMeta') |
||
| 98 | ->with('all'); |
||
| 99 | |||
| 100 | $builderModel->expects($this->at(9))->method('getMessageMeta') |
||
| 101 | ->with('sender'); |
||
| 102 | |||
| 103 | $builderModel->expects($this->at(10))->method('getMessageMeta') |
||
| 104 | ->with('all'); |
||
| 105 | |||
| 106 | $builderModel->expects($this->at(11))->method('getMessageMeta') |
||
| 107 | ->with('recipients'); |
||
| 108 | |||
| 109 | //2 times for all, one time for sender, one time for recipient |
||
| 110 | $builderModel->expects($this->exactly(4))->method('getMessageMeta'); |
||
| 111 | //2 times for all, one time for sender, one time for recipient |
||
| 112 | $builderModel->expects($this->exactly(4))->method('getThreadMeta'); |
||
| 113 | |||
| 114 | $builderModel->expects($this->exactly(1))->method('getThreadData'); |
||
| 115 | $builderModel->expects($this->exactly(1))->method('getMessageData'); |
||
| 116 | |||
| 117 | $this->builder->build($builderModel); |
||
| 118 | } |
||
| 119 | |||
| 151 |