|
39 | 39 | expect($result)->toBe('passed');
|
40 | 40 | })->with('modifiedFilesList');
|
41 | 41 |
|
| 42 | +test('Skips Pint check when there is none php files added to commit', function ($pintConfiguration) { |
| 43 | + $this->config->set('git-hooks.code_analyzers.laravel_pint', $pintConfiguration); |
| 44 | + $this->config->set('git-hooks.pre-commit', [ |
| 45 | + PintPreCommitHook::class, |
| 46 | + ]); |
| 47 | + |
| 48 | + $this->makeTempFile('sample.js', |
| 49 | + file_get_contents(__DIR__.'/../../../Fixtures/sample.js') |
| 50 | + ); |
| 51 | + |
| 52 | + GitHooks::shouldReceive('isMergeInProgress')->andReturn(false); |
| 53 | + GitHooks::shouldReceive('getListOfChangedFiles')->andReturn('AM src/sample.js'); |
| 54 | + |
| 55 | + $this->artisan('git-hooks:pre-commit')->assertSuccessful(); |
| 56 | +})->with('pintConfigurations'); |
| 57 | + |
42 | 58 | test('Throws HookFailException and notifies when Pint is not installed', function ($listOfFixableFiles) {
|
43 | 59 | $this->config->set('git-hooks.code_analyzers.laravel_pint', [
|
44 | 60 | 'path' => 'inexistent/path/to/pint',
|
|
54 | 70 | $this->artisan('git-hooks:pre-commit')
|
55 | 71 | ->expectsOutputToContain('Pint is not installed.')
|
56 | 72 | ->assertExitCode(1);
|
57 |
| -})->with('listOfFixableFiles'); |
| 73 | +})->with('listOfFixableFiles', 'pintConfigurations'); |
58 | 74 |
|
59 |
| -test('Fails commit when Pint is not passing and user does not autofix the files', function ($listOfFixableFiles) { |
60 |
| - $this->config->set('git-hooks.code_analyzers.laravel_pint', [ |
61 |
| - 'path' => '../../../bin/pint', |
62 |
| - 'preset' => 'psr12', |
63 |
| - ]); |
| 75 | +test('Fails commit when Pint is not passing and user does not autofix the files', function ($pintConfiguration, $listOfFixableFiles) { |
| 76 | + $this->config->set('git-hooks.code_analyzers.laravel_pint', $pintConfiguration); |
64 | 77 | $this->config->set('git-hooks.pre-commit', [
|
65 | 78 | PintPreCommitHook::class,
|
66 | 79 | ]);
|
|
77 | 90 | ->expectsOutputToContain('COMMIT FAILED')
|
78 | 91 | ->expectsConfirmation('Would you like to attempt to correct files automagically?', 'no')
|
79 | 92 | ->assertExitCode(1);
|
80 |
| -})->with('listOfFixableFiles'); |
| 93 | +})->with('pintConfigurations', 'listOfFixableFiles'); |
81 | 94 |
|
82 |
| -test('Commit passes when Pint fixes fix the files', function ($listOfFixableFiles) { |
83 |
| - $this->config->set('git-hooks.code_analyzers.laravel_pint', [ |
84 |
| - 'path' => '../../../bin/pint', |
85 |
| - 'preset' => 'psr12', |
86 |
| - ]); |
| 95 | +test('Commit passes when Pint fixes fix the files', function ($pintConfiguration, $listOfFixableFiles) { |
| 96 | + $this->config->set('git-hooks.code_analyzers.laravel_pint', $pintConfiguration); |
87 | 97 | $this->config->set('git-hooks.pre-commit', [
|
88 | 98 | PintPreCommitHook::class,
|
89 | 99 | ]);
|
|
103 | 113 | $this->artisan('git-hooks:pre-commit')
|
104 | 114 | ->doesntExpectOutputToContain('Pint Failed')
|
105 | 115 | ->assertSuccessful();
|
106 |
| -})->with('listOfFixableFiles'); |
| 116 | +})->with('pintConfigurations', 'listOfFixableFiles'); |
0 commit comments