-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tooling for integration tests with initial tests
- Loading branch information
Showing
16 changed files
with
552 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
*/ | ||
|
||
define('CH_PATH_FILES', realpath(__DIR__ . '/files')); | ||
define('CH_PATH_ROOT', realpath(__DIR__ . '/..')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/composer.lock | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# CaptainHook Acceptance Testing | ||
|
||
This is a sample project directory to use with acceptance tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"config": {}, | ||
"commit-msg": { | ||
"enabled": false, | ||
"actions": [] | ||
}, | ||
"pre-push": { | ||
"enabled": false, | ||
"actions": [] | ||
}, | ||
"pre-commit": { | ||
"enabled": false, | ||
"actions": [] | ||
}, | ||
"prepare-commit-msg": { | ||
"enabled": false, | ||
"actions": [] | ||
}, | ||
"post-commit": { | ||
"enabled": false, | ||
"actions": [] | ||
}, | ||
"post-merge": { | ||
"enabled": false, | ||
"actions": [] | ||
}, | ||
"post-checkout": { | ||
"enabled": false, | ||
"actions": [] | ||
}, | ||
"post-rewrite": { | ||
"enabled": false, | ||
"actions": [] | ||
}, | ||
"post-change": { | ||
"enabled": false, | ||
"actions": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "captainhook/repo-test", | ||
"description": "A sample project to use with CaptainHook acceptance tests.", | ||
"type": "project", | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"require-dev": { | ||
"captainhook/captainhook": "*" | ||
}, | ||
"scripts": { | ||
"post-autoload-dump": "captainhook install --no-interaction --no-ansi --force" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace CaptainHook\App\Integration; | ||
|
||
class HookInstallTest extends IntegrationTestCase | ||
{ | ||
public function testGitHooksSuccessfullyInstallWithComposerUpdate(): void | ||
{ | ||
$repoPath = $this->setUpRepository(false); | ||
|
||
$result = $this->runInShell(['composer', 'update', '--no-ansi', '--no-interaction'], $repoPath); | ||
|
||
$this->assertStringContainsString("'commit-msg' hook installed successfully", $result->getStdout()); | ||
$this->assertStringContainsString("'pre-push' hook installed successfully", $result->getStdout()); | ||
$this->assertStringContainsString("'pre-commit' hook installed successfully", $result->getStdout()); | ||
$this->assertStringContainsString("'prepare-commit-msg' hook installed successfully", $result->getStdout()); | ||
$this->assertStringContainsString("'post-commit' hook installed successfully", $result->getStdout()); | ||
$this->assertStringContainsString("'post-merge' hook installed successfully", $result->getStdout()); | ||
$this->assertStringContainsString("'post-checkout' hook installed successfully", $result->getStdout()); | ||
$this->assertStringContainsString("'post-rewrite' hook installed successfully", $result->getStdout()); | ||
$this->assertStringContainsString("'post-change' hook installed successfully", $result->getStdout()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace CaptainHook\App\Integration; | ||
|
||
class HookPluginTest extends IntegrationTestCase | ||
{ | ||
public function testHookPluginRunsBeforeAndAfterHookAndActions(): void | ||
{ | ||
$repoPath = $this->setUpRepository(); | ||
|
||
$this->setConfig($repoPath, 'plugins', [ | ||
[ | ||
'plugin' => '\\CaptainHook\\App\\Integration\\Plugin\\SimplePlugin', | ||
'options' => [ | ||
'stuff' => 'cool things', | ||
], | ||
], | ||
]); | ||
|
||
$this->enableHook($repoPath, 'pre-commit', [ | ||
[ | ||
'action' => 'echo "action1"', | ||
], | ||
[ | ||
'action' => 'echo "action2"', | ||
], | ||
]); | ||
|
||
$this->enableHook($repoPath, 'post-commit'); | ||
|
||
$this->filesystem()->touch($repoPath . '/foo.txt'); | ||
$this->mustRunInShell(['git', 'add', 'foo.txt'], $repoPath); | ||
|
||
$result = $this->runInShell(['git', 'commit', '-m', 'Add foo.txt'], $repoPath); | ||
|
||
$this->assertStringContainsString('Do cool things before pre-commit runs', $result->getStderr()); | ||
$this->assertStringContainsString('Do cool things before action echo "action1" runs', $result->getStderr()); | ||
$this->assertStringContainsString('Do cool things after action echo "action1" runs', $result->getStderr()); | ||
$this->assertStringContainsString('Do cool things before action echo "action2" runs', $result->getStderr()); | ||
$this->assertStringContainsString('Do cool things after action echo "action2" runs', $result->getStderr()); | ||
$this->assertStringContainsString('Do cool things after pre-commit runs', $result->getStderr()); | ||
|
||
$this->assertStringContainsString('Do cool things before post-commit runs', $result->getStderr()); | ||
$this->assertStringContainsString('Do cool things after post-commit runs', $result->getStderr()); | ||
|
||
$this->assertStringNotContainsString('commit-msg', $result->getStderr()); | ||
$this->assertStringNotContainsString('prepare-commit-msg', $result->getStderr()); | ||
} | ||
} |
Oops, something went wrong.