| Conditions | 1 |
| Paths | 1 |
| Total Lines | 83 |
| Code Lines | 69 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 90 | public function testReportRoutingSystem(): void |
||
| 91 | { |
||
| 92 | $contents = file_get_contents( |
||
| 93 | __DIR__ . '/../Fixture/report_issue_16853_js.json' |
||
| 94 | ); |
||
| 95 | $report = Report::fromString($contents); |
||
| 96 | |||
| 97 | $tags = $report->getTags(); |
||
| 98 | $contexts = $report->getContexts(); |
||
| 99 | $extras = $report->getExtras(); |
||
| 100 | $reports = $report->getReports(); |
||
| 101 | $user = $report->getUser(); |
||
| 102 | $message = $report->getUserMessage(); |
||
| 103 | $toJson = $report->toJson(); |
||
| 104 | |||
| 105 | $this->assertEquals((object) [ |
||
| 106 | 'server_software' => 'nginx/1.14.2', |
||
| 107 | 'user_agent_string' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0', |
||
| 108 | 'locale' => 'en', |
||
| 109 | 'configuration_storage' => false, |
||
| 110 | 'php_version' => '7.4.14', |
||
| 111 | 'exception_type' => 'js', |
||
| 112 | ], $tags); |
||
| 113 | $this->assertEquals((object) [ |
||
| 114 | 'os' => (object) ['name' => 'Win'], |
||
| 115 | 'browser' => (object) [ |
||
| 116 | 'name' => 'FIREFOX', |
||
| 117 | 'version' => '90.0', |
||
| 118 | ], |
||
| 119 | ], $contexts); |
||
| 120 | $this->assertEquals((object) [], $extras); |
||
| 121 | $this->assertEquals((object) ['message' => ''], $message); |
||
| 122 | $this->assertEquals( |
||
| 123 | (object) [ |
||
| 124 | 'ip_address' => '0.0.0.0', |
||
| 125 | 'id' => '99a62784e874c1a5b4625660a94c736bbb8ca46f53d321ab8ce700050e30cb97', |
||
| 126 | ], |
||
| 127 | $user |
||
| 128 | ); |
||
| 129 | $this->assertFalse($report->isMultiReports()); |
||
| 130 | $this->assertFalse($report->hasUserFeedback()); |
||
| 131 | $this->assertEquals([ |
||
| 132 | [ |
||
| 133 | 'sentry.interfaces.Message' => $message, |
||
| 134 | 'release' => '5.2.0-dev', |
||
| 135 | 'dist' => '5.2.0-dev', |
||
| 136 | 'platform' => 'javascript', |
||
| 137 | 'environment' => 'development', |
||
| 138 | 'transaction' => '/database/designer', |
||
| 139 | 'timestamp' => $report->getTimestampUTC(), |
||
| 140 | 'tags' => $tags, |
||
| 141 | 'contexts' => $contexts, |
||
| 142 | 'extra' => $extras, |
||
| 143 | 'user' => $user, |
||
| 144 | 'exception' => [ |
||
| 145 | 'values' => [ |
||
| 146 | (object) [ |
||
| 147 | 'type' => 'TypeError', |
||
| 148 | 'value' => 'can\'t access property "transaction", db is null', |
||
| 149 | 'stacktrace' => (object) [ |
||
| 150 | 'frames' => $reports[0]['exception']['values'][0]->stacktrace->frames, |
||
| 151 | ], |
||
| 152 | ], |
||
| 153 | ], |
||
| 154 | ], |
||
| 155 | 'message' => 'can\'t access property "transaction", db is null', |
||
| 156 | 'culprit' => 'index.php', |
||
| 157 | 'event_id' => $report->getEventId(), |
||
| 158 | ], |
||
| 159 | ], $reports); |
||
| 160 | $this->assertEquals([ |
||
| 161 | 'sentry.interfaces.Message' => $message, |
||
| 162 | 'release' => '5.2.0-dev', |
||
| 163 | 'dist' => '5.2.0-dev', |
||
| 164 | 'platform' => 'javascript', |
||
| 165 | 'environment' => 'development', |
||
| 166 | 'transaction' => '/database/designer', |
||
| 167 | 'timestamp' => $report->getTimestampUTC(), |
||
| 168 | 'tags' => $tags, |
||
| 169 | 'contexts' => $contexts, |
||
| 170 | 'extra' => $extras, |
||
| 171 | 'user' => $user, |
||
| 172 | ], $toJson); |
||
| 173 | } |
||
| 276 |