Skip to content

Commit

Permalink
Create first tests
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 22, 2024
1 parent 85d6729 commit b5f507a
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

0 comments on commit b5f507a

Please sign in to comment.