Skip to content

Commit

Permalink
Test task skipping
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Apr 13, 2024
1 parent 33a2862 commit 292a75b
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion packages/framework/tests/Unit/BuildTaskUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,36 @@ public function testWithExecutionTime()
$this->assertSame(' in 1,234.56ms', $task->buffer[0]);
}

public function testTaskSkipping()
{
$task = new BufferedTestBuildTask();

$task->mockHandle(function (BufferedTestBuildTask $task) {
$task->skip();
});

$task->run();

$this->assertSame(0, $task->property('exitCode'));
$this->assertSame('<bg=yellow>Skipped</>', $task->buffer[1]);
$this->assertSame('<fg=gray> > Task was skipped</>', $task->buffer[2]);
}

public function testTaskSkippingWithCustomMessage()
{
$task = new BufferedTestBuildTask();

$task->mockHandle(function (BufferedTestBuildTask $task) {
$task->skip('Custom reason');
});

$task->run();

$this->assertSame(0, $task->property('exitCode'));
$this->assertSame('<bg=yellow>Skipped</>', $task->buffer[1]);
$this->assertSame('<fg=gray> > Custom reason</>', $task->buffer[2]);
}

public function testExceptionHandling()
{
$task = new BufferedTestBuildTask();
Expand Down Expand Up @@ -217,7 +247,7 @@ class InspectableTestBuildTask extends BuildTask
public function handle(): void
{
if (isset($this->mockHandle)) {
($this->mockHandle)();
($this->mockHandle)($this);
} else {
$this->wasHandled = true;
}
Expand Down

0 comments on commit 292a75b

Please sign in to comment.