Conditions | 1 |
Paths | 1 |
Total Lines | 73 |
Code Lines | 46 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
116 | public function testChangedConfig() |
||
117 | { |
||
118 | $changedConfig = array( |
||
119 | 'fallback' => true, |
||
120 | 'requestCache' => false, |
||
121 | 'requestLog' => true, |
||
122 | 'circuitBreaker' => array( |
||
123 | 'errorThresholdPercentage' => 101, |
||
124 | 'forceOpen' => true, |
||
125 | 'forceClosed' => true, |
||
126 | 'requestVolumeThreshold' => 102, |
||
127 | 'sleepWindowInMilliseconds' => 103, |
||
128 | ), |
||
129 | 'metrics' => array( |
||
130 | 'healthSnapshotIntervalInMilliseconds' => 104, |
||
131 | 'rollingStatisticalWindowInMilliseconds' => 105, |
||
132 | 'rollingStatisticalWindowBuckets' => 106, |
||
133 | ), |
||
134 | ); |
||
135 | |||
136 | $container = new ContainerBuilder(); |
||
137 | $this->extension->load(array(array('default' => $changedConfig)), $container); |
||
138 | |||
139 | $configArrayAll = $container->getParameter('phystrix.configuration.data'); |
||
140 | |||
141 | $this->assertArrayHasKey('default', $configArrayAll); |
||
142 | |||
143 | $defaultConfigArray = $configArrayAll['default']; |
||
144 | |||
145 | // fallback |
||
146 | $this->assertArrayHasKey('fallback', $defaultConfigArray); |
||
147 | $this->assertEquals(true, $defaultConfigArray['fallback']['enabled']); |
||
148 | |||
149 | // requestCache |
||
150 | $this->assertArrayHasKey('requestCache', $defaultConfigArray); |
||
151 | $this->assertEquals(false, $defaultConfigArray['requestCache']['enabled']); |
||
152 | |||
153 | // requestLog |
||
154 | $this->assertArrayHasKey('requestLog', $defaultConfigArray); |
||
155 | $this->assertEquals(true, $defaultConfigArray['fallback']['enabled']); |
||
156 | |||
157 | // circuitBreaker |
||
158 | $this->assertArrayHasKey('circuitBreaker', $defaultConfigArray); |
||
159 | $circuitBreakerConfigArray = $defaultConfigArray['circuitBreaker']; |
||
160 | |||
161 | $this->assertArrayHasKey('errorThresholdPercentage', $circuitBreakerConfigArray); |
||
162 | $this->assertEquals(101, $circuitBreakerConfigArray['errorThresholdPercentage']); |
||
163 | |||
164 | $this->assertArrayHasKey('requestVolumeThreshold', $circuitBreakerConfigArray); |
||
165 | $this->assertEquals(102, $circuitBreakerConfigArray['requestVolumeThreshold']); |
||
166 | |||
167 | $this->assertArrayHasKey('sleepWindowInMilliseconds', $circuitBreakerConfigArray); |
||
168 | $this->assertEquals(103, $circuitBreakerConfigArray['sleepWindowInMilliseconds']); |
||
169 | |||
170 | $this->assertArrayHasKey('forceOpen', $circuitBreakerConfigArray); |
||
171 | $this->assertTrue($circuitBreakerConfigArray['forceOpen']); |
||
172 | |||
173 | $this->assertArrayHasKey('forceClosed', $circuitBreakerConfigArray); |
||
174 | $this->assertTrue($circuitBreakerConfigArray['forceClosed']); |
||
175 | |||
176 | // metrics |
||
177 | $this->assertArrayHasKey('metrics', $defaultConfigArray); |
||
178 | $metricsConfigArray = $defaultConfigArray['metrics']; |
||
179 | |||
180 | $this->assertArrayHasKey('healthSnapshotIntervalInMilliseconds', $metricsConfigArray); |
||
181 | $this->assertEquals(104, $metricsConfigArray['healthSnapshotIntervalInMilliseconds']); |
||
182 | |||
183 | $this->assertArrayHasKey('rollingStatisticalWindowInMilliseconds', $metricsConfigArray); |
||
184 | $this->assertEquals(105, $metricsConfigArray['rollingStatisticalWindowInMilliseconds']); |
||
185 | |||
186 | $this->assertArrayHasKey('rollingStatisticalWindowBuckets', $metricsConfigArray); |
||
187 | $this->assertEquals(106, $metricsConfigArray['rollingStatisticalWindowBuckets']); |
||
188 | } |
||
189 | |||
199 |