| Conditions | 1 |
| Paths | 1 |
| Total Lines | 91 |
| Code Lines | 54 |
| 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 |
||
| 62 | public function testModuleGeneration() |
||
| 63 | { |
||
| 64 | $this->moduleFactory->addController('AController'); |
||
| 65 | |||
| 66 | $this->moduleFactory->addModel('AModel', true, true); |
||
| 67 | |||
| 68 | $this->moduleFactory->addTest('AServiceTest', 'service'); |
||
| 69 | $this->moduleFactory->addTest('AHttpTest', 'http'); |
||
| 70 | $this->moduleFactory->addTest('AUnitTest', 'unit'); |
||
| 71 | |||
| 72 | $this->moduleFactory->addCommand('ACommand', 'command:dosomething'); |
||
| 73 | |||
| 74 | $this->moduleFactory->addEvent('WasCreatedEvent'); |
||
| 75 | $this->moduleFactory->addEvent('WasUpdatedEvent'); |
||
| 76 | $this->moduleFactory->addEvent('WasDeletedEvent'); |
||
| 77 | |||
| 78 | $this->moduleFactory->addListener('AListener', 'WasCreatedEvent'); |
||
| 79 | |||
| 80 | $this->moduleFactory->addService('AService'); |
||
| 81 | |||
| 82 | $this->moduleFactory->addRequest('ARequest'); |
||
| 83 | |||
| 84 | $this->moduleFactory->addRoute('v1'); |
||
| 85 | |||
| 86 | $this->moduleFactory->addComposer(); |
||
| 87 | |||
| 88 | $this->moduleFactory->addMiddleware('AMiddleware'); |
||
| 89 | |||
| 90 | $this->moduleFactory->addPolicy('APolicy'); |
||
| 91 | |||
| 92 | $this->moduleFactory->addFactory('AModel'); |
||
| 93 | |||
| 94 | $this->moduleFactory->addServiceProvider('AServiceProvider'); |
||
| 95 | |||
| 96 | $this->moduleFactory->build(); |
||
| 97 | |||
| 98 | /* @var ControllerGeneratedEvent $event */ |
||
| 99 | $event = $this->getFirstDispatchedEvent(ControllerGeneratedEvent::class); |
||
| 100 | $this->assertNotNull($event); |
||
| 101 | $this->assertEquals("AController", $event->getClassName()); |
||
| 102 | |||
| 103 | /* @var ModelGeneratedEvent $event */ |
||
| 104 | $event = $this->getFirstDispatchedEvent(ModelGeneratedEvent::class); |
||
| 105 | Event::assertDispatched(ModelGeneratedEvent::class, 1); |
||
| 106 | $this->assertNotNull($event); |
||
| 107 | $this->assertEquals("AModel", $event->getClassName()); |
||
| 108 | $this->assertTrue($event->isMongoModel()); |
||
| 109 | $this->assertTrue($event->includesMigration()); |
||
| 110 | |||
| 111 | |||
| 112 | /* @var TestGeneratedEvent[] $events */ |
||
| 113 | $events = $this->getDispatchedEvents(TestGeneratedEvent::class); |
||
| 114 | $this->assertNotEmpty($events); |
||
| 115 | |||
| 116 | $this->assertEquals($events[0]->getClassName(), "AServiceTest"); |
||
| 117 | $this->assertEquals($events[0]->getType(), "service"); |
||
| 118 | |||
| 119 | $this->assertEquals($events[1]->getClassName(), "AHttpTest"); |
||
| 120 | $this->assertEquals($events[1]->getType(), "http"); |
||
| 121 | |||
| 122 | $this->assertEquals($events[2]->getClassName(), "AUnitTest"); |
||
| 123 | $this->assertEquals($events[2]->getType(), "unit"); |
||
| 124 | |||
| 125 | Event::assertDispatched(CommandGeneratedEvent::class, 1); |
||
| 126 | |||
| 127 | /* @var CommandGeneratedEvent $event */ |
||
| 128 | $event = $this->getFirstDispatchedEvent(CommandGeneratedEvent::class); |
||
| 129 | $this->assertEquals("ACommand", $event->getClassName()); |
||
| 130 | $this->assertEquals("command:dosomething", $event->getConsoleCommand()); |
||
| 131 | $this->assertNotNull($event); |
||
| 132 | |||
| 133 | /* @var EventGeneratedEvent $event */ |
||
| 134 | Event::assertDispatched(EventGeneratedEvent::class, 3); |
||
| 135 | $event = $this->getFirstDispatchedEvent(EventGeneratedEvent::class); |
||
| 136 | $this->assertEquals("WasCreatedEvent", $event->getClassName()); |
||
| 137 | $this->assertNotNull($event); |
||
| 138 | |||
| 139 | /* @var ListenerGeneratedEvent $event */ |
||
| 140 | $event = $this->getFirstDispatchedEvent(ListenerGeneratedEvent::class); |
||
| 141 | $this->assertEquals("AListener", $event->getClassName()); |
||
| 142 | $this->assertNotNull($event); |
||
| 143 | |||
| 144 | /* @var ServiceGeneratedEvent $event */ |
||
| 145 | $event = $this->getFirstDispatchedEvent(ServiceGeneratedEvent::class); |
||
| 146 | $this->assertEquals("AService", $event->getClassName()); |
||
| 147 | $this->assertNotNull($event); |
||
| 148 | |||
| 149 | /* @var ProviderGeneratedEvent $event */ |
||
| 150 | $event = $this->getFirstDispatchedEvent(ProviderGeneratedEvent::class); |
||
| 151 | $this->assertEquals("AServiceProvider", $event->getClassName()); |
||
| 152 | $this->assertNotNull($event); |
||
| 153 | } |
||
| 155 |