diff --git a/tests/Console/Commands/Concerns/BacksUpComposerJson.php b/tests/Console/Commands/Concerns/BacksUpComposerJson.php deleted file mode 100644 index 5e1233daf7..0000000000 --- a/tests/Console/Commands/Concerns/BacksUpComposerJson.php +++ /dev/null @@ -1,20 +0,0 @@ -copy(base_path('composer.json'), base_path('composer.json.bak')); - } - - protected function restoreComposerJson() - { - $files = app(Filesystem::class); - $files->copy(base_path('composer.json.bak'), base_path('composer.json')); - $files->delete(base_path('composer.json.bak')); - } -} diff --git a/tests/Console/Commands/Concerns/FakesComposerInstalls.php b/tests/Console/Commands/Concerns/FakesComposerInstalls.php new file mode 100644 index 0000000000..9663f79704 --- /dev/null +++ b/tests/Console/Commands/Concerns/FakesComposerInstalls.php @@ -0,0 +1,13 @@ +andReturnSelf(); + } +} diff --git a/tests/Console/Commands/MakeActionTest.php b/tests/Console/Commands/MakeActionTest.php index f1311ba695..570e92e3dd 100644 --- a/tests/Console/Commands/MakeActionTest.php +++ b/tests/Console/Commands/MakeActionTest.php @@ -8,8 +8,8 @@ class MakeActionTest extends TestCase { - use Concerns\BacksUpComposerJson, - Concerns\CleansUpGeneratedPaths; + use Concerns\CleansUpGeneratedPaths, + Concerns\FakesComposerInstalls; private $files; @@ -18,13 +18,12 @@ public function setUp(): void parent::setUp(); $this->files = app(Filesystem::class); - $this->backupComposerJson(); + $this->fakeSuccessfulComposerRequire(); } public function tearDown(): void { $this->cleanupPaths(); - $this->restoreComposerJson(); parent::tearDown(); } diff --git a/tests/Console/Commands/MakeAddonTest.php b/tests/Console/Commands/MakeAddonTest.php index 53545f8f36..e1279d7269 100644 --- a/tests/Console/Commands/MakeAddonTest.php +++ b/tests/Console/Commands/MakeAddonTest.php @@ -2,14 +2,13 @@ namespace Tests\Console\Commands; -use Facades\Statamic\Console\Processes\Composer; use Illuminate\Filesystem\Filesystem; use Tests\TestCase; class MakeAddonTest extends TestCase { - use Concerns\BacksUpComposerJson, - Concerns\CleansUpGeneratedPaths; + use Concerns\CleansUpGeneratedPaths, + Concerns\FakesComposerInstalls; private $files; @@ -20,13 +19,12 @@ public function setUp(): void $this->markTestSkippedInWindows(); $this->files = app(Filesystem::class); - $this->backupComposerJson(); + $this->fakeSuccessfulComposerRequire(); } public function tearDown(): void { $this->cleanupPaths(); - $this->restoreComposerJson(); parent::tearDown(); } @@ -94,8 +92,6 @@ public function using_force_option_will_overwrite_original_addon() /** @test */ public function it_can_generate_with_a_fieldtype() { - $this->fakeSuccessfulComposerInstall(); - $this->assertFileDoesNotExist(base_path('addons/hasselhoff/knight-rider')); $this->makeAddon('hasselhoff/knight-rider', ['--fieldtype' => true]); @@ -118,8 +114,6 @@ public function it_can_generate_with_a_fieldtype() /** @test */ public function it_can_make_an_addon_with_everything_including_the_kitchen_sink() { - $this->fakeSuccessfulComposerInstall(); - $path = base_path('addons/ford/san-holo'); $this->assertFileDoesNotExist($path); @@ -146,9 +140,4 @@ private function makeAddon($addon, $options = []) '--no-interaction' => true, ], $options)); } - - private function fakeSuccessfulComposerInstall() - { - Composer::shouldReceive('withoutQueue', 'throwOnFailure', 'require')->andReturnSelf(); - } } diff --git a/tests/Console/Commands/MakeFieldtypeTest.php b/tests/Console/Commands/MakeFieldtypeTest.php index bc05e1e4d6..05d2b4994b 100644 --- a/tests/Console/Commands/MakeFieldtypeTest.php +++ b/tests/Console/Commands/MakeFieldtypeTest.php @@ -8,8 +8,8 @@ class MakeFieldtypeTest extends TestCase { - use Concerns\BacksUpComposerJson, - Concerns\CleansUpGeneratedPaths; + use Concerns\CleansUpGeneratedPaths, + Concerns\FakesComposerInstalls; private $files; @@ -18,13 +18,12 @@ public function setUp(): void parent::setUp(); $this->files = app(Filesystem::class); - $this->backupComposerJson(); + $this->fakeSuccessfulComposerRequire(); } public function tearDown(): void { $this->cleanupPaths(); - $this->restoreComposerJson(); parent::tearDown(); } diff --git a/tests/Console/Commands/MakeFilterTest.php b/tests/Console/Commands/MakeFilterTest.php index e614dc8aa8..f183ecb969 100644 --- a/tests/Console/Commands/MakeFilterTest.php +++ b/tests/Console/Commands/MakeFilterTest.php @@ -8,8 +8,8 @@ class MakeFilterTest extends TestCase { - use Concerns\BacksUpComposerJson, - Concerns\CleansUpGeneratedPaths; + use Concerns\CleansUpGeneratedPaths, + Concerns\FakesComposerInstalls; private $files; @@ -18,13 +18,12 @@ public function setUp(): void parent::setUp(); $this->files = app(Filesystem::class); - $this->backupComposerJson(); + $this->fakeSuccessfulComposerRequire(); } public function tearDown(): void { $this->cleanupPaths(); - $this->restoreComposerJson(); parent::tearDown(); } diff --git a/tests/Console/Commands/MakeModifierTest.php b/tests/Console/Commands/MakeModifierTest.php index c345970ade..0bf37c2b42 100644 --- a/tests/Console/Commands/MakeModifierTest.php +++ b/tests/Console/Commands/MakeModifierTest.php @@ -8,8 +8,8 @@ class MakeModifierTest extends TestCase { - use Concerns\BacksUpComposerJson, - Concerns\CleansUpGeneratedPaths; + use Concerns\CleansUpGeneratedPaths, + Concerns\FakesComposerInstalls; private $files; @@ -18,13 +18,12 @@ public function setUp(): void parent::setUp(); $this->files = app(Filesystem::class); - $this->backupComposerJson(); + $this->fakeSuccessfulComposerRequire(); } public function tearDown(): void { $this->cleanupPaths(); - $this->restoreComposerJson(); parent::tearDown(); } diff --git a/tests/Console/Commands/MakeScopeTest.php b/tests/Console/Commands/MakeScopeTest.php index 58ad64a99e..e92b345612 100644 --- a/tests/Console/Commands/MakeScopeTest.php +++ b/tests/Console/Commands/MakeScopeTest.php @@ -8,8 +8,8 @@ class MakeScopeTest extends TestCase { - use Concerns\BacksUpComposerJson, - Concerns\CleansUpGeneratedPaths; + use Concerns\CleansUpGeneratedPaths, + Concerns\FakesComposerInstalls; private $files; @@ -18,13 +18,12 @@ public function setUp(): void parent::setUp(); $this->files = app(Filesystem::class); - $this->backupComposerJson(); + $this->fakeSuccessfulComposerRequire(); } public function tearDown(): void { $this->cleanupPaths(); - $this->restoreComposerJson(); parent::tearDown(); } diff --git a/tests/Console/Commands/MakeTagTest.php b/tests/Console/Commands/MakeTagTest.php index 9c5ef5a0a1..82d132fbd6 100644 --- a/tests/Console/Commands/MakeTagTest.php +++ b/tests/Console/Commands/MakeTagTest.php @@ -8,8 +8,8 @@ class MakeTagTest extends TestCase { - use Concerns\BacksUpComposerJson, - Concerns\CleansUpGeneratedPaths; + use Concerns\CleansUpGeneratedPaths, + Concerns\FakesComposerInstalls; private $files; @@ -18,13 +18,12 @@ public function setUp(): void parent::setUp(); $this->files = app(Filesystem::class); - $this->backupComposerJson(); + $this->fakeSuccessfulComposerRequire(); } public function tearDown(): void { $this->cleanupPaths(); - $this->restoreComposerJson(); parent::tearDown(); } diff --git a/tests/Console/Commands/MakeWidgetTest.php b/tests/Console/Commands/MakeWidgetTest.php index f51334341a..86b0fa9235 100644 --- a/tests/Console/Commands/MakeWidgetTest.php +++ b/tests/Console/Commands/MakeWidgetTest.php @@ -8,8 +8,8 @@ class MakeWidgetTest extends TestCase { - use Concerns\BacksUpComposerJson, - Concerns\CleansUpGeneratedPaths; + use Concerns\CleansUpGeneratedPaths, + Concerns\FakesComposerInstalls; private $files; @@ -18,13 +18,12 @@ public function setUp(): void parent::setUp(); $this->files = app(Filesystem::class); - $this->backupComposerJson(); + $this->fakeSuccessfulComposerRequire(); } public function tearDown(): void { $this->cleanupPaths(); - $this->restoreComposerJson(); parent::tearDown(); }