Skip to content

Commit

Permalink
Health Command - Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
svilborg committed Jul 28, 2019
1 parent 00c409b commit cd59eee
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tests/Command/HealthCommandFailTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
namespace Tests\Unit;

use Illuminate\Support\Facades\Artisan;
use Health\ServiceProviders\HealthServiceProvider;

class HealthCommandFailTest extends \Orchestra\Testbench\TestCase
{

/**
* Package Providers
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getPackageProviders($app)
{
return [
HealthServiceProvider::class
];
}

/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function resolveApplicationConfiguration($app)
{
parent::resolveApplicationConfiguration($app);

$app['config']['health'] = [
'checks' => [
[
'class' => \Health\Checks\NullCheck::class
],
[
'class' => \Health\Checks\Env\Environment::class,
'params' => [
'APP_ENV' => 'nosuch'
]
]
]
];
}

public function testCommand()
{
$this->mockConsoleOutput = false;

$code = $this->artisan('health', []);

$resultAsText = Artisan::output();
// echo $resultAsText;

$this->assertEquals(1, $code);

$this->assertContains('DOWN Health', $resultAsText);
$this->assertContains('✔ UP health-checks-null-check', $resultAsText);
$this->assertContains('✖ DOWN health-checks-env-environment', $resultAsText);
}
}
2 changes: 2 additions & 0 deletions tests/Command/HealthCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ public function testCommand()

$this->assertEquals(0, $code);
$this->assertContains('UP Health', $resultAsText);
$this->assertContains('✔ UP health-checks-null-check', $resultAsText);
$this->assertContains('✔ UP health-checks-env-environment', $resultAsText);
}
}

0 comments on commit cd59eee

Please sign in to comment.