Conditions | 1 |
Paths | 1 |
Total Lines | 68 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Tests | 42 |
CRAP Score | 1 |
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 |
||
13 | 1 | public function testEntityCacheConfigParsing() |
|
14 | { |
||
15 | 1 | $configuration = new Configuration(); |
|
16 | 1 | $processor = new Processor(); |
|
17 | $rawConfigs = [ |
||
18 | [ |
||
19 | 1 | 'entity_cache' => null, |
|
20 | 1 | ], |
|
21 | [ |
||
22 | 1 | 'entity_cache' => 'test_cache', |
|
23 | |||
24 | 1 | ], |
|
25 | [ |
||
26 | 'entity_cache' => [ |
||
27 | 1 | 'logger' => 'logger', |
|
28 | 1 | ], |
|
29 | 1 | ], |
|
30 | [ |
||
31 | 'entity_cache' => |
||
32 | [ |
||
33 | 'configuration' => [ |
||
34 | 'TestEntity' => [ |
||
35 | 1 | 'ttl' => 10, |
|
36 | 'extra' => [ |
||
37 | 1 | 'quick_search' => false, |
|
38 | 1 | ], |
|
39 | 1 | ], |
|
40 | 1 | ], |
|
41 | 1 | ], |
|
42 | 1 | ], |
|
43 | [ |
||
44 | 'entity_cache' => |
||
45 | [ |
||
46 | 'configuration' => [ |
||
47 | 1 | 'TestEntity' => 900, |
|
48 | 1 | ], |
|
49 | 1 | ], |
|
50 | 1 | ], |
|
51 | [ |
||
52 | 'entity_cache' => |
||
53 | [ |
||
54 | 'configuration' => [ |
||
55 | 'TestEntity' => [ |
||
56 | 1 | 'enabled' => false, |
|
57 | 'extra' => [ |
||
58 | 1 | 'quick_search' => true, |
|
59 | 1 | ], |
|
60 | 1 | ], |
|
61 | 1 | ], |
|
62 | 1 | ], |
|
63 | 1 | ], |
|
64 | 1 | ]; |
|
65 | 1 | $configs = $processor->processConfiguration( |
|
66 | 1 | $configuration, |
|
67 | $rawConfigs |
||
68 | 1 | ); |
|
69 | |||
70 | 1 | self::assertTrue($configs['entity_cache']['enabled']); |
|
71 | 1 | self::assertEquals('test_cache', $configs['entity_cache']['service']); |
|
72 | 1 | self::assertFalse($configs['entity_cache']['configuration']['TestEntity']['enabled']); |
|
73 | 1 | self::assertEquals(900, $configs['entity_cache']['configuration']['TestEntity']['ttl']); |
|
74 | 1 | self::assertTrue($configs['entity_cache']['configuration']['TestEntity']['extra']['quick_search']); |
|
75 | 1 | self::assertEquals('logger', $configs['entity_cache']['logger']); |
|
76 | |||
77 | 1 | $builder = new ContainerBuilder(); |
|
78 | 1 | $extension = new BankiruDoctrineApiExtension(); |
|
79 | 1 | $extension->load($rawConfigs, $builder); |
|
80 | 1 | } |
|
81 | } |
||
82 |