1 | <?php |
||
31 | class TestCase extends \PHPUnit\Framework\TestCase |
||
32 | { |
||
33 | /** |
||
34 | * @var \GitElephant\Command\Caller\CallerInterface |
||
35 | */ |
||
36 | protected $caller; |
||
37 | |||
38 | /** |
||
39 | * @var Repository|array<Repository> |
||
40 | */ |
||
41 | protected $repository; |
||
42 | |||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $path; |
||
47 | |||
48 | /** |
||
49 | * @var Finder |
||
50 | */ |
||
51 | protected $finder; |
||
52 | |||
53 | /** |
||
54 | * @param string|int|null $name the name or index of the repository |
||
55 | * |
||
56 | * @return \GitElephant\Repository |
||
57 | */ |
||
58 | protected function getRepository($name = null) |
||
69 | |||
70 | /** |
||
71 | * @return CallerInterface the real/not mocked caller |
||
72 | */ |
||
73 | protected function getCaller(): CallerInterface |
||
81 | |||
82 | /** |
||
83 | * @param null|string $name the folder name |
||
84 | * @param int $index the repository index (for getting them back) |
||
85 | * |
||
86 | * @return void |
||
87 | */ |
||
88 | protected function initRepository(string $name = null, int $index = null): void |
||
110 | |||
111 | protected function tearDown(): void |
||
123 | |||
124 | /** |
||
125 | * Write to file. Creates the file if not existing. |
||
126 | * Overwrites content if already existing. |
||
127 | * |
||
128 | * @param string $name file name |
||
129 | * @param string|null $folder folder name |
||
130 | * @param string|null $content content |
||
131 | * @param Repository $repository repository to add file to |
||
132 | * |
||
133 | * @return void |
||
134 | */ |
||
135 | protected function addFile( |
||
150 | |||
151 | /** |
||
152 | * remove file from repo |
||
153 | * |
||
154 | * @param string $name |
||
155 | */ |
||
156 | protected function removeFile(string $name): void |
||
161 | |||
162 | /** |
||
163 | * update a file in the repository |
||
164 | * |
||
165 | * @param string $name file name |
||
166 | * @param string $content content |
||
167 | */ |
||
168 | protected function updateFile(string $name, string $content): void |
||
173 | |||
174 | /** |
||
175 | * rename a file in the repository |
||
176 | * |
||
177 | * @param string $originName file name |
||
178 | * @param string $targetName new file name |
||
179 | * @param bool $gitMv use git mv, otherwise uses php rename function (with the Filesystem component) |
||
180 | */ |
||
181 | protected function renameFile(string $originName, string $targetName, bool $gitMv = true): void |
||
195 | |||
196 | /** |
||
197 | * @param string $name name |
||
198 | * |
||
199 | * @return void |
||
200 | */ |
||
201 | protected function addFolder($name): void |
||
206 | |||
207 | protected function addSubmodule(string $url, string $path): void |
||
211 | |||
212 | /** |
||
213 | * @param string $classname |
||
214 | * |
||
215 | * @return MockObject |
||
216 | */ |
||
217 | protected function getMock(string $classname): MockObject |
||
224 | |||
225 | /** |
||
226 | * mock the caller |
||
227 | * |
||
228 | * @param string $command command |
||
229 | * @param string $output output |
||
230 | * |
||
231 | * @return MockObject |
||
232 | */ |
||
233 | protected function getMockCaller($command, $output): MockObject |
||
247 | |||
248 | protected function addCommandToMockContainer(MockObject $container, string $commandName): void |
||
256 | |||
257 | /** |
||
258 | * |
||
259 | * @param MockObject $repo |
||
260 | * @param string|array $output |
||
261 | * @return void |
||
262 | */ |
||
263 | protected function addOutputToMockRepo(MockObject $repo, $output): void |
||
270 | |||
271 | protected function getMockCommand(): MockObject |
||
281 | |||
282 | protected function getMockRepository(): MockObject |
||
293 | |||
294 | /** |
||
295 | * Do a test on a certain commit |
||
296 | * |
||
297 | * @param Commit $commit the commit to test |
||
298 | * @param string $sha |
||
299 | * @param string $tree |
||
300 | * @param string $author the name of the author |
||
301 | * @param string $committer the name of the committer |
||
302 | * @param string $emailAuthor |
||
303 | * @param string $emailCommitter |
||
304 | * @param integer $datetimeAuthor |
||
305 | * @param integer $datetimeCommitter |
||
306 | * @param string $message |
||
307 | * @return void |
||
308 | */ |
||
309 | protected function doCommitTest( |
||
336 | |||
337 | /** |
||
338 | * Compatibility function for PHP 7.2: |
||
339 | * PHPUnit 9. only supports PHP >= 7.3, |
||
340 | * but has a different compatibility regarding the assertRegex function |
||
341 | * |
||
342 | * @param string $pattern |
||
343 | * @param string $string |
||
344 | * @param string $message |
||
345 | * @return void |
||
346 | */ |
||
347 | protected function myAssertMatchesRegularExpression($pattern, $string, $message = '') |
||
355 | } |
||
356 |