| Conditions | 1 |
| Paths | 1 |
| Total Lines | 76 |
| Code Lines | 61 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | 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 |
||
| 22 | public function testProcess() |
||
| 23 | { |
||
| 24 | $serviceDouble = $this |
||
| 25 | ->getMockBuilder('Symfony\\Component\\DependencyInjection\\Definition') |
||
| 26 | ->disableOriginalConstructor() |
||
| 27 | ->setMethods(['getTag']) |
||
| 28 | ->getMock(); |
||
| 29 | $serviceDouble |
||
| 30 | ->expects($this->once()) |
||
| 31 | ->method('getTag') |
||
| 32 | ->with('graviton.rest') |
||
| 33 | ->willReturn([]); |
||
| 34 | |||
| 35 | $containerDouble = $this |
||
| 36 | ->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder') |
||
| 37 | ->disableOriginalConstructor() |
||
| 38 | ->getMock(); |
||
| 39 | $containerDouble |
||
| 40 | ->expects($this->once()) |
||
| 41 | ->method('findTaggedServiceIds') |
||
| 42 | ->with('graviton.rest') |
||
| 43 | ->willReturn(['gravitonTest.document.controller.A' => []]); |
||
| 44 | $containerDouble |
||
| 45 | ->expects($this->once()) |
||
| 46 | ->method('getDefinition') |
||
| 47 | ->with('gravitonTest.document.controller.A') |
||
| 48 | ->willReturn($serviceDouble); |
||
| 49 | $containerDouble |
||
| 50 | ->expects($this->once()) |
||
| 51 | ->method('setParameter') |
||
| 52 | ->with( |
||
| 53 | $this->equalTo('graviton.document.extref.fields'), |
||
| 54 | [ |
||
| 55 | 'gravitontest.document.rest.a.get' => [ |
||
| 56 | '$exposedRefA', |
||
| 57 | |||
| 58 | 'achild.$exposedRefB', |
||
| 59 | 'achild.bchild.$exposedRefC', |
||
| 60 | 'achild.bchildren.0.$exposedRefC', |
||
| 61 | |||
| 62 | 'achildren.0.$exposedRefB', |
||
| 63 | 'achildren.0.bchild.$exposedRefC', |
||
| 64 | 'achildren.0.bchildren.0.$exposedRefC', |
||
| 65 | ], |
||
| 66 | 'gravitontest.document.rest.a.all' => [ |
||
| 67 | '$exposedRefA', |
||
| 68 | |||
| 69 | 'achild.$exposedRefB', |
||
| 70 | 'achild.bchild.$exposedRefC', |
||
| 71 | 'achild.bchildren.0.$exposedRefC', |
||
| 72 | |||
| 73 | 'achildren.0.$exposedRefB', |
||
| 74 | 'achildren.0.bchild.$exposedRefC', |
||
| 75 | 'achildren.0.bchildren.0.$exposedRefC', |
||
| 76 | ], |
||
| 77 | ] |
||
| 78 | ); |
||
| 79 | |||
| 80 | $documentMap = new DocumentMap( |
||
| 81 | (new Finder()) |
||
| 82 | ->in(__DIR__.'/Resources/doctrine/extref') |
||
| 83 | ->name('*.mongodb.xml'), |
||
| 84 | (new Finder()) |
||
| 85 | ->in(__DIR__.'/Resources/serializer/extref') |
||
| 86 | ->name('*.xml'), |
||
| 87 | (new Finder()) |
||
| 88 | ->in(__DIR__.'/Resources/validation/extref') |
||
| 89 | ->name('*.xml'), |
||
| 90 | (new Finder()) |
||
| 91 | ->in(__DIR__.'/Resources/schema') |
||
| 92 | ->name('*.json') |
||
| 93 | ); |
||
| 94 | |||
| 95 | $compilerPass = new ExtRefFieldsCompilerPass($documentMap); |
||
| 96 | $compilerPass->process($containerDouble); |
||
| 97 | } |
||
| 98 | } |
||
| 99 |