Skip to content

Commit

Permalink
Merge pull request #26 from dsbilling/master
Browse files Browse the repository at this point in the history
Update Pint defaults
  • Loading branch information
igorsgm authored Jan 4, 2024
2 parents 3a68f06 + 7b45bb3 commit b29c74b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 47 deletions.
4 changes: 2 additions & 2 deletions config/git-hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@
'code_analyzers' => [
'laravel_pint' => [
'path' => env('LARAVEL_PINT_PATH', 'vendor/bin/pint'),
'config' => env('LARAVEL_PINT_CONFIG', 'pint.json'),
'preset' => env('LARAVEL_PINT_PRESET', 'psr12'),
'config' => env('LARAVEL_PINT_CONFIG'),
'preset' => env('LARAVEL_PINT_PRESET', 'laravel'),
'file_extensions' => env('LARAVEL_PINT_FILE_EXTENSIONS', '/\.php$/'),
],
'php_code_sniffer' => [
Expand Down
2 changes: 0 additions & 2 deletions src/Contracts/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ interface Hook
{
/**
* Get hook name
*
* @return string
*/
public function getName(): ?string;
}
26 changes: 13 additions & 13 deletions tests/Features/Commands/PostCommitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
use Igorsgm\GitHooks\Git\Log;

test('Git Log is sent through HookPipes', function (string $logText) {
// This approach is broken in the current version of Mockery
// @TODO: Update this test once Pest or Mockery versions are updated
// $postCommitHook1 = mock(PostCommitHook::class)->expect(
// handle: fn (Log $log, Closure $closure) => expect($log->getHash())->toBe(mockCommitHash())
// );
// This approach is broken in the current version of Mockery
// @TODO: Update this test once Pest or Mockery versions are updated
// $postCommitHook1 = mock(PostCommitHook::class)->expect(
// handle: fn (Log $log, Closure $closure) => expect($log->getHash())->toBe(mockCommitHash())
// );

$postCommitHook1 = mock(PostCommitHook::class);
$postCommitHook1->expects('handle')
->withArgs(fn($log, $closure) => $log->getHash() === mockCommitHash());
->withArgs(fn ($log, $closure) => $log->getHash() === mockCommitHash());

$postCommitHook2 = clone $postCommitHook1;

Expand All @@ -29,13 +29,13 @@
})->with('lastCommitLogText');

it('Returns 1 on HookFailException', function ($logText) {
// This approach is broken in the current version of Mockery
// @TODO: Update this test once Pest or Mockery versions are updated
// $postCommitHook1 = mock(PostCommitHook::class)->expect(
// handle: function (Log $log, Closure $closure) {
// throw new HookFailException();
// }
// );
// This approach is broken in the current version of Mockery
// @TODO: Update this test once Pest or Mockery versions are updated
// $postCommitHook1 = mock(PostCommitHook::class)->expect(
// handle: function (Log $log, Closure $closure) {
// throw new HookFailException();
// }
// );

$postCommitHook1 = mock(PostCommitHook::class);
$postCommitHook1->expects('handle')
Expand Down
31 changes: 15 additions & 16 deletions tests/Features/Commands/PreCommitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
use Igorsgm\GitHooks\Git\ChangedFiles;

test('Sends ChangedFiles through HookPipes', function (string $listOfChangedFiles) {
// This approach is broken in the current version of Mockery
// @TODO: Update this test once Pest or Mockery versions are updated
// $preCommitHook1 = mock(PreCommitHook::class)->expect(
// handle: function (ChangedFiles $files, Closure $closure) use ($listOfChangedFiles) {
// $firstChangedFile = (string) $files->getFiles()->first();
// expect($firstChangedFile)->toBe($listOfChangedFiles);
// }
// );
// This approach is broken in the current version of Mockery
// @TODO: Update this test once Pest or Mockery versions are updated
// $preCommitHook1 = mock(PreCommitHook::class)->expect(
// handle: function (ChangedFiles $files, Closure $closure) use ($listOfChangedFiles) {
// $firstChangedFile = (string) $files->getFiles()->first();
// expect($firstChangedFile)->toBe($listOfChangedFiles);
// }
// );
$preCommitHook1 = mock(PreCommitHook::class);
$preCommitHook1->expects('handle')
->andReturnUsing(function (ChangedFiles $files, Closure $closure) use ($listOfChangedFiles) {
Expand All @@ -34,20 +34,19 @@
})->with('listOfChangedFiles');

it('Returns 1 on HookFailException', function ($listOfChangedFiles) {
// This approach is broken in the current version of Mockery
// @TODO: Update this test once Pest or Mockery versions are updated
// $preCommitHook1 = mock(PreCommitHook::class)->expect(
// handle: function (ChangedFiles $files, Closure $closure) {
// throw new HookFailException();
// }
// );
// This approach is broken in the current version of Mockery
// @TODO: Update this test once Pest or Mockery versions are updated
// $preCommitHook1 = mock(PreCommitHook::class)->expect(
// handle: function (ChangedFiles $files, Closure $closure) {
// throw new HookFailException();
// }
// );
$preCommitHook1 = mock(PreCommitHook::class);
$preCommitHook1->expects('handle')
->andReturnUsing(function (ChangedFiles $files, Closure $closure) {
throw new HookFailException();
});


$this->config->set('git-hooks.pre-commit', [
$preCommitHook1,
]);
Expand Down
12 changes: 6 additions & 6 deletions tests/Features/Commands/PrePushTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
use Igorsgm\GitHooks\Git\Log;

test('Git Log is sent through HookPipes', function (string $logText) {
// This approach is broken in the current version of Mockery
// @TODO: Update this test once Pest or Mockery versions are updated
// $prePushHook1 = mock(PostCommitHook::class)->expect(
// handle: fn (Log $log, Closure $closure) => expect($log->getHash())->toBe(mockCommitHash())
// );
// This approach is broken in the current version of Mockery
// @TODO: Update this test once Pest or Mockery versions are updated
// $prePushHook1 = mock(PostCommitHook::class)->expect(
// handle: fn (Log $log, Closure $closure) => expect($log->getHash())->toBe(mockCommitHash())
// );
$prePushHook1 = mock(PostCommitHook::class);
$prePushHook1->expects('handle')
->withArgs(fn(Log $log, Closure $closure) => $log->getHash() === mockCommitHash())
->withArgs(fn (Log $log, Closure $closure) => $log->getHash() === mockCommitHash())
->once();

$prePushHook2 = clone $prePushHook1;
Expand Down
15 changes: 7 additions & 8 deletions tests/Features/Commands/PrepareCommitMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,19 @@
})->with('listOfChangedFiles');

it('Returns 1 on HookFailException', function ($listOfChangedFiles) {
// This approach is broken in the current version of Mockery
// @TODO: Update this test once Pest or Mockery versions are updated
// $postCommitHook1 = mock(MessageHook::class)->expect(
// handle: function (CommitMessage $commitMessage, Closure $closure) {
// throw new HookFailException();
// }
// );
// This approach is broken in the current version of Mockery
// @TODO: Update this test once Pest or Mockery versions are updated
// $postCommitHook1 = mock(MessageHook::class)->expect(
// handle: function (CommitMessage $commitMessage, Closure $closure) {
// throw new HookFailException();
// }
// );
$postCommitHook1 = mock(MessageHook::class);
$postCommitHook1->expects('handle')
->andReturnUsing(function (CommitMessage $commitMessage, Closure $closure) {
throw new HookFailException();
});


$this->config->set('git-hooks.prepare-commit-msg', [
$postCommitHook1,
]);
Expand Down

0 comments on commit b29c74b

Please sign in to comment.