Conditions | 1 |
Paths | 1 |
Total Lines | 65 |
Code Lines | 52 |
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 |
||
82 | public function testCreateService() |
||
83 | { |
||
84 | $templateRepository = $this->createMock(TemplateRepositoryInterface::class); |
||
85 | |||
86 | $inputFilterManager = $this->createMock(InputFilterPluginManager::class); |
||
87 | $inputFilterManager |
||
88 | ->expects($this->once()) |
||
89 | ->method('get') |
||
90 | ->with(TemplateInputFilter::class) |
||
91 | ->will($this->returnValue($this->createMock(TemplateInputFilter::class))); |
||
92 | |||
93 | $hydratorManager = $this->createMock(HydratorPluginManager::class); |
||
94 | $hydratorManager |
||
95 | ->expects($this->once()) |
||
96 | ->method('get') |
||
97 | ->with(TemplateHydrator::class) |
||
98 | ->will($this->returnValue($this->createMock(TemplateHydrator::class))); |
||
99 | |||
100 | $sl = $this->createMock(ServiceLocatorInterface::class); |
||
101 | $sl |
||
102 | ->expects($this->at(0)) |
||
103 | ->method('get') |
||
104 | ->with('Roave\EmailTemplates\ObjectManager') |
||
105 | ->will($this->returnValue($this->createMock(ObjectManager::class))); |
||
106 | |||
107 | $sl |
||
108 | ->expects($this->at(1)) |
||
109 | ->method('get') |
||
110 | ->with(TemplateRepository::class) |
||
111 | ->will($this->returnValue($templateRepository)); |
||
112 | |||
113 | $sl |
||
114 | ->expects($this->at(2)) |
||
115 | ->method('get') |
||
116 | ->with('inputFilterManager') |
||
117 | ->will($this->returnValue($inputFilterManager)); |
||
118 | |||
119 | $sl |
||
120 | ->expects($this->at(3)) |
||
121 | ->method('get') |
||
122 | ->with('hydratorManager') |
||
123 | ->will($this->returnValue($hydratorManager)); |
||
124 | |||
125 | $sl |
||
126 | ->expects($this->at(4)) |
||
127 | ->method('get') |
||
128 | ->with(EnginePluginManager::class) |
||
129 | ->will($this->returnValue($this->createMock(EnginePluginManager::class))); |
||
130 | |||
131 | $sl |
||
132 | ->expects($this->at(5)) |
||
133 | ->method('get') |
||
134 | ->with(TemplateServiceOptions::class) |
||
135 | ->will($this->returnValue($this->createMock(TemplateServiceOptions::class))); |
||
136 | |||
137 | $sl |
||
138 | ->expects($this->at(6)) |
||
139 | ->method('get') |
||
140 | ->with(UpdateTemplateParametersListener::class) |
||
141 | ->will($this->returnValue($this->createMock(ListenerAggregateInterface::class))); |
||
142 | |||
143 | $service = $this->factory->createService($sl); |
||
144 | |||
145 | $this->assertInstanceOf(TemplateService::class, $service); |
||
146 | } |
||
147 | } |
||
148 |