Skip to content

Commit

Permalink
added test to confirm command runs and exists
Browse files Browse the repository at this point in the history
  • Loading branch information
dcblogdev committed Jun 26, 2022
1 parent 557f78b commit 255fd6f
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions tests/Unit/DbSyncTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,39 @@
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;

//TODO pass test
test('will fail without credentials', function () {
test('cannot run on production', function () {

config(['app.env' => 'production']);

$this->artisan('db:production-sync')
->expectsOutput('DB sync will only run on local and staging environments')
->assertExitCode(true);
});

test('can run on environment', function ($env) {

config(['app.env' => $env]);

$this->artisan('db:production-sync')
->doesntExpectOutput('DB sync will only run on local and staging environments');
})->with(['local', 'staging']);

test('fails with invalid credentials', function () {

config(['app.env' => 'local']);

$this->artisan('db:production-sync')
->expectsOutput('DB credentials not set, have you published the config and set ENV variables?')
->assertFailed();
});

test('runs with valid credentials', function () {

config(['app.env' => 'local']);
config(['dbsync.host' => '127.0.0.1']);
config(['dbsync.username' => 'root']);
config(['dbsync.database' => 'demo']);

$this->artisan('db:production-sync')
->expectsOutput('DB credentials not set, have you published the config and set ENV variables?');
});
->expectsOutput('DB Synced');
});

0 comments on commit 255fd6f

Please sign in to comment.