| Conditions | 8 |
| Paths | 64 |
| Total Lines | 76 |
| Code Lines | 44 |
| 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 |
||
| 102 | public function testMultiAppRun($request, $auto, $name, $path = null) |
||
| 103 | { |
||
| 104 | $root = vfsStream::setup('rootDir', null, [ |
||
| 105 | 'app' => [ |
||
| 106 | 'middleware.php' => '<?php return [];', |
||
| 107 | 'app1' => [ |
||
| 108 | 'common.php' => '', |
||
| 109 | 'event.php' => '<?php return ["bind"=>[],"listen"=>[],"subscribe"=>[]];', |
||
| 110 | 'provider.php' => '<?php return [];', |
||
| 111 | 'middleware.php' => '<?php return [];', |
||
| 112 | 'config' => [ |
||
| 113 | 'app.php' => '<?php return [];', |
||
| 114 | ], |
||
| 115 | ], |
||
| 116 | ], |
||
| 117 | 'config' => [ |
||
| 118 | 'app.php' => '<?php return [];', |
||
| 119 | 'app1' => [ |
||
| 120 | 'app.php' => '<?php return [];', |
||
| 121 | ], |
||
| 122 | ], |
||
| 123 | 'route' => [ |
||
| 124 | 'route.php' => '<?php return [];', |
||
| 125 | ], |
||
| 126 | ]); |
||
| 127 | |||
| 128 | $config = m::mock(Config::class)->makePartial(); |
||
| 129 | |||
| 130 | $config->shouldReceive('get')->with('app.auto_multi_app', false)->andReturn($auto); |
||
| 131 | |||
| 132 | $config->shouldReceive('get')->with('app.domain_bind', [])->andReturn([ |
||
| 133 | 'www.domain.com' => 'app1', |
||
| 134 | 'app2' => 'app2', |
||
| 135 | ]); |
||
| 136 | |||
| 137 | $config->shouldReceive('get')->with('app.app_map', [])->andReturn([ |
||
| 138 | 'some1' => 'app3', |
||
| 139 | ]); |
||
| 140 | |||
| 141 | $this->app->shouldReceive('get')->with('config')->andReturn($config); |
||
| 142 | |||
| 143 | $this->app->shouldReceive('getBasePath')->andReturn($root->getChild('app')->url() . DIRECTORY_SEPARATOR); |
||
| 144 | $this->app->shouldReceive('getRootPath')->andReturn($root->url() . DIRECTORY_SEPARATOR); |
||
| 145 | $this->app->shouldReceive('getConfigPath')->andReturn($root->getChild('config')->url() . DIRECTORY_SEPARATOR); |
||
| 146 | |||
| 147 | $response = m::mock(Response::class)->makePartial(); |
||
| 148 | |||
| 149 | $this->prepareApp($request, $response); |
||
| 150 | |||
| 151 | $this->assertTrue($this->http->isMulti()); |
||
| 152 | |||
| 153 | if ($name === null) { |
||
| 154 | $this->http->shouldReceive('reportException')->once(); |
||
| 155 | |||
| 156 | $this->http->shouldReceive('renderException')->once()->andReturn($response); |
||
| 157 | } |
||
| 158 | |||
| 159 | if (!$auto) { |
||
| 160 | $this->http->name($name); |
||
| 161 | } |
||
| 162 | |||
| 163 | if ($path) { |
||
| 164 | $this->http->path($path); |
||
| 165 | } |
||
| 166 | |||
| 167 | $this->assertEquals($response, $this->http->run($request)); |
||
| 168 | |||
| 169 | if ($name !== null) { |
||
| 170 | $this->assertEquals($name, $this->http->getName()); |
||
| 171 | } |
||
| 172 | |||
| 173 | if ($name === 'app1' || $name === 'app2') { |
||
| 174 | $this->assertTrue($this->http->isBindDomain()); |
||
| 175 | } |
||
| 176 | if ($path) { |
||
| 177 | $this->assertEquals($path, $this->app->getAppPath()); |
||
| 178 | } |
||
| 250 |