Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
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 |
||
57 | public function testGetVariationOfImageAsset() |
||
58 | { |
||
59 | $assetField = new Field([ |
||
60 | 'value' => new ImageAsset\Value([ |
||
61 | 'destinationContentId' => 486, |
||
62 | ]), |
||
63 | ]); |
||
64 | $imageField = new Field([ |
||
65 | 'value' => new Image\Value([ |
||
66 | 'id' => 'images/6/8/4/0/486-10-eng-GB/photo.jpg', |
||
67 | ]), |
||
68 | ]); |
||
69 | |||
70 | $assetVersionInfo = new VersionInfo(); |
||
71 | $imageVersionInfo = new VersionInfo(); |
||
72 | $imageContent = new Content([ |
||
73 | 'versionInfo' => $imageVersionInfo, |
||
74 | ]); |
||
75 | |||
76 | $variationName = 'thumbnail'; |
||
77 | $parameters = []; |
||
78 | |||
79 | $expectedVariation = new Variation(); |
||
80 | |||
81 | $this->contentService |
||
82 | ->expects($this->once()) |
||
83 | ->method('loadContent') |
||
84 | ->with($assetField->value->destinationContentId) |
||
85 | ->willReturn($imageContent); |
||
86 | |||
87 | $this->assetMapper |
||
88 | ->expects($this->once()) |
||
89 | ->method('getAssetField') |
||
90 | ->with($imageContent) |
||
91 | ->willReturn($imageField); |
||
92 | |||
93 | $this->innerAliasGenerator |
||
94 | ->expects($this->once()) |
||
95 | ->method('getVariation') |
||
96 | ->with($imageField, $imageVersionInfo, $variationName, $parameters) |
||
97 | ->willReturn($expectedVariation); |
||
98 | |||
99 | $actualVariation = $this->aliasGenerator->getVariation( |
||
100 | $assetField, |
||
101 | $assetVersionInfo, |
||
102 | $variationName, |
||
103 | $parameters |
||
104 | ); |
||
105 | |||
106 | $this->assertEquals($expectedVariation, $actualVariation); |
||
107 | } |
||
108 | |||
153 |