Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcblogdev committed May 2, 2024
1 parent e28c4af commit 905fc60
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
4 changes: 4 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@
<php>
<env name="DB_CONNECTION" value="testing"/>
<env name="APP_KEY" value="base64:2fl+Ktvkfl+Fuz4Qp/A75G2RTiWVA/ZoKZvp6fiiM10="/>
<env name="DBSYNC_USESSH" value="true"/>
<env name="DBSYNC_SSHUSERNAME" value="username"/>
<env name="DBSYNC_SSHPORT" value="22"/>
<env name="DBSYNC_HOST" value="localhost"/>
</php>
</phpunit>
24 changes: 24 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,28 @@ protected function getPackageProviders($app)
DbSyncServiceProvider::class,
];
}

protected function getEnvironmentSetUp($app)
{
$app['config']->set('dbsync.useSsh', false);
$app['config']->set('dbsync.host', '');
$app['config']->set('dbsync.sshUsername', '');
$app['config']->set('dbsync.sshPort', 22);
$app['config']->set('dbsync.username', '');
$app['config']->set('dbsync.mysqlHostName', 'localhost');
$app['config']->set('dbsync.port', 3306);
$app['config']->set('dbsync.database', '');
$app['config']->set('dbsync.password', '');
$app['config']->set('dbsync.ignore', '');
$app['config']->set('dbsync.importSqlFile', true);
$app['config']->set('dbsync.removeFileAfterImport', true);
$app['config']->set('dbsync.defaultFileName', 'file.sql');
$app['config']->set('dbsync.targetConnection', 'mysql');
$app['config']->set('dbsync.mysqldumpSkipTzUtc', false);
$app['config']->set('dbsync.localMysqlPath', '/usr/local/bin/mysql');
$app['config']->set('dbsync.environments', [
'local',
'staging'
]);
}
}
5 changes: 4 additions & 1 deletion tests/Unit/DbSyncTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@
config(['dbsync.database' => 'demo']);

$this->artisan('db:production-sync --test')
->expectsOutput('DB Synced');
->doesntExpectOutputToContain('DB sync will only run on local and staging environments')
->doesntExpectOutputToContain('DB credentials not set, have you published the config and set ENV variables?')
->assertExitCode(true)
->expectsOutput("\nDB Synced");
});
5 changes: 4 additions & 1 deletion tests/Unit/RemoteSyncTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@
config(['dbsync.database' => 'demo']);

$this->artisan('db:remote-sync --test')
->expectsOutput('DB Synced');
->doesntExpectOutputToContain('DB sync will only run on local and staging environments')
->doesntExpectOutputToContain('DB credentials not set, have you published the config and set ENV variables?')
->assertExitCode(true)
->expectsOutput("\nDB Synced");
});

0 comments on commit 905fc60

Please sign in to comment.