Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
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 |
||
129 | public function testWorkingTreeStatus(): void |
||
130 | { |
||
131 | /*$this->markTestSkipped( |
||
132 | 'Caller::execute throws a RuntimeException here because. Repository::unstage |
||
133 | invokes "git reset HEAD -- test", which returns 1 (not 0) on git < 1.8, even though it executes successfully. |
||
134 | On new git version this is not happening anymore.' |
||
135 | );*/ |
||
136 | |||
137 | $this->addFile('test', null, 'test content'); |
||
138 | $wt = $this->repository->getWorkingTreeStatus(); |
||
139 | $this->assertCount(1, $wt->untracked()); |
||
140 | |||
141 | $this->repository->stage('test'); |
||
142 | $wt = $this->repository->getWorkingTreeStatus(); |
||
143 | $index = $this->repository->getIndexStatus(); |
||
144 | $this->assertCount(0, $wt->untracked()); |
||
145 | $this->assertCount(1, $index->added()); |
||
146 | |||
147 | $this->repository->unstage('test'); |
||
148 | $wt = $this->repository->getWorkingTreeStatus(); |
||
149 | $index = $this->repository->getIndexStatus(); |
||
150 | $this->assertCount(1, $wt->untracked()); |
||
151 | $this->assertCount(0, $index->added()); |
||
152 | |||
153 | $this->repository->commit('test-commit', true); |
||
154 | $wt = $this->repository->getWorkingTreeStatus(); |
||
155 | $index = $this->repository->getIndexStatus(); |
||
156 | $this->assertCount(0, $wt->all()); |
||
157 | $this->assertCount(0, $index->all()); |
||
158 | |||
159 | $this->addFile('test', null, 'new content'); |
||
160 | $wt = $this->repository->getWorkingTreeStatus(); |
||
161 | $index = $this->repository->getIndexStatus(); |
||
162 | $this->assertCount(1, $wt->modified()); |
||
163 | $this->assertCount(0, $index->modified()); |
||
164 | |||
165 | $this->repository->stage('test'); |
||
166 | $wt = $this->repository->getWorkingTreeStatus(); |
||
167 | $index = $this->repository->getIndexStatus(); |
||
168 | $this->assertCount(0, $wt->modified()); |
||
169 | $this->assertCount(1, $index->modified()); |
||
170 | |||
171 | $this->removeFile('test'); |
||
172 | $wt = $this->repository->getWorkingTreeStatus(); |
||
173 | $index = $this->repository->getIndexStatus(); |
||
174 | $this->assertCount(1, $wt->deleted()); |
||
175 | $this->assertCount(1, $index->modified()); |
||
176 | |||
177 | // Caller::execute throws a RuntimeException here because |
||
178 | // Repository::unstage invokes 'git reset HEAD -- test', |
||
179 | // which returns 1 (not 0), even though it executes successfully |
||
180 | // |
||
181 | // @see http://stackoverflow.com/questions/9154674/why-git-reset-file-returns-1 |
||
182 | $this->repository->unstage('test'); |
||
183 | $wt = $this->repository->getWorkingTreeStatus(); |
||
184 | $index = $this->repository->getIndexStatus(); |
||
185 | $this->assertCount(1, $wt->deleted()); |
||
186 | $this->assertCount(0, $index->all()); |
||
187 | } |
||
188 | |||
221 |