From b5f507a65cf78522afe69da2dbcbd27f2d16d3d7 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 22 Dec 2024 17:04:40 +0100 Subject: [PATCH] Create first tests --- .../Commands/PublishViewsCommandTest.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/framework/tests/Feature/Commands/PublishViewsCommandTest.php b/packages/framework/tests/Feature/Commands/PublishViewsCommandTest.php index 7c845aabf49..aea48742783 100644 --- a/packages/framework/tests/Feature/Commands/PublishViewsCommandTest.php +++ b/packages/framework/tests/Feature/Commands/PublishViewsCommandTest.php @@ -4,6 +4,7 @@ namespace Hyde\Framework\Testing\Feature\Commands; +use Hyde\Console\Helpers\ConsoleHelper; use Hyde\Hyde; use Hyde\Testing\TestCase; use Illuminate\Support\Facades\File; @@ -50,4 +51,38 @@ public function testWithInvalidSuppliedTag() ->expectsOutputToContain('No publishable resources for tag [invalid].') ->assertExitCode(0); } + + public function testInteractiveSelectionOnUnixSystems() + { + if (windows_os()) { + $this->markTestSkipped('Laravel Prompts does not support Windows OS'); + } + + ConsoleHelper::mockMultiselect(['resources/views/vendor/hyde/components/article-excerpt.blade.php'], function ($label, $options) { + $this->assertEquals('Select the files you want to publish (CTRL+A to toggle all)', $label); + $this->assertContainsOnly('string', array_keys($options)); + $this->assertContainsOnly('string', array_values($options)); + $this->assertContains('resources/views/vendor/hyde/components/article-excerpt.blade.php', array_keys($options)); + $this->assertContains('article-excerpt.blade.php', array_values($options)); + }); + + $this->artisan('publish:views components --interactive') + ->expectsOutput("Published files [article-excerpt.blade.php]") + ->assertExitCode(0); + + $this->assertFileExists(Hyde::path('resources/views/vendor/hyde/components/article-excerpt.blade.php')); + + File::deleteDirectory(Hyde::path('resources/views/vendor/hyde')); + } + + public function testInteractiveSelectionOnWindowsSystems() + { + if (! windows_os()) { + $this->markTestSkipped('This test is only for Windows OS'); + } + + $this->artisan('publish:views components --interactive') + ->expectsOutput('Due to limitations in the Windows version of PHP, it is not currently possible to use interactive mode on Windows outside of WSL.') + ->assertExitCode(1); + } }