Skip to content

Commit

Permalink
Tests use a realistic Git endpoint in mocks
Browse files Browse the repository at this point in the history
This commit replaces our old Git endpoints which
are no longer in use with current ones in tests
and mocks.

This isn't really necessary, but if we search for old
endpoints in GitHub it's useful to avoid seeing
false-positives that we need to check manually.
  • Loading branch information
snim2 committed Oct 25, 2024
1 parent b5fcf6b commit d8ab5c8
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 49 deletions.
14 changes: 7 additions & 7 deletions spec/dependencies/validator.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
it('returns an error', function () {
$whippetContents = '{
"src": {
"plugins": "git@git.govpress.com:wordpress-plugins/"
"plugins": "git@github.com:dxw-wordpress-plugins/"
},
"plugins": [
{"name": "akismet"},
Expand All @@ -77,7 +77,7 @@
it('returns an error', function () {
$whippetContents = '{
"src": {
"plugins": "git@git.govpress.com:wordpress-plugins/"
"plugins": "git@github.com:dxw-wordpress-plugins/"
},
"plugins": [
{"name": "akismet"},
Expand Down Expand Up @@ -110,7 +110,7 @@
it('returns an error', function () {
$whippetContents = '{
"src": {
"plugins": "git@git.govpress.com:wordpress-plugins/"
"plugins": "git@github.com:dxw-wordpress-plugins/"
},
"plugins": [
{"name": "akismet"},
Expand Down Expand Up @@ -146,7 +146,7 @@
it('returns an error', function () {
$whippetContents = '{
"src": {
"plugins": "git@git.govpress.com:wordpress-plugins/"
"plugins": "git@github.com:dxw-wordpress-plugins/"
},
"plugins": [
{"name": "akismet"},
Expand Down Expand Up @@ -185,7 +185,7 @@
it('returns an error', function () {
$whippetContents = '{
"src": {
"plugins": "git@git.govpress.com:wordpress-plugins/"
"plugins": "git@github.com:dxw-wordpress-plugins/"
},
"plugins": [
{"name": "akismet", "ref": "v1"},
Expand Down Expand Up @@ -229,7 +229,7 @@
it('returns an ok result', function () {
$whippetContents = '{
"src": {
"plugins": "git@git.govpress.com:wordpress-plugins/"
"plugins": "git@github.com:dxw-wordpress-plugins/"
},
"plugins": [
{"name": "akismet", "ref": "v1"},
Expand Down Expand Up @@ -273,7 +273,7 @@
it('returns an ok result', function () {
$whippetContents = '{
"src": {
"plugins": "git@git.govpress.com:wordpress-plugins/"
"plugins": "git@github.com:dxw-wordpress-plugins/"
},
"plugins": [
{"name": "akismet"},
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/Helpers/ManifestIo.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function load_plugins_manifest()

if ($plugin == 'source') {
if (empty($data)) {
echo "Source is empty. It should just specify a repo root:\n\n source = 'git@git.govpress.com:wordpress-plugins/'\n\nWhippet will attempt to find a source for your plugins by appending the plugin name to this URL.";
echo "Source is empty. It should just specify a repo root:\n\n source = 'git@github.com:dxw-wordpress-plugins/'\n\nWhippet will attempt to find a source for your plugins by appending the plugin name to this URL.";
exit(1);
}

Expand Down
28 changes: 14 additions & 14 deletions tests/dependencies/installer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public function testInstallAll()

$my_plugin = [
'name' => 'my-plugin',
'src' => 'git@git.govpress.com:wordpress-plugins/my-plugin',
'src' => 'git@github.com:dxw-wordpress-plugins/my-plugin',
'revision' => '123456',
];

$another_plugin = [
'name' => 'another-plugin',
'src' => 'git@git.govpress.com:wordpress-plugins/another-plugin',
'src' => 'git@github.com:dxw-wordpress-plugins/another-plugin',
'revision' => '789abc',
];

Expand All @@ -46,9 +46,9 @@ public function testInstallAll()

$gitMyTheme = $this->getGit(false, 'git@git.govpress.com:wordpress-themes/my-theme', '27ba906');
$this->addFactoryNewInstance('\\Dxw\\Whippet\\Git\\Git', $dir.'/wp-content/themes/my-theme', $gitMyTheme);
$gitMyPlugin = $this->getGit(false, 'git@git.govpress.com:wordpress-plugins/my-plugin', '123456');
$gitMyPlugin = $this->getGit(false, 'git@github.com:dxw-wordpress-plugins/my-plugin', '123456');
$this->addFactoryNewInstance('\\Dxw\\Whippet\\Git\\Git', $dir.'/wp-content/plugins/my-plugin', $gitMyPlugin);
$gitAnotherPlugin = $this->getGit(false, 'git@git.govpress.com:wordpress-plugins/another-plugin', '789abc');
$gitAnotherPlugin = $this->getGit(false, 'git@github.com:dxw-wordpress-plugins/another-plugin', '789abc');
$this->addFactoryNewInstance('\\Dxw\\Whippet\\Git\\Git', $dir.'/wp-content/plugins/another-plugin', $gitAnotherPlugin);

$inspection_check_results = function ($type, $dep) {
Expand Down Expand Up @@ -115,7 +115,7 @@ public function testInspectionsApiUnavailable()

$my_plugin = [
'name' => 'my-plugin',
'src' => 'git@git.govpress.com:wordpress-plugins/my-plugin',
'src' => 'git@github.com:dxw-wordpress-plugins/my-plugin',
'revision' => '123456',
];

Expand All @@ -127,7 +127,7 @@ public function testInspectionsApiUnavailable()
]);
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetLock', 'fromFile', $dir.'/whippet.lock', \Result\Result::ok($whippetLock));

$gitMyPlugin = $this->getGit(false, 'git@git.govpress.com:wordpress-plugins/my-plugin', '123456');
$gitMyPlugin = $this->getGit(false, 'git@github.com:dxw-wordpress-plugins/my-plugin', '123456');
$this->addFactoryNewInstance('\\Dxw\\Whippet\\Git\\Git', $dir.'/wp-content/plugins/my-plugin', $gitMyPlugin);

$inspection_check_results = function ($type, $dep) {
Expand Down Expand Up @@ -438,12 +438,12 @@ public function testInstallSingle()
'plugins' => [
[
'name' => 'my-plugin',
'src' => 'git@git.govpress.com:wordpress-plugins/my-plugin',
'src' => 'git@github.com:dxw-wordpress-plugins/my-plugin',
'revision' => '123456',
],
[
'name' => 'another-plugin',
'src' => 'git@git.govpress.com:wordpress-plugins/another-plugin',
'src' => 'git@github.com:dxw-wordpress-plugins/another-plugin',
'revision' => '789abc',
],
],
Expand Down Expand Up @@ -499,19 +499,19 @@ public function testInstallSingleAlreadyCloned()
'plugins' => [
[
'name' => 'my-plugin',
'src' => 'git@git.govpress.com:wordpress-plugins/my-plugin',
'src' => 'git@github.com:dxw-wordpress-plugins/my-plugin',
'revision' => '123456',
],
[
'name' => 'another-plugin',
'src' => 'git@git.govpress.com:wordpress-plugins/another-plugin',
'src' => 'git@github.com:dxw-wordpress-plugins/another-plugin',
'revision' => '789abc',
],
],
]);
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetLock', 'fromFile', $dir.'/whippet.lock', \Result\Result::ok($whippetLock));

$gitMyPlugin = $this->getGit(false, 'git@git.govpress.com:wordpress-plugins/my-plugin', '123456');
$gitMyPlugin = $this->getGit(false, 'git@github.com:dxw-wordpress-plugins/my-plugin', '123456');
$this->addFactoryNewInstance('\\Dxw\\Whippet\\Git\\Git', $dir.'/wp-content/plugins/my-plugin', $gitMyPlugin);

$dependencies = new \Dxw\Whippet\Dependencies\Installer(
Expand Down Expand Up @@ -544,19 +544,19 @@ public function testInstallSingleAlreadyClonedAndArchived()
'plugins' => [
[
'name' => 'my-plugin',
'src' => 'git@git.govpress.com:wordpress-plugins/my-plugin',
'src' => 'git@github.com:dxw-wordpress-plugins/my-plugin',
'revision' => '123456',
],
[
'name' => 'another-plugin',
'src' => 'git@git.govpress.com:wordpress-plugins/another-plugin',
'src' => 'git@github.com:dxw-wordpress-plugins/another-plugin',
'revision' => '789abc',
],
],
]);
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetLock', 'fromFile', $dir.'/whippet.lock', \Result\Result::ok($whippetLock));

$gitMyPlugin = $this->getGit(false, 'git@git.govpress.com:wordpress-plugins/my-plugin', '123456', true);
$gitMyPlugin = $this->getGit(false, 'git@github.com:dxw-wordpress-plugins/my-plugin', '123456', true);
$this->addFactoryNewInstance('\\Dxw\\Whippet\\Git\\Git', $dir.'/wp-content/plugins/my-plugin', $gitMyPlugin);

$dependencies = new \Dxw\Whippet\Dependencies\Installer(
Expand Down
42 changes: 21 additions & 21 deletions tests/dependencies/updater_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function testUpdateAll()
$whippetJson = $this->getWhippetJson([
'src' => [
'themes' => 'git@git.govpress.com:wordpress-themes/',
'plugins' => 'git@git.govpress.com:wordpress-plugins/',
'plugins' => 'git@github.com:dxw-wordpress-plugins/',
],
'themes' => [
[
Expand All @@ -96,12 +96,12 @@ public function testUpdateAll()

$whippetLock = $this->getWhippetLockWritable([
['themes', 'my-theme', 'git@git.govpress.com:wordpress-themes/my-theme', '27ba906'],
['plugins', 'my-plugin', 'git@git.govpress.com:wordpress-plugins/my-plugin', 'd961c3d'],
['plugins', 'my-plugin', 'git@github.com:dxw-wordpress-plugins/my-plugin', 'd961c3d'],
], sha1('foobar'), $dir.'/whippet.lock', []);
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetLock', 'fromFile', $dir.'/whippet.lock', \Result\Result::ok($whippetLock));

$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-themes/my-theme', 'v1.4', \Result\Result::ok('27ba906'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@github.com:dxw-wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));

$dependencies = new \Dxw\Whippet\Dependencies\Updater(
$this->getFactory(),
Expand Down Expand Up @@ -431,7 +431,7 @@ public function testUpdateAllNoGitignore()
$whippetJson = $this->getWhippetJson([
'src' => [
'themes' => 'git@git.govpress.com:wordpress-themes/',
'plugins' => 'git@git.govpress.com:wordpress-plugins/',
'plugins' => 'git@github.com:dxw-wordpress-plugins/',
],
'themes' => [
[
Expand All @@ -458,12 +458,12 @@ public function testUpdateAllNoGitignore()

$whippetLock = $this->getWhippetLockWritable([
['themes', 'my-theme', 'git@git.govpress.com:wordpress-themes/my-theme', '27ba906'],
['plugins', 'my-plugin', 'git@git.govpress.com:wordpress-plugins/my-plugin', 'd961c3d'],
['plugins', 'my-plugin', 'git@github.com:dxw-wordpress-plugins/my-plugin', 'd961c3d'],
], sha1('foobar'), $dir.'/whippet.lock', []);
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetLock', 'fromFile', $dir.'/whippet.lock', \Result\Result::ok($whippetLock));

$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-themes/my-theme', 'v1.4', \Result\Result::ok('27ba906'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@github.com:dxw-wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));

$dependencies = new \Dxw\Whippet\Dependencies\Updater(
$this->getFactory(),
Expand Down Expand Up @@ -519,7 +519,7 @@ public function testUpdateAllRemoveFromGitignore()
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetLock', 'fromFile', $dir.'/whippet.lock', \Result\Result::ok($whippetLock));

$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-themes/my-theme', 'v1.4', \Result\Result::ok('27ba906'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@github.com:dxw-wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));

$dependencies = new \Dxw\Whippet\Dependencies\Updater(
$this->getFactory(),
Expand Down Expand Up @@ -561,7 +561,7 @@ public function testUpdateAllNoExistingWhippetLock()
$whippetJson = $this->getWhippetJson([
'src' => [
'themes' => 'git@git.govpress.com:wordpress-themes/',
'plugins' => 'git@git.govpress.com:wordpress-plugins/',
'plugins' => 'git@github.com:dxw-wordpress-plugins/',
],
'themes' => [
[
Expand All @@ -588,12 +588,12 @@ public function testUpdateAllNoExistingWhippetLock()

$whippetLock = $this->getWhippetLockWritable([
['themes', 'my-theme', 'git@git.govpress.com:wordpress-themes/my-theme', '27ba906'],
['plugins', 'my-plugin', 'git@git.govpress.com:wordpress-plugins/my-plugin', 'd961c3d'],
['plugins', 'my-plugin', 'git@github.com:dxw-wordpress-plugins/my-plugin', 'd961c3d'],
], sha1('foobar'), $dir.'/whippet.lock', []);
$this->addFactoryNewInstance('\\Dxw\\Whippet\\Files\\WhippetLock', [], $whippetLock);

$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-themes/my-theme', 'v1.4', \Result\Result::ok('27ba906'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@github.com:dxw-wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetLock', 'fromFile', $dir.'/whippet.lock', \Result\Result::err('file not found'));

$dependencies = new \Dxw\Whippet\Dependencies\Updater(
Expand All @@ -615,7 +615,7 @@ public function testUpdateAllWithBrokenJson()

$whippetJson = $this->getWhippetJson([
'src' => [
'plugins' => 'git@git.govpress.com:wordpress-plugins/',
'plugins' => 'git@github.com:dxw-wordpress-plugins/',
],
'themes' => [
[
Expand Down Expand Up @@ -644,7 +644,7 @@ public function testUpdateAllWithBrokenJson()
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetLock', 'fromFile', $dir.'/whippet.lock', \Result\Result::ok($whippetLock));

$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-themes/my-theme', 'v1.4', \Result\Result::ok('27ba906'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@github.com:dxw-wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));

$dependencies = new \Dxw\Whippet\Dependencies\Updater(
$this->getFactory(),
Expand Down Expand Up @@ -709,7 +709,7 @@ public function testUpdateSingleNoMatch()
file_put_contents($dir.'/whippet.json', 'foobar');
$whippetJson = $this->getWhippetJson([
'src' => [
'plugins' => 'git@git.govpress.com:wordpress-plugins/',
'plugins' => 'git@github.com:dxw-wordpress-plugins/',
],
'themes' => [
[
Expand Down Expand Up @@ -749,7 +749,7 @@ public function testUpdateSingleBrokenJson()

$whippetJson = $this->getWhippetJson([
'src' => [
'plugins' => 'git@git.govpress.com:wordpress-plugins/',
'plugins' => 'git@github.com:dxw-wordpress-plugins/',
],
'themes' => [
[
Expand Down Expand Up @@ -778,7 +778,7 @@ public function testUpdateSingleBrokenJson()
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetLock', 'fromFile', $dir.'/whippet.lock', \Result\Result::ok($whippetLock));

$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-themes/my-theme', 'v1.4', \Result\Result::ok('27ba906'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@github.com:dxw-wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));

$dependencies = new \Dxw\Whippet\Dependencies\Updater(
$this->getFactory(),
Expand Down Expand Up @@ -954,7 +954,7 @@ public function testUpdateSingleWithExplicitSrc()
$whippetJson = $this->getWhippetJson([
'src' => [
'themes' => 'git@git.govpress.com:wordpress-themes/',
'plugins' => 'git@git.govpress.com:wordpress-plugins/',
'plugins' => 'git@github.com:dxw-wordpress-plugins/',
],
'themes' => [
[
Expand Down Expand Up @@ -1057,7 +1057,7 @@ public function testUpdateSingleNoGitignore()
$whippetJson = $this->getWhippetJson([
'src' => [
'themes' => 'git@git.govpress.com:wordpress-themes/',
'plugins' => 'git@git.govpress.com:wordpress-plugins/',
'plugins' => 'git@github.com:dxw-wordpress-plugins/',
],
'themes' => [
[
Expand Down Expand Up @@ -1088,7 +1088,7 @@ public function testUpdateSingleNoGitignore()
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetLock', 'fromFile', $dir.'/whippet.lock', \Result\Result::ok($whippetLock));

$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-themes/my-theme', 'v1.4', \Result\Result::ok('27ba906'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@github.com:dxw-wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));

$dependencies = new \Dxw\Whippet\Dependencies\Updater(
$this->getFactory(),
Expand All @@ -1111,7 +1111,7 @@ public function testUpdateSingle()

$whippetJson = $this->getWhippetJson([
'src' => [
'plugins' => 'git@git.govpress.com:wordpress-plugins/',
'plugins' => 'git@github.com:dxw-wordpress-plugins/',
],
'themes' => [
[
Expand All @@ -1129,12 +1129,12 @@ public function testUpdateSingle()
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetJson', 'fromFile', $dir.'/whippet.json', \Result\Result::ok($whippetJson));

$whippetLock = $this->getWhippetLockWritable([
['plugins', 'my-plugin', 'git@git.govpress.com:wordpress-plugins/my-plugin', 'd961c3d'],
['plugins', 'my-plugin', 'git@github.com:dxw-wordpress-plugins/my-plugin', 'd961c3d'],
], sha1('foobar'), $dir.'/whippet.lock', []);

$this->addFactoryCallStatic('\\Dxw\\Whippet\\Files\\WhippetLock', 'fromFile', $dir.'/whippet.lock', \Result\Result::ok($whippetLock));

$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@git.govpress.com:wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));
$this->addFactoryCallStatic('\\Dxw\\Whippet\\Git\\Git', 'ls_remote', 'git@github.com:dxw-wordpress-plugins/my-plugin', 'v1.6', \Result\Result::ok('d961c3d'));

$gitignore = $this->getGitignore(["/wp-content/themes/my-theme\n",
"/wp-content/plugins/my-plugin\n", ], [
Expand Down
4 changes: 2 additions & 2 deletions tests/files/whippet_json_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public function testGetSources()
{
$whippetJson = new \Dxw\Whippet\Files\WhippetJson([
'src' => [
'plugins' => 'git@git.govpress.com:wordpress-plugins/',
'plugins' => 'git@github.com:dxw-wordpress-plugins/',
],
]);

$this->assertEquals([
'plugins' => 'git@git.govpress.com:wordpress-plugins/',
'plugins' => 'git@github.com:dxw-wordpress-plugins/',
], $whippetJson->getSources());
}

Expand Down
Loading

0 comments on commit d8ab5c8

Please sign in to comment.