|
6 | 6 | use Igorsgm\GitHooks\Git\ChangedFiles;
|
7 | 7 |
|
8 | 8 | test('Sends ChangedFiles through HookPipes', function (string $listOfChangedFiles) {
|
9 |
| - $preCommitHook1 = mock(PreCommitHook::class)->expect( |
10 |
| - handle: function (ChangedFiles $files, Closure $closure) use ($listOfChangedFiles) { |
| 9 | +// This approach is broken in the current version of Mockery |
| 10 | +// @TODO: Update this test once Pest or Mockery versions are updated |
| 11 | +// $preCommitHook1 = mock(PreCommitHook::class)->expect( |
| 12 | +// handle: function (ChangedFiles $files, Closure $closure) use ($listOfChangedFiles) { |
| 13 | +// $firstChangedFile = (string) $files->getFiles()->first(); |
| 14 | +// expect($firstChangedFile)->toBe($listOfChangedFiles); |
| 15 | +// } |
| 16 | +// ); |
| 17 | + $preCommitHook1 = mock(PreCommitHook::class); |
| 18 | + $preCommitHook1->expects('handle') |
| 19 | + ->andReturnUsing(function (ChangedFiles $files, Closure $closure) use ($listOfChangedFiles) { |
11 | 20 | $firstChangedFile = (string) $files->getFiles()->first();
|
12 | 21 | expect($firstChangedFile)->toBe($listOfChangedFiles);
|
13 |
| - } |
14 |
| - ); |
| 22 | + }); |
| 23 | + |
15 | 24 | $preCommitHook2 = clone $preCommitHook1;
|
16 | 25 |
|
17 | 26 | $this->config->set('git-hooks.pre-commit', [
|
|
25 | 34 | })->with('listOfChangedFiles');
|
26 | 35 |
|
27 | 36 | it('Returns 1 on HookFailException', function ($listOfChangedFiles) {
|
28 |
| - $preCommitHook1 = mock(PreCommitHook::class)->expect( |
29 |
| - handle: function (ChangedFiles $files, Closure $closure) { |
| 37 | +// This approach is broken in the current version of Mockery |
| 38 | +// @TODO: Update this test once Pest or Mockery versions are updated |
| 39 | +// $preCommitHook1 = mock(PreCommitHook::class)->expect( |
| 40 | +// handle: function (ChangedFiles $files, Closure $closure) { |
| 41 | +// throw new HookFailException(); |
| 42 | +// } |
| 43 | +// ); |
| 44 | + $preCommitHook1 = mock(PreCommitHook::class); |
| 45 | + $preCommitHook1->expects('handle') |
| 46 | + ->andReturnUsing(function (ChangedFiles $files, Closure $closure) { |
30 | 47 | throw new HookFailException();
|
31 |
| - } |
32 |
| - ); |
| 48 | + }); |
| 49 | + |
33 | 50 |
|
34 | 51 | $this->config->set('git-hooks.pre-commit', [
|
35 | 52 | $preCommitHook1,
|
|
0 commit comments