From 628d1df913553a96b5c2417c956eb28f867fd5bd Mon Sep 17 00:00:00 2001 From: Sebastian Feldmann Date: Tue, 11 May 2021 14:12:05 +0200 Subject: [PATCH] Testsuite cleanup --- .github/workflows/integration.yml | 4 +- .github/workflows/release.yml | 83 +++++++++---------- composer.json | 6 +- phpunit.ci.xml | 11 --- phpunit.xml | 6 +- tests/integration/PreCommit/SuccessTest.php | 34 ++++++++ .../Config/ActionTest.php | 0 .../Config/ConditionTest.php | 0 .../Config/FactoryTest.php | 0 .../{CaptainHook => unit}/Config/HookTest.php | 0 .../{CaptainHook => unit}/Config/Mockery.php | 3 +- .../Config/OptionsTest.php | 0 .../Config/PluginTest.php | 0 .../{CaptainHook => unit}/Config/UtilTest.php | 0 tests/{CaptainHook => unit}/ConfigTest.php | 0 .../Console/ApplicationTest.php | 0 .../Console/Command/AddTest.php | 0 .../Console/Command/ConfigurationTest.php | 0 .../Console/Command/DisableTest.php | 0 .../Console/Command/EnableTest.php | 0 .../Console/Command/Hook/CommitMsgTest.php | 0 .../Console/Command/Hook/PostCheckoutTest.php | 0 .../Console/Command/Hook/PostCommitTest.php | 0 .../Console/Command/Hook/PostMergeTest.php | 0 .../Console/Command/Hook/PreCommitTest.php | 0 .../Console/Command/Hook/PrePushTest.php | 0 .../Command/Hook/PrepareCommitMsgTest.php | 0 .../Console/Command/InstallTest.php | 0 .../Console/IO/ComposerIOTest.php | 0 .../Console/IO/DefaultIOTest.php | 0 .../Console/IO/Mockery.php | 3 +- .../Console/IO/NullIOTest.php | 0 .../Console/IOUtilTest.php | 0 tests/{CaptainHook => unit}/Git/DummyRepo.php | 0 .../Hook/Branch/Action/EnsureNamingTest.php | 0 .../Composer/Action/CheckLockFileTest.php | 0 .../Hook/Condition/FileChanged/AllTest.php | 0 .../Hook/Condition/FileChanged/AnyTest.php | 0 .../Hook/Condition/FileStaged/AllTest.php | 0 .../Hook/Condition/FileStaged/AnyTest.php | 0 .../Condition/FileStaged/InDirectoryTest.php | 0 .../Hook/Condition/FileStaged/OfTypeTest.php | 0 .../Hook/Condition/Logic/LogicAndTest.php | 0 .../Hook/Condition/Logic/LogicOrTest.php | 0 .../Hook/Condition/OnBranchTest.php | 0 .../{CaptainHook => unit}/Hook/DebugTest.php | 0 .../File/Action/DoesNotContainRegexTest.php | 0 .../Hook/File/Action/ExistsTest.php | 0 .../Hook/File/Action/IsEmptyTest.php | 0 .../Hook/File/Action/IsNotEmptyTest.php | 3 +- .../Hook/File/Action/MaxSizeTest.php | 0 .../Hook/Message/Action/BeamsTest.php | 0 .../Hook/Message/Action/NoRule.php | 0 .../Hook/Message/Action/PrepareTest.php | 0 .../Hook/Message/Action/RegexTest.php | 0 .../Hook/Message/Action/RulesTest.php | 0 .../Hook/Message/Rule/BlacklistTest.php | 0 .../Message/Rule/CapitalizeSubjectTest.php | 0 .../Message/Rule/LimitBodyLineLengthTest.php | 0 .../Message/Rule/LimitSubjectLengthTest.php | 0 .../Hook/Message/Rule/MsgNotEmptyTest.php | 0 .../Message/Rule/NoPeriodOnSubjectEndTest.php | 0 ...parateSubjectFromBodyWithBlankLineTest.php | 0 .../Message/Rule/UseImperativeMoodTest.php | 0 .../Hook/Message/RuleBook/RuleSetTest.php | 0 .../Hook/Message/RuleBookTest.php | 0 tests/{CaptainHook => unit}/Hook/Mockery.php | 4 +- .../Hook/Notify/Action/NotifyTest.php | 0 .../Hook/Notify/ExtractorTest.php | 0 .../Hook/Notify/NotificationTest.php | 0 .../Hook/PHP/Action/LintingTest.php | 0 .../Hook/PHP/Action/TestCoverageTest.php | 4 +- .../PHP/CoverageResolver/CloverXmlTest.php | 0 .../Hook/PHP/CoverageResolver/PHPUnitTest.php | 2 +- .../Hook/RestrictionTest.php | 0 .../Hook/Template/BuilderTest.php | 0 .../Hook/Template/DockerTest.php | 0 .../Hook/Template/Local/PHPTest.php | 0 .../Hook/Template/Local/ShellTest.php | 0 tests/{CaptainHook => unit}/Hook/UtilTest.php | 0 tests/{CaptainHook => unit}/HooksTest.php | 0 tests/{CaptainHook => unit}/Mockery.php | 0 .../Plugin/DummyConstrainedHookPlugin.php | 0 .../Plugin/DummyConstrainedHookPluginAlt.php | 0 .../Plugin/DummyConstrainedPlugin.php | 0 .../Plugin/DummyHookPlugin.php | 0 .../Plugin/DummyHookPluginSkipsActions.php | 0 .../Plugin/DummyPlugin.php | 0 .../Plugin/Hook/PreserveWorkingTreeTest.php | 0 .../Action/Cli/Command/FormatterTest.php | 0 .../Cli/Command/Placeholder/ConfigTest.php | 0 .../Cli/Command/Placeholder/EnvTest.php | 0 .../Command/Placeholder/StagedFilesTest.php | 0 .../Runner/Action/CliTest.php | 0 .../Runner/Action/DummyNoAction.php | 0 .../Runner/Action/DummyPHPConstraint.php | 0 .../Runner/Action/DummyPHPError.php | 0 .../Runner/Action/DummyPHPFailure.php | 0 .../Runner/Action/DummyPHPSuccess.php | 0 .../Runner/Action/PHPTest.php | 0 .../Runner/ConditionTest.php | 0 .../Runner/Config/CreatorTest.php | 0 .../Runner/Config/EditorTest.php | 0 .../Runner/Config/Setup/AdvancedTest.php | 0 .../Runner/Config/Setup/ExpressTest.php | 0 .../Runner/Config/Setup/GuidedTest.php | 0 .../Runner/Hook/CommitMsgTest.php | 0 .../Runner/Hook/PostCheckoutTest.php | 0 .../Runner/Hook/PostCommitTest.php | 0 .../Runner/Hook/PostMergeTest.php | 0 .../Runner/Hook/PostRewriteTest.php | 0 .../Runner/Hook/PreCommitTest.php | 0 .../Runner/Hook/PrePushTest.php | 0 .../Runner/Hook/PrepareCommitMsgTest.php | 0 .../{CaptainHook => unit}/Runner/HookTest.php | 0 .../Runner/InstallerTest.php | 7 +- .../{CaptainHook => unit}/Runner/UtilTest.php | 0 .../Storage/File/JsonTest.php | 0 .../Storage/File/XmlTest.php | 0 .../Storage/FileTest.php | 0 120 files changed, 98 insertions(+), 72 deletions(-) delete mode 100644 phpunit.ci.xml create mode 100644 tests/integration/PreCommit/SuccessTest.php rename tests/{CaptainHook => unit}/Config/ActionTest.php (100%) rename tests/{CaptainHook => unit}/Config/ConditionTest.php (100%) rename tests/{CaptainHook => unit}/Config/FactoryTest.php (100%) rename tests/{CaptainHook => unit}/Config/HookTest.php (100%) rename tests/{CaptainHook => unit}/Config/Mockery.php (94%) rename tests/{CaptainHook => unit}/Config/OptionsTest.php (100%) rename tests/{CaptainHook => unit}/Config/PluginTest.php (100%) rename tests/{CaptainHook => unit}/Config/UtilTest.php (100%) rename tests/{CaptainHook => unit}/ConfigTest.php (100%) rename tests/{CaptainHook => unit}/Console/ApplicationTest.php (100%) rename tests/{CaptainHook => unit}/Console/Command/AddTest.php (100%) rename tests/{CaptainHook => unit}/Console/Command/ConfigurationTest.php (100%) rename tests/{CaptainHook => unit}/Console/Command/DisableTest.php (100%) rename tests/{CaptainHook => unit}/Console/Command/EnableTest.php (100%) rename tests/{CaptainHook => unit}/Console/Command/Hook/CommitMsgTest.php (100%) rename tests/{CaptainHook => unit}/Console/Command/Hook/PostCheckoutTest.php (100%) rename tests/{CaptainHook => unit}/Console/Command/Hook/PostCommitTest.php (100%) rename tests/{CaptainHook => unit}/Console/Command/Hook/PostMergeTest.php (100%) rename tests/{CaptainHook => unit}/Console/Command/Hook/PreCommitTest.php (100%) rename tests/{CaptainHook => unit}/Console/Command/Hook/PrePushTest.php (100%) rename tests/{CaptainHook => unit}/Console/Command/Hook/PrepareCommitMsgTest.php (100%) rename tests/{CaptainHook => unit}/Console/Command/InstallTest.php (100%) rename tests/{CaptainHook => unit}/Console/IO/ComposerIOTest.php (100%) rename tests/{CaptainHook => unit}/Console/IO/DefaultIOTest.php (100%) rename tests/{CaptainHook => unit}/Console/IO/Mockery.php (86%) rename tests/{CaptainHook => unit}/Console/IO/NullIOTest.php (100%) rename tests/{CaptainHook => unit}/Console/IOUtilTest.php (100%) rename tests/{CaptainHook => unit}/Git/DummyRepo.php (100%) rename tests/{CaptainHook => unit}/Hook/Branch/Action/EnsureNamingTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Composer/Action/CheckLockFileTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Condition/FileChanged/AllTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Condition/FileChanged/AnyTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Condition/FileStaged/AllTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Condition/FileStaged/AnyTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Condition/FileStaged/InDirectoryTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Condition/FileStaged/OfTypeTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Condition/Logic/LogicAndTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Condition/Logic/LogicOrTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Condition/OnBranchTest.php (100%) rename tests/{CaptainHook => unit}/Hook/DebugTest.php (100%) rename tests/{CaptainHook => unit}/Hook/File/Action/DoesNotContainRegexTest.php (100%) rename tests/{CaptainHook => unit}/Hook/File/Action/ExistsTest.php (100%) rename tests/{CaptainHook => unit}/Hook/File/Action/IsEmptyTest.php (100%) rename tests/{CaptainHook => unit}/Hook/File/Action/IsNotEmptyTest.php (98%) rename tests/{CaptainHook => unit}/Hook/File/Action/MaxSizeTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Action/BeamsTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Action/NoRule.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Action/PrepareTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Action/RegexTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Action/RulesTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Rule/BlacklistTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Rule/CapitalizeSubjectTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Rule/LimitBodyLineLengthTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Rule/LimitSubjectLengthTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Rule/MsgNotEmptyTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Rule/NoPeriodOnSubjectEndTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Rule/SeparateSubjectFromBodyWithBlankLineTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/Rule/UseImperativeMoodTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/RuleBook/RuleSetTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Message/RuleBookTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Mockery.php (86%) rename tests/{CaptainHook => unit}/Hook/Notify/Action/NotifyTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Notify/ExtractorTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Notify/NotificationTest.php (100%) rename tests/{CaptainHook => unit}/Hook/PHP/Action/LintingTest.php (100%) rename tests/{CaptainHook => unit}/Hook/PHP/Action/TestCoverageTest.php (95%) rename tests/{CaptainHook => unit}/Hook/PHP/CoverageResolver/CloverXmlTest.php (100%) rename tests/{CaptainHook => unit}/Hook/PHP/CoverageResolver/PHPUnitTest.php (94%) rename tests/{CaptainHook => unit}/Hook/RestrictionTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Template/BuilderTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Template/DockerTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Template/Local/PHPTest.php (100%) rename tests/{CaptainHook => unit}/Hook/Template/Local/ShellTest.php (100%) rename tests/{CaptainHook => unit}/Hook/UtilTest.php (100%) rename tests/{CaptainHook => unit}/HooksTest.php (100%) rename tests/{CaptainHook => unit}/Mockery.php (100%) rename tests/{CaptainHook => unit}/Plugin/DummyConstrainedHookPlugin.php (100%) rename tests/{CaptainHook => unit}/Plugin/DummyConstrainedHookPluginAlt.php (100%) rename tests/{CaptainHook => unit}/Plugin/DummyConstrainedPlugin.php (100%) rename tests/{CaptainHook => unit}/Plugin/DummyHookPlugin.php (100%) rename tests/{CaptainHook => unit}/Plugin/DummyHookPluginSkipsActions.php (100%) rename tests/{CaptainHook => unit}/Plugin/DummyPlugin.php (100%) rename tests/{CaptainHook => unit}/Plugin/Hook/PreserveWorkingTreeTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Action/Cli/Command/FormatterTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Action/Cli/Command/Placeholder/ConfigTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Action/Cli/Command/Placeholder/EnvTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Action/Cli/Command/Placeholder/StagedFilesTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Action/CliTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Action/DummyNoAction.php (100%) rename tests/{CaptainHook => unit}/Runner/Action/DummyPHPConstraint.php (100%) rename tests/{CaptainHook => unit}/Runner/Action/DummyPHPError.php (100%) rename tests/{CaptainHook => unit}/Runner/Action/DummyPHPFailure.php (100%) rename tests/{CaptainHook => unit}/Runner/Action/DummyPHPSuccess.php (100%) rename tests/{CaptainHook => unit}/Runner/Action/PHPTest.php (100%) rename tests/{CaptainHook => unit}/Runner/ConditionTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Config/CreatorTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Config/EditorTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Config/Setup/AdvancedTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Config/Setup/ExpressTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Config/Setup/GuidedTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Hook/CommitMsgTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Hook/PostCheckoutTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Hook/PostCommitTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Hook/PostMergeTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Hook/PostRewriteTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Hook/PreCommitTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Hook/PrePushTest.php (100%) rename tests/{CaptainHook => unit}/Runner/Hook/PrepareCommitMsgTest.php (100%) rename tests/{CaptainHook => unit}/Runner/HookTest.php (100%) rename tests/{CaptainHook => unit}/Runner/InstallerTest.php (98%) rename tests/{CaptainHook => unit}/Runner/UtilTest.php (100%) rename tests/{CaptainHook => unit}/Storage/File/JsonTest.php (100%) rename tests/{CaptainHook => unit}/Storage/File/XmlTest.php (100%) rename tests/{CaptainHook => unit}/Storage/FileTest.php (100%) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 60984494..dba2ec0c 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -45,10 +45,10 @@ jobs: run: GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} tools/phive --no-progress --home ./.phive install --force-accept-unsigned --trust-gpg-keys 4AA394086372C20A,31C7E470E2138192,8E730BA25823D8B5,CF1A108D0E7AE720 - name: Execute unit tests - run: tools/phpunit --configuration=phpunit.ci.xml --testsuite CaptainHook + run: tools/phpunit --no-coverage --testsuite UnitTests - name: Execute integration tests - run: tools/phpunit --configuration=phpunit.ci.xml --testsuite Integration + run: tools/phpunit --no-coverage --testsuite IntegrationTests - name: Check coding style run: tools/phpcs --standard=psr12 src tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 02fd062c..62fa5894 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,15 +7,12 @@ on: jobs: release: - name: "Release" - - runs-on: "ubuntu-latest" - + name: Release + runs-on: ubuntu-latest strategy: matrix: - dependencies: - - "locked" + - locked env: PHAR: "build/phar/captainhook.phar" @@ -40,55 +37,55 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-dev --no-interaction --no-progress - - name: "Install tooling" + - name: Install tooling run: "GITHUB_AUTH_TOKEN=${{ secrets.GITHUB_API_TOKEN }} tools/phive --no-progress --home ./.phive install --force-accept-unsigned --trust-gpg-keys 4AA394086372C20A,31C7E470E2138192,8E730BA25823D8B5,CF1A108D0E7AE720" - - name: "Validate configuration for humbug/box" - run: "tools/box validate box.json" + - name: Validate configuration for humbug/box + run: tools/box validate box.json - name: Force install Symfony 3 run: composer require symfony/console ^3.0 symfony/process ^3.0 symfony/filesystem ^3.0 - - name: "Compile phar with humbug/box" - run: "tools/box compile" + - name: Compile phar with humbug/box + run: tools/box compile - - name: "Show info about generated phar with humbug/box" - run: "tools/box info ${{ env.PHAR }}" + - name: Show info about generated phar with humbug/box + run: tools/box info ${{ env.PHAR }} - - name: "Run phar" - run: "${{ env.PHAR }} --help" + - name: Run phar + run: ${{ env.PHAR }} --help - - name: "Show gpg version" - run: "gpg --version" + - name: Show gpg version + run: gpg --version - - name: "Decrypt signing key with gpg" + - name: Decrypt signing key with gpg run: "gpg --batch --output ${{ env.GPG_KEYS }} --passphrase \"${{ secrets.GPG_DECRYPT_PASSPHRASE }}\" --yes --ignore-mdc-error --decrypt ${{ env.GPG_KEYS_ENCRYPTED }}" - - name: "Import keys with gpg" + - name: Import keys with gpg run: "gpg --batch --import ${{ env.GPG_KEYS }}" - - name: "Sign phar with gpg" + - name: Sign phar with gpg run: "gpg --armor --local-user \"${{ secrets.GPG_KEY_EMAIL }}\" --output ${{ env.PHAR_SIGNATURE }} --passphrase \"${{ secrets.GPG_KEY_PASSPHRASE }}\" --pinentry-mode loopback --yes --detach-sig ${{ env.PHAR }}" - - name: "Verify signature with gpg" + - name: Verify signature with gpg run: "gpg --verify ${{ env.PHAR_SIGNATURE }} ${{ env.PHAR }}" - - name: "Remove decrypted keys" + - name: Remove decrypted keys run: "rm ${{ env.GPG_KEYS }}" - - name: "Determine tag" - id: "determine-tag" + - name: Determine tag + id: determine-tag run: "echo \"::set-output name=tag::${GITHUB_REF#refs/tags/}\"" - - name: "Fetch all" + - name: Fetch all run: git fetch --all && git fetch --tags --force - - name: "Determine previous tag" - id: "determine-prev-tag" + - name: Determine previous tag + id: determine-prev-tag run: echo "##[set-output name=tag;]$(git describe --abbrev=0 ${{ steps.determine-tag.outputs.tag }})^" - - name: "Prepare release notes" - id: "changelog" + - name: Prepare release notes + id: changelog run: | changelog=$(php build/release-notes) echo $changelog @@ -97,12 +94,12 @@ jobs: changelog="${changelog//$'\r'/'%0D'}" echo "::set-output name=changelog::$changelog" - - name: "Check release notes" + - name: Check release notes run: "echo \"${{ steps.changelog.outputs.changelog }}\"" - - name: "Create release" - id: "create-release" - uses: "actions/create-release@master" + - name: Create release + id: create-release + uses: actions/create-release@master env: GITHUB_TOKEN: "${{ secrets.GITHUB_API_TOKEN }}" with: @@ -112,34 +109,34 @@ jobs: release_name: "${{ steps.determine-tag.outputs.tag }}" body: "${{ steps.changelog.outputs.changelog }}" - - name: "Upload captainhook.phar" - uses: "actions/upload-release-asset@v1.0.1" + - name: Upload captainhook.phar + uses: actions/upload-release-asset@v1.0.1 env: GITHUB_TOKEN: "${{ secrets.GITHUB_API_TOKEN }}" with: - asset_content_type: "text/plain" - asset_name: "captainhook.phar" + asset_content_type: text/plain + asset_name: captainhook.phar asset_path: "${{ env.PHAR }}" upload_url: "${{ steps.create-release.outputs.upload_url }}" - - name: "Upload captainhook.phar.asc" - uses: "actions/upload-release-asset@v1.0.1" + - name: Upload captainhook.phar.asc + uses: actions/upload-release-asset@v1.0.1 env: GITHUB_TOKEN: "${{ secrets.GITHUB_API_TOKEN }}" with: - asset_content_type: "text/plain" - asset_name: "captainhook.phar.asc" + asset_content_type: text/plain + asset_name: captainhook.phar.asc asset_path: "${{ env.PHAR_SIGNATURE }}" upload_url: "${{ steps.create-release.outputs.upload_url }}" - - name: "Check out the phar repo" + - name: Check out the phar repo uses: actions/checkout@v2 with: repository: captainhookphp/captainhook-phar token: ${{ secrets.PAT_SF }} path: phar-repo - - name: "Tag and push the phar repo" + - name: Tag and push the phar repo run: | cd phar-repo git config user.name "Sebastian Feldmann" diff --git a/composer.json b/composer.json index e92e3946..fd903b5d 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ }, "autoload-dev": { "psr-4": { - "CaptainHook\\App\\": "tests/CaptainHook/", + "CaptainHook\\App\\": "tests/unit/", "CaptainHook\\App\\Integration\\": "tests/integration/" } }, @@ -68,8 +68,8 @@ "post-install-cmd": "tools/phive install --force-accept-unsigned", "tools": "tools/phive install --force-accept-unsigned", "compile": "tools/box compile", - "test": "tools/phpunit --testsuite CaptainHook", - "test:integration": "tools/phpunit --testsuite Integration --no-coverage", + "test": "tools/phpunit --testsuite UnitTests", + "test:integration": "tools/phpunit --testsuite IntegrationTests --no-coverage", "analyse": "tools/phpstan analyse", "style": "tools/phpcs --standard=psr12 src tests" } diff --git a/phpunit.ci.xml b/phpunit.ci.xml deleted file mode 100644 index cae88b94..00000000 --- a/phpunit.ci.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - tests/CaptainHook - - - tests/integration - - - diff --git a/phpunit.xml b/phpunit.xml index 080a1a5a..ff1f337f 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,10 +10,10 @@ - - tests/CaptainHook + + tests/unit - + tests/integration diff --git a/tests/integration/PreCommit/SuccessTest.php b/tests/integration/PreCommit/SuccessTest.php new file mode 100644 index 00000000..0cc596e7 --- /dev/null +++ b/tests/integration/PreCommit/SuccessTest.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace CaptainHook\App\Integration\PreCommit; + +use CaptainHook\App\Integration\IntegrationTestCase; + +class SuccessTest extends IntegrationTestCase +{ + public function testPreCommitSuccess(): void + { + $repoPath = $this->setUpRepository(); + + $this->enableHook($repoPath, 'pre-commit', [ + ['action' => 'echo "test action placeholder {$STAGED_FILES|of-type:html}" > html.log'] + ]); + + $this->filesystem()->touch($repoPath . '/foo.html'); + $this->mustRunInShell(['git', 'add', 'foo.html'], $repoPath); + $this->mustRunInShell(['git', 'commit', '-m', 'Test successful pre-commit execution'], $repoPath); + + $log = file_get_contents($repoPath . '/html.log'); + + $this->assertStringContainsString("foo.html", $log); + } +} diff --git a/tests/CaptainHook/Config/ActionTest.php b/tests/unit/Config/ActionTest.php similarity index 100% rename from tests/CaptainHook/Config/ActionTest.php rename to tests/unit/Config/ActionTest.php diff --git a/tests/CaptainHook/Config/ConditionTest.php b/tests/unit/Config/ConditionTest.php similarity index 100% rename from tests/CaptainHook/Config/ConditionTest.php rename to tests/unit/Config/ConditionTest.php diff --git a/tests/CaptainHook/Config/FactoryTest.php b/tests/unit/Config/FactoryTest.php similarity index 100% rename from tests/CaptainHook/Config/FactoryTest.php rename to tests/unit/Config/FactoryTest.php diff --git a/tests/CaptainHook/Config/HookTest.php b/tests/unit/Config/HookTest.php similarity index 100% rename from tests/CaptainHook/Config/HookTest.php rename to tests/unit/Config/HookTest.php diff --git a/tests/CaptainHook/Config/Mockery.php b/tests/unit/Config/Mockery.php similarity index 94% rename from tests/CaptainHook/Config/Mockery.php rename to tests/unit/Config/Mockery.php index daa26283..fc75edd7 100644 --- a/tests/CaptainHook/Config/Mockery.php +++ b/tests/unit/Config/Mockery.php @@ -12,6 +12,7 @@ namespace CaptainHook\App\Config; use CaptainHook\App\Config as CHConfig; +use PHPUnit\Framework\MockObject\MockBuilder; trait Mockery { @@ -74,5 +75,5 @@ public function createPluginConfigMock(): Plugin * @param $type * @return \PHPUnit\Framework\MockObject\MockBuilder */ - abstract public function getMockBuilder(string $type): \PHPUnit\Framework\MockObject\MockBuilder; + abstract public function getMockBuilder(string $type): MockBuilder; } diff --git a/tests/CaptainHook/Config/OptionsTest.php b/tests/unit/Config/OptionsTest.php similarity index 100% rename from tests/CaptainHook/Config/OptionsTest.php rename to tests/unit/Config/OptionsTest.php diff --git a/tests/CaptainHook/Config/PluginTest.php b/tests/unit/Config/PluginTest.php similarity index 100% rename from tests/CaptainHook/Config/PluginTest.php rename to tests/unit/Config/PluginTest.php diff --git a/tests/CaptainHook/Config/UtilTest.php b/tests/unit/Config/UtilTest.php similarity index 100% rename from tests/CaptainHook/Config/UtilTest.php rename to tests/unit/Config/UtilTest.php diff --git a/tests/CaptainHook/ConfigTest.php b/tests/unit/ConfigTest.php similarity index 100% rename from tests/CaptainHook/ConfigTest.php rename to tests/unit/ConfigTest.php diff --git a/tests/CaptainHook/Console/ApplicationTest.php b/tests/unit/Console/ApplicationTest.php similarity index 100% rename from tests/CaptainHook/Console/ApplicationTest.php rename to tests/unit/Console/ApplicationTest.php diff --git a/tests/CaptainHook/Console/Command/AddTest.php b/tests/unit/Console/Command/AddTest.php similarity index 100% rename from tests/CaptainHook/Console/Command/AddTest.php rename to tests/unit/Console/Command/AddTest.php diff --git a/tests/CaptainHook/Console/Command/ConfigurationTest.php b/tests/unit/Console/Command/ConfigurationTest.php similarity index 100% rename from tests/CaptainHook/Console/Command/ConfigurationTest.php rename to tests/unit/Console/Command/ConfigurationTest.php diff --git a/tests/CaptainHook/Console/Command/DisableTest.php b/tests/unit/Console/Command/DisableTest.php similarity index 100% rename from tests/CaptainHook/Console/Command/DisableTest.php rename to tests/unit/Console/Command/DisableTest.php diff --git a/tests/CaptainHook/Console/Command/EnableTest.php b/tests/unit/Console/Command/EnableTest.php similarity index 100% rename from tests/CaptainHook/Console/Command/EnableTest.php rename to tests/unit/Console/Command/EnableTest.php diff --git a/tests/CaptainHook/Console/Command/Hook/CommitMsgTest.php b/tests/unit/Console/Command/Hook/CommitMsgTest.php similarity index 100% rename from tests/CaptainHook/Console/Command/Hook/CommitMsgTest.php rename to tests/unit/Console/Command/Hook/CommitMsgTest.php diff --git a/tests/CaptainHook/Console/Command/Hook/PostCheckoutTest.php b/tests/unit/Console/Command/Hook/PostCheckoutTest.php similarity index 100% rename from tests/CaptainHook/Console/Command/Hook/PostCheckoutTest.php rename to tests/unit/Console/Command/Hook/PostCheckoutTest.php diff --git a/tests/CaptainHook/Console/Command/Hook/PostCommitTest.php b/tests/unit/Console/Command/Hook/PostCommitTest.php similarity index 100% rename from tests/CaptainHook/Console/Command/Hook/PostCommitTest.php rename to tests/unit/Console/Command/Hook/PostCommitTest.php diff --git a/tests/CaptainHook/Console/Command/Hook/PostMergeTest.php b/tests/unit/Console/Command/Hook/PostMergeTest.php similarity index 100% rename from tests/CaptainHook/Console/Command/Hook/PostMergeTest.php rename to tests/unit/Console/Command/Hook/PostMergeTest.php diff --git a/tests/CaptainHook/Console/Command/Hook/PreCommitTest.php b/tests/unit/Console/Command/Hook/PreCommitTest.php similarity index 100% rename from tests/CaptainHook/Console/Command/Hook/PreCommitTest.php rename to tests/unit/Console/Command/Hook/PreCommitTest.php diff --git a/tests/CaptainHook/Console/Command/Hook/PrePushTest.php b/tests/unit/Console/Command/Hook/PrePushTest.php similarity index 100% rename from tests/CaptainHook/Console/Command/Hook/PrePushTest.php rename to tests/unit/Console/Command/Hook/PrePushTest.php diff --git a/tests/CaptainHook/Console/Command/Hook/PrepareCommitMsgTest.php b/tests/unit/Console/Command/Hook/PrepareCommitMsgTest.php similarity index 100% rename from tests/CaptainHook/Console/Command/Hook/PrepareCommitMsgTest.php rename to tests/unit/Console/Command/Hook/PrepareCommitMsgTest.php diff --git a/tests/CaptainHook/Console/Command/InstallTest.php b/tests/unit/Console/Command/InstallTest.php similarity index 100% rename from tests/CaptainHook/Console/Command/InstallTest.php rename to tests/unit/Console/Command/InstallTest.php diff --git a/tests/CaptainHook/Console/IO/ComposerIOTest.php b/tests/unit/Console/IO/ComposerIOTest.php similarity index 100% rename from tests/CaptainHook/Console/IO/ComposerIOTest.php rename to tests/unit/Console/IO/ComposerIOTest.php diff --git a/tests/CaptainHook/Console/IO/DefaultIOTest.php b/tests/unit/Console/IO/DefaultIOTest.php similarity index 100% rename from tests/CaptainHook/Console/IO/DefaultIOTest.php rename to tests/unit/Console/IO/DefaultIOTest.php diff --git a/tests/CaptainHook/Console/IO/Mockery.php b/tests/unit/Console/IO/Mockery.php similarity index 86% rename from tests/CaptainHook/Console/IO/Mockery.php rename to tests/unit/Console/IO/Mockery.php index c69bee08..5b5889ce 100644 --- a/tests/CaptainHook/Console/IO/Mockery.php +++ b/tests/unit/Console/IO/Mockery.php @@ -12,6 +12,7 @@ namespace CaptainHook\App\Console\IO; use CaptainHook\App\Console\IO; +use PHPUnit\Framework\MockObject\MockBuilder; trait Mockery { @@ -31,5 +32,5 @@ public function createIOMock(): IO * @param $type * @return \PHPUnit\Framework\MockObject\MockBuilder */ - abstract public function getMockBuilder(string $type): \PHPUnit\Framework\MockObject\MockBuilder; + abstract public function getMockBuilder(string $type): MockBuilder; } diff --git a/tests/CaptainHook/Console/IO/NullIOTest.php b/tests/unit/Console/IO/NullIOTest.php similarity index 100% rename from tests/CaptainHook/Console/IO/NullIOTest.php rename to tests/unit/Console/IO/NullIOTest.php diff --git a/tests/CaptainHook/Console/IOUtilTest.php b/tests/unit/Console/IOUtilTest.php similarity index 100% rename from tests/CaptainHook/Console/IOUtilTest.php rename to tests/unit/Console/IOUtilTest.php diff --git a/tests/CaptainHook/Git/DummyRepo.php b/tests/unit/Git/DummyRepo.php similarity index 100% rename from tests/CaptainHook/Git/DummyRepo.php rename to tests/unit/Git/DummyRepo.php diff --git a/tests/CaptainHook/Hook/Branch/Action/EnsureNamingTest.php b/tests/unit/Hook/Branch/Action/EnsureNamingTest.php similarity index 100% rename from tests/CaptainHook/Hook/Branch/Action/EnsureNamingTest.php rename to tests/unit/Hook/Branch/Action/EnsureNamingTest.php diff --git a/tests/CaptainHook/Hook/Composer/Action/CheckLockFileTest.php b/tests/unit/Hook/Composer/Action/CheckLockFileTest.php similarity index 100% rename from tests/CaptainHook/Hook/Composer/Action/CheckLockFileTest.php rename to tests/unit/Hook/Composer/Action/CheckLockFileTest.php diff --git a/tests/CaptainHook/Hook/Condition/FileChanged/AllTest.php b/tests/unit/Hook/Condition/FileChanged/AllTest.php similarity index 100% rename from tests/CaptainHook/Hook/Condition/FileChanged/AllTest.php rename to tests/unit/Hook/Condition/FileChanged/AllTest.php diff --git a/tests/CaptainHook/Hook/Condition/FileChanged/AnyTest.php b/tests/unit/Hook/Condition/FileChanged/AnyTest.php similarity index 100% rename from tests/CaptainHook/Hook/Condition/FileChanged/AnyTest.php rename to tests/unit/Hook/Condition/FileChanged/AnyTest.php diff --git a/tests/CaptainHook/Hook/Condition/FileStaged/AllTest.php b/tests/unit/Hook/Condition/FileStaged/AllTest.php similarity index 100% rename from tests/CaptainHook/Hook/Condition/FileStaged/AllTest.php rename to tests/unit/Hook/Condition/FileStaged/AllTest.php diff --git a/tests/CaptainHook/Hook/Condition/FileStaged/AnyTest.php b/tests/unit/Hook/Condition/FileStaged/AnyTest.php similarity index 100% rename from tests/CaptainHook/Hook/Condition/FileStaged/AnyTest.php rename to tests/unit/Hook/Condition/FileStaged/AnyTest.php diff --git a/tests/CaptainHook/Hook/Condition/FileStaged/InDirectoryTest.php b/tests/unit/Hook/Condition/FileStaged/InDirectoryTest.php similarity index 100% rename from tests/CaptainHook/Hook/Condition/FileStaged/InDirectoryTest.php rename to tests/unit/Hook/Condition/FileStaged/InDirectoryTest.php diff --git a/tests/CaptainHook/Hook/Condition/FileStaged/OfTypeTest.php b/tests/unit/Hook/Condition/FileStaged/OfTypeTest.php similarity index 100% rename from tests/CaptainHook/Hook/Condition/FileStaged/OfTypeTest.php rename to tests/unit/Hook/Condition/FileStaged/OfTypeTest.php diff --git a/tests/CaptainHook/Hook/Condition/Logic/LogicAndTest.php b/tests/unit/Hook/Condition/Logic/LogicAndTest.php similarity index 100% rename from tests/CaptainHook/Hook/Condition/Logic/LogicAndTest.php rename to tests/unit/Hook/Condition/Logic/LogicAndTest.php diff --git a/tests/CaptainHook/Hook/Condition/Logic/LogicOrTest.php b/tests/unit/Hook/Condition/Logic/LogicOrTest.php similarity index 100% rename from tests/CaptainHook/Hook/Condition/Logic/LogicOrTest.php rename to tests/unit/Hook/Condition/Logic/LogicOrTest.php diff --git a/tests/CaptainHook/Hook/Condition/OnBranchTest.php b/tests/unit/Hook/Condition/OnBranchTest.php similarity index 100% rename from tests/CaptainHook/Hook/Condition/OnBranchTest.php rename to tests/unit/Hook/Condition/OnBranchTest.php diff --git a/tests/CaptainHook/Hook/DebugTest.php b/tests/unit/Hook/DebugTest.php similarity index 100% rename from tests/CaptainHook/Hook/DebugTest.php rename to tests/unit/Hook/DebugTest.php diff --git a/tests/CaptainHook/Hook/File/Action/DoesNotContainRegexTest.php b/tests/unit/Hook/File/Action/DoesNotContainRegexTest.php similarity index 100% rename from tests/CaptainHook/Hook/File/Action/DoesNotContainRegexTest.php rename to tests/unit/Hook/File/Action/DoesNotContainRegexTest.php diff --git a/tests/CaptainHook/Hook/File/Action/ExistsTest.php b/tests/unit/Hook/File/Action/ExistsTest.php similarity index 100% rename from tests/CaptainHook/Hook/File/Action/ExistsTest.php rename to tests/unit/Hook/File/Action/ExistsTest.php diff --git a/tests/CaptainHook/Hook/File/Action/IsEmptyTest.php b/tests/unit/Hook/File/Action/IsEmptyTest.php similarity index 100% rename from tests/CaptainHook/Hook/File/Action/IsEmptyTest.php rename to tests/unit/Hook/File/Action/IsEmptyTest.php diff --git a/tests/CaptainHook/Hook/File/Action/IsNotEmptyTest.php b/tests/unit/Hook/File/Action/IsNotEmptyTest.php similarity index 98% rename from tests/CaptainHook/Hook/File/Action/IsNotEmptyTest.php rename to tests/unit/Hook/File/Action/IsNotEmptyTest.php index 0d6de2aa..02f84d25 100644 --- a/tests/CaptainHook/Hook/File/Action/IsNotEmptyTest.php +++ b/tests/unit/Hook/File/Action/IsNotEmptyTest.php @@ -15,6 +15,7 @@ use CaptainHook\App\Console\IO\NullIO; use CaptainHook\App\Mockery as GitMockery; use CaptainHook\App\Console\IO\Mockery as IOMockery; +use Exception; use PHPUnit\Framework\TestCase; class IsNotEmptyTest extends TestCase @@ -111,7 +112,7 @@ public function testConfigWithGlobs(): void */ public function testFailCommitEmptyFile(): void { - $this->expectException(\Exception::class); + $this->expectException(Exception::class); $io = new NullIO(); diff --git a/tests/CaptainHook/Hook/File/Action/MaxSizeTest.php b/tests/unit/Hook/File/Action/MaxSizeTest.php similarity index 100% rename from tests/CaptainHook/Hook/File/Action/MaxSizeTest.php rename to tests/unit/Hook/File/Action/MaxSizeTest.php diff --git a/tests/CaptainHook/Hook/Message/Action/BeamsTest.php b/tests/unit/Hook/Message/Action/BeamsTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Action/BeamsTest.php rename to tests/unit/Hook/Message/Action/BeamsTest.php diff --git a/tests/CaptainHook/Hook/Message/Action/NoRule.php b/tests/unit/Hook/Message/Action/NoRule.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Action/NoRule.php rename to tests/unit/Hook/Message/Action/NoRule.php diff --git a/tests/CaptainHook/Hook/Message/Action/PrepareTest.php b/tests/unit/Hook/Message/Action/PrepareTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Action/PrepareTest.php rename to tests/unit/Hook/Message/Action/PrepareTest.php diff --git a/tests/CaptainHook/Hook/Message/Action/RegexTest.php b/tests/unit/Hook/Message/Action/RegexTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Action/RegexTest.php rename to tests/unit/Hook/Message/Action/RegexTest.php diff --git a/tests/CaptainHook/Hook/Message/Action/RulesTest.php b/tests/unit/Hook/Message/Action/RulesTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Action/RulesTest.php rename to tests/unit/Hook/Message/Action/RulesTest.php diff --git a/tests/CaptainHook/Hook/Message/Rule/BlacklistTest.php b/tests/unit/Hook/Message/Rule/BlacklistTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Rule/BlacklistTest.php rename to tests/unit/Hook/Message/Rule/BlacklistTest.php diff --git a/tests/CaptainHook/Hook/Message/Rule/CapitalizeSubjectTest.php b/tests/unit/Hook/Message/Rule/CapitalizeSubjectTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Rule/CapitalizeSubjectTest.php rename to tests/unit/Hook/Message/Rule/CapitalizeSubjectTest.php diff --git a/tests/CaptainHook/Hook/Message/Rule/LimitBodyLineLengthTest.php b/tests/unit/Hook/Message/Rule/LimitBodyLineLengthTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Rule/LimitBodyLineLengthTest.php rename to tests/unit/Hook/Message/Rule/LimitBodyLineLengthTest.php diff --git a/tests/CaptainHook/Hook/Message/Rule/LimitSubjectLengthTest.php b/tests/unit/Hook/Message/Rule/LimitSubjectLengthTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Rule/LimitSubjectLengthTest.php rename to tests/unit/Hook/Message/Rule/LimitSubjectLengthTest.php diff --git a/tests/CaptainHook/Hook/Message/Rule/MsgNotEmptyTest.php b/tests/unit/Hook/Message/Rule/MsgNotEmptyTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Rule/MsgNotEmptyTest.php rename to tests/unit/Hook/Message/Rule/MsgNotEmptyTest.php diff --git a/tests/CaptainHook/Hook/Message/Rule/NoPeriodOnSubjectEndTest.php b/tests/unit/Hook/Message/Rule/NoPeriodOnSubjectEndTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Rule/NoPeriodOnSubjectEndTest.php rename to tests/unit/Hook/Message/Rule/NoPeriodOnSubjectEndTest.php diff --git a/tests/CaptainHook/Hook/Message/Rule/SeparateSubjectFromBodyWithBlankLineTest.php b/tests/unit/Hook/Message/Rule/SeparateSubjectFromBodyWithBlankLineTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Rule/SeparateSubjectFromBodyWithBlankLineTest.php rename to tests/unit/Hook/Message/Rule/SeparateSubjectFromBodyWithBlankLineTest.php diff --git a/tests/CaptainHook/Hook/Message/Rule/UseImperativeMoodTest.php b/tests/unit/Hook/Message/Rule/UseImperativeMoodTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/Rule/UseImperativeMoodTest.php rename to tests/unit/Hook/Message/Rule/UseImperativeMoodTest.php diff --git a/tests/CaptainHook/Hook/Message/RuleBook/RuleSetTest.php b/tests/unit/Hook/Message/RuleBook/RuleSetTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/RuleBook/RuleSetTest.php rename to tests/unit/Hook/Message/RuleBook/RuleSetTest.php diff --git a/tests/CaptainHook/Hook/Message/RuleBookTest.php b/tests/unit/Hook/Message/RuleBookTest.php similarity index 100% rename from tests/CaptainHook/Hook/Message/RuleBookTest.php rename to tests/unit/Hook/Message/RuleBookTest.php diff --git a/tests/CaptainHook/Hook/Mockery.php b/tests/unit/Hook/Mockery.php similarity index 86% rename from tests/CaptainHook/Hook/Mockery.php rename to tests/unit/Hook/Mockery.php index 8d7a8454..bb1634bd 100644 --- a/tests/CaptainHook/Hook/Mockery.php +++ b/tests/unit/Hook/Mockery.php @@ -11,6 +11,8 @@ namespace CaptainHook\App\Hook; +use PHPUnit\Framework\MockObject\MockBuilder; + trait Mockery { /** @@ -29,5 +31,5 @@ public function createTemplateMock(): Template * @param $type * @return \PHPUnit\Framework\MockObject\MockBuilder */ - abstract public function getMockBuilder(string $type): \PHPUnit\Framework\MockObject\MockBuilder; + abstract public function getMockBuilder(string $type): MockBuilder; } diff --git a/tests/CaptainHook/Hook/Notify/Action/NotifyTest.php b/tests/unit/Hook/Notify/Action/NotifyTest.php similarity index 100% rename from tests/CaptainHook/Hook/Notify/Action/NotifyTest.php rename to tests/unit/Hook/Notify/Action/NotifyTest.php diff --git a/tests/CaptainHook/Hook/Notify/ExtractorTest.php b/tests/unit/Hook/Notify/ExtractorTest.php similarity index 100% rename from tests/CaptainHook/Hook/Notify/ExtractorTest.php rename to tests/unit/Hook/Notify/ExtractorTest.php diff --git a/tests/CaptainHook/Hook/Notify/NotificationTest.php b/tests/unit/Hook/Notify/NotificationTest.php similarity index 100% rename from tests/CaptainHook/Hook/Notify/NotificationTest.php rename to tests/unit/Hook/Notify/NotificationTest.php diff --git a/tests/CaptainHook/Hook/PHP/Action/LintingTest.php b/tests/unit/Hook/PHP/Action/LintingTest.php similarity index 100% rename from tests/CaptainHook/Hook/PHP/Action/LintingTest.php rename to tests/unit/Hook/PHP/Action/LintingTest.php diff --git a/tests/CaptainHook/Hook/PHP/Action/TestCoverageTest.php b/tests/unit/Hook/PHP/Action/TestCoverageTest.php similarity index 95% rename from tests/CaptainHook/Hook/PHP/Action/TestCoverageTest.php rename to tests/unit/Hook/PHP/Action/TestCoverageTest.php index 24ffa98a..0f55cb1a 100644 --- a/tests/CaptainHook/Hook/PHP/Action/TestCoverageTest.php +++ b/tests/unit/Hook/PHP/Action/TestCoverageTest.php @@ -28,7 +28,7 @@ class TestCoverageTest extends TestCase */ public function testCoverageViaCloverXML(): void { - if (\defined('PHP_WINDOWS_VERSION_MAJOR')) { + if (defined('PHP_WINDOWS_VERSION_MAJOR')) { $this->markTestSkipped('not tested on windows'); } @@ -75,7 +75,7 @@ public function testCoverageLow(): void */ public function testCoverageViaPHPUnit(): void { - if (\defined('PHP_WINDOWS_VERSION_MAJOR')) { + if (defined('PHP_WINDOWS_VERSION_MAJOR')) { $this->markTestSkipped('not tested on windows'); } diff --git a/tests/CaptainHook/Hook/PHP/CoverageResolver/CloverXmlTest.php b/tests/unit/Hook/PHP/CoverageResolver/CloverXmlTest.php similarity index 100% rename from tests/CaptainHook/Hook/PHP/CoverageResolver/CloverXmlTest.php rename to tests/unit/Hook/PHP/CoverageResolver/CloverXmlTest.php diff --git a/tests/CaptainHook/Hook/PHP/CoverageResolver/PHPUnitTest.php b/tests/unit/Hook/PHP/CoverageResolver/PHPUnitTest.php similarity index 94% rename from tests/CaptainHook/Hook/PHP/CoverageResolver/PHPUnitTest.php rename to tests/unit/Hook/PHP/CoverageResolver/PHPUnitTest.php index 987c8880..9969b2ae 100644 --- a/tests/CaptainHook/Hook/PHP/CoverageResolver/PHPUnitTest.php +++ b/tests/unit/Hook/PHP/CoverageResolver/PHPUnitTest.php @@ -21,7 +21,7 @@ class PHPUnitTest extends TestCase */ public function testValid(): void { - if (\defined('PHP_WINDOWS_VERSION_MAJOR')) { + if (defined('PHP_WINDOWS_VERSION_MAJOR')) { $this->markTestSkipped('not tested on windows'); } diff --git a/tests/CaptainHook/Hook/RestrictionTest.php b/tests/unit/Hook/RestrictionTest.php similarity index 100% rename from tests/CaptainHook/Hook/RestrictionTest.php rename to tests/unit/Hook/RestrictionTest.php diff --git a/tests/CaptainHook/Hook/Template/BuilderTest.php b/tests/unit/Hook/Template/BuilderTest.php similarity index 100% rename from tests/CaptainHook/Hook/Template/BuilderTest.php rename to tests/unit/Hook/Template/BuilderTest.php diff --git a/tests/CaptainHook/Hook/Template/DockerTest.php b/tests/unit/Hook/Template/DockerTest.php similarity index 100% rename from tests/CaptainHook/Hook/Template/DockerTest.php rename to tests/unit/Hook/Template/DockerTest.php diff --git a/tests/CaptainHook/Hook/Template/Local/PHPTest.php b/tests/unit/Hook/Template/Local/PHPTest.php similarity index 100% rename from tests/CaptainHook/Hook/Template/Local/PHPTest.php rename to tests/unit/Hook/Template/Local/PHPTest.php diff --git a/tests/CaptainHook/Hook/Template/Local/ShellTest.php b/tests/unit/Hook/Template/Local/ShellTest.php similarity index 100% rename from tests/CaptainHook/Hook/Template/Local/ShellTest.php rename to tests/unit/Hook/Template/Local/ShellTest.php diff --git a/tests/CaptainHook/Hook/UtilTest.php b/tests/unit/Hook/UtilTest.php similarity index 100% rename from tests/CaptainHook/Hook/UtilTest.php rename to tests/unit/Hook/UtilTest.php diff --git a/tests/CaptainHook/HooksTest.php b/tests/unit/HooksTest.php similarity index 100% rename from tests/CaptainHook/HooksTest.php rename to tests/unit/HooksTest.php diff --git a/tests/CaptainHook/Mockery.php b/tests/unit/Mockery.php similarity index 100% rename from tests/CaptainHook/Mockery.php rename to tests/unit/Mockery.php diff --git a/tests/CaptainHook/Plugin/DummyConstrainedHookPlugin.php b/tests/unit/Plugin/DummyConstrainedHookPlugin.php similarity index 100% rename from tests/CaptainHook/Plugin/DummyConstrainedHookPlugin.php rename to tests/unit/Plugin/DummyConstrainedHookPlugin.php diff --git a/tests/CaptainHook/Plugin/DummyConstrainedHookPluginAlt.php b/tests/unit/Plugin/DummyConstrainedHookPluginAlt.php similarity index 100% rename from tests/CaptainHook/Plugin/DummyConstrainedHookPluginAlt.php rename to tests/unit/Plugin/DummyConstrainedHookPluginAlt.php diff --git a/tests/CaptainHook/Plugin/DummyConstrainedPlugin.php b/tests/unit/Plugin/DummyConstrainedPlugin.php similarity index 100% rename from tests/CaptainHook/Plugin/DummyConstrainedPlugin.php rename to tests/unit/Plugin/DummyConstrainedPlugin.php diff --git a/tests/CaptainHook/Plugin/DummyHookPlugin.php b/tests/unit/Plugin/DummyHookPlugin.php similarity index 100% rename from tests/CaptainHook/Plugin/DummyHookPlugin.php rename to tests/unit/Plugin/DummyHookPlugin.php diff --git a/tests/CaptainHook/Plugin/DummyHookPluginSkipsActions.php b/tests/unit/Plugin/DummyHookPluginSkipsActions.php similarity index 100% rename from tests/CaptainHook/Plugin/DummyHookPluginSkipsActions.php rename to tests/unit/Plugin/DummyHookPluginSkipsActions.php diff --git a/tests/CaptainHook/Plugin/DummyPlugin.php b/tests/unit/Plugin/DummyPlugin.php similarity index 100% rename from tests/CaptainHook/Plugin/DummyPlugin.php rename to tests/unit/Plugin/DummyPlugin.php diff --git a/tests/CaptainHook/Plugin/Hook/PreserveWorkingTreeTest.php b/tests/unit/Plugin/Hook/PreserveWorkingTreeTest.php similarity index 100% rename from tests/CaptainHook/Plugin/Hook/PreserveWorkingTreeTest.php rename to tests/unit/Plugin/Hook/PreserveWorkingTreeTest.php diff --git a/tests/CaptainHook/Runner/Action/Cli/Command/FormatterTest.php b/tests/unit/Runner/Action/Cli/Command/FormatterTest.php similarity index 100% rename from tests/CaptainHook/Runner/Action/Cli/Command/FormatterTest.php rename to tests/unit/Runner/Action/Cli/Command/FormatterTest.php diff --git a/tests/CaptainHook/Runner/Action/Cli/Command/Placeholder/ConfigTest.php b/tests/unit/Runner/Action/Cli/Command/Placeholder/ConfigTest.php similarity index 100% rename from tests/CaptainHook/Runner/Action/Cli/Command/Placeholder/ConfigTest.php rename to tests/unit/Runner/Action/Cli/Command/Placeholder/ConfigTest.php diff --git a/tests/CaptainHook/Runner/Action/Cli/Command/Placeholder/EnvTest.php b/tests/unit/Runner/Action/Cli/Command/Placeholder/EnvTest.php similarity index 100% rename from tests/CaptainHook/Runner/Action/Cli/Command/Placeholder/EnvTest.php rename to tests/unit/Runner/Action/Cli/Command/Placeholder/EnvTest.php diff --git a/tests/CaptainHook/Runner/Action/Cli/Command/Placeholder/StagedFilesTest.php b/tests/unit/Runner/Action/Cli/Command/Placeholder/StagedFilesTest.php similarity index 100% rename from tests/CaptainHook/Runner/Action/Cli/Command/Placeholder/StagedFilesTest.php rename to tests/unit/Runner/Action/Cli/Command/Placeholder/StagedFilesTest.php diff --git a/tests/CaptainHook/Runner/Action/CliTest.php b/tests/unit/Runner/Action/CliTest.php similarity index 100% rename from tests/CaptainHook/Runner/Action/CliTest.php rename to tests/unit/Runner/Action/CliTest.php diff --git a/tests/CaptainHook/Runner/Action/DummyNoAction.php b/tests/unit/Runner/Action/DummyNoAction.php similarity index 100% rename from tests/CaptainHook/Runner/Action/DummyNoAction.php rename to tests/unit/Runner/Action/DummyNoAction.php diff --git a/tests/CaptainHook/Runner/Action/DummyPHPConstraint.php b/tests/unit/Runner/Action/DummyPHPConstraint.php similarity index 100% rename from tests/CaptainHook/Runner/Action/DummyPHPConstraint.php rename to tests/unit/Runner/Action/DummyPHPConstraint.php diff --git a/tests/CaptainHook/Runner/Action/DummyPHPError.php b/tests/unit/Runner/Action/DummyPHPError.php similarity index 100% rename from tests/CaptainHook/Runner/Action/DummyPHPError.php rename to tests/unit/Runner/Action/DummyPHPError.php diff --git a/tests/CaptainHook/Runner/Action/DummyPHPFailure.php b/tests/unit/Runner/Action/DummyPHPFailure.php similarity index 100% rename from tests/CaptainHook/Runner/Action/DummyPHPFailure.php rename to tests/unit/Runner/Action/DummyPHPFailure.php diff --git a/tests/CaptainHook/Runner/Action/DummyPHPSuccess.php b/tests/unit/Runner/Action/DummyPHPSuccess.php similarity index 100% rename from tests/CaptainHook/Runner/Action/DummyPHPSuccess.php rename to tests/unit/Runner/Action/DummyPHPSuccess.php diff --git a/tests/CaptainHook/Runner/Action/PHPTest.php b/tests/unit/Runner/Action/PHPTest.php similarity index 100% rename from tests/CaptainHook/Runner/Action/PHPTest.php rename to tests/unit/Runner/Action/PHPTest.php diff --git a/tests/CaptainHook/Runner/ConditionTest.php b/tests/unit/Runner/ConditionTest.php similarity index 100% rename from tests/CaptainHook/Runner/ConditionTest.php rename to tests/unit/Runner/ConditionTest.php diff --git a/tests/CaptainHook/Runner/Config/CreatorTest.php b/tests/unit/Runner/Config/CreatorTest.php similarity index 100% rename from tests/CaptainHook/Runner/Config/CreatorTest.php rename to tests/unit/Runner/Config/CreatorTest.php diff --git a/tests/CaptainHook/Runner/Config/EditorTest.php b/tests/unit/Runner/Config/EditorTest.php similarity index 100% rename from tests/CaptainHook/Runner/Config/EditorTest.php rename to tests/unit/Runner/Config/EditorTest.php diff --git a/tests/CaptainHook/Runner/Config/Setup/AdvancedTest.php b/tests/unit/Runner/Config/Setup/AdvancedTest.php similarity index 100% rename from tests/CaptainHook/Runner/Config/Setup/AdvancedTest.php rename to tests/unit/Runner/Config/Setup/AdvancedTest.php diff --git a/tests/CaptainHook/Runner/Config/Setup/ExpressTest.php b/tests/unit/Runner/Config/Setup/ExpressTest.php similarity index 100% rename from tests/CaptainHook/Runner/Config/Setup/ExpressTest.php rename to tests/unit/Runner/Config/Setup/ExpressTest.php diff --git a/tests/CaptainHook/Runner/Config/Setup/GuidedTest.php b/tests/unit/Runner/Config/Setup/GuidedTest.php similarity index 100% rename from tests/CaptainHook/Runner/Config/Setup/GuidedTest.php rename to tests/unit/Runner/Config/Setup/GuidedTest.php diff --git a/tests/CaptainHook/Runner/Hook/CommitMsgTest.php b/tests/unit/Runner/Hook/CommitMsgTest.php similarity index 100% rename from tests/CaptainHook/Runner/Hook/CommitMsgTest.php rename to tests/unit/Runner/Hook/CommitMsgTest.php diff --git a/tests/CaptainHook/Runner/Hook/PostCheckoutTest.php b/tests/unit/Runner/Hook/PostCheckoutTest.php similarity index 100% rename from tests/CaptainHook/Runner/Hook/PostCheckoutTest.php rename to tests/unit/Runner/Hook/PostCheckoutTest.php diff --git a/tests/CaptainHook/Runner/Hook/PostCommitTest.php b/tests/unit/Runner/Hook/PostCommitTest.php similarity index 100% rename from tests/CaptainHook/Runner/Hook/PostCommitTest.php rename to tests/unit/Runner/Hook/PostCommitTest.php diff --git a/tests/CaptainHook/Runner/Hook/PostMergeTest.php b/tests/unit/Runner/Hook/PostMergeTest.php similarity index 100% rename from tests/CaptainHook/Runner/Hook/PostMergeTest.php rename to tests/unit/Runner/Hook/PostMergeTest.php diff --git a/tests/CaptainHook/Runner/Hook/PostRewriteTest.php b/tests/unit/Runner/Hook/PostRewriteTest.php similarity index 100% rename from tests/CaptainHook/Runner/Hook/PostRewriteTest.php rename to tests/unit/Runner/Hook/PostRewriteTest.php diff --git a/tests/CaptainHook/Runner/Hook/PreCommitTest.php b/tests/unit/Runner/Hook/PreCommitTest.php similarity index 100% rename from tests/CaptainHook/Runner/Hook/PreCommitTest.php rename to tests/unit/Runner/Hook/PreCommitTest.php diff --git a/tests/CaptainHook/Runner/Hook/PrePushTest.php b/tests/unit/Runner/Hook/PrePushTest.php similarity index 100% rename from tests/CaptainHook/Runner/Hook/PrePushTest.php rename to tests/unit/Runner/Hook/PrePushTest.php diff --git a/tests/CaptainHook/Runner/Hook/PrepareCommitMsgTest.php b/tests/unit/Runner/Hook/PrepareCommitMsgTest.php similarity index 100% rename from tests/CaptainHook/Runner/Hook/PrepareCommitMsgTest.php rename to tests/unit/Runner/Hook/PrepareCommitMsgTest.php diff --git a/tests/CaptainHook/Runner/HookTest.php b/tests/unit/Runner/HookTest.php similarity index 100% rename from tests/CaptainHook/Runner/HookTest.php rename to tests/unit/Runner/HookTest.php diff --git a/tests/CaptainHook/Runner/InstallerTest.php b/tests/unit/Runner/InstallerTest.php similarity index 98% rename from tests/CaptainHook/Runner/InstallerTest.php rename to tests/unit/Runner/InstallerTest.php index 65c1d9b7..7ceaed67 100644 --- a/tests/CaptainHook/Runner/InstallerTest.php +++ b/tests/unit/Runner/InstallerTest.php @@ -19,6 +19,7 @@ use CaptainHook\App\Mockery as CHMockery; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; +use RuntimeException; use SebastianFeldmann\Git\Repository; class InstallerTest extends TestCase @@ -53,7 +54,7 @@ public function testSetInvalidHook(): void */ public function testMoveAfterSkippingFail(): void { - $this->expectException(\RuntimeException::class); + $this->expectException(RuntimeException::class); $io = $this->createIOMock(); $config = $this->createConfigMock(); @@ -73,7 +74,7 @@ public function testMoveAfterSkippingFail(): void */ public function testSkipAfterMovingFail(): void { - $this->expectException(\RuntimeException::class); + $this->expectException(RuntimeException::class); $io = $this->createIOMock(); $config = $this->createConfigMock(); @@ -212,7 +213,7 @@ public function testMoveNotExistingHook(): void */ public function testMoveExistingHookTargetIsFile(): void { - $this->expectException(\RuntimeException::class); + $this->expectException(RuntimeException::class); $fakeRepo = new DummyRepo( // git repo diff --git a/tests/CaptainHook/Runner/UtilTest.php b/tests/unit/Runner/UtilTest.php similarity index 100% rename from tests/CaptainHook/Runner/UtilTest.php rename to tests/unit/Runner/UtilTest.php diff --git a/tests/CaptainHook/Storage/File/JsonTest.php b/tests/unit/Storage/File/JsonTest.php similarity index 100% rename from tests/CaptainHook/Storage/File/JsonTest.php rename to tests/unit/Storage/File/JsonTest.php diff --git a/tests/CaptainHook/Storage/File/XmlTest.php b/tests/unit/Storage/File/XmlTest.php similarity index 100% rename from tests/CaptainHook/Storage/File/XmlTest.php rename to tests/unit/Storage/File/XmlTest.php diff --git a/tests/CaptainHook/Storage/FileTest.php b/tests/unit/Storage/FileTest.php similarity index 100% rename from tests/CaptainHook/Storage/FileTest.php rename to tests/unit/Storage/FileTest.php