Skip to content

Commit 905fc60

Browse files
committed
updated tests
1 parent e28c4af commit 905fc60

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

phpunit.xml

+4
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,9 @@
2626
<php>
2727
<env name="DB_CONNECTION" value="testing"/>
2828
<env name="APP_KEY" value="base64:2fl+Ktvkfl+Fuz4Qp/A75G2RTiWVA/ZoKZvp6fiiM10="/>
29+
<env name="DBSYNC_USESSH" value="true"/>
30+
<env name="DBSYNC_SSHUSERNAME" value="username"/>
31+
<env name="DBSYNC_SSHPORT" value="22"/>
32+
<env name="DBSYNC_HOST" value="localhost"/>
2933
</php>
3034
</phpunit>

tests/TestCase.php

+24
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,28 @@ protected function getPackageProviders($app)
1313
DbSyncServiceProvider::class,
1414
];
1515
}
16+
17+
protected function getEnvironmentSetUp($app)
18+
{
19+
$app['config']->set('dbsync.useSsh', false);
20+
$app['config']->set('dbsync.host', '');
21+
$app['config']->set('dbsync.sshUsername', '');
22+
$app['config']->set('dbsync.sshPort', 22);
23+
$app['config']->set('dbsync.username', '');
24+
$app['config']->set('dbsync.mysqlHostName', 'localhost');
25+
$app['config']->set('dbsync.port', 3306);
26+
$app['config']->set('dbsync.database', '');
27+
$app['config']->set('dbsync.password', '');
28+
$app['config']->set('dbsync.ignore', '');
29+
$app['config']->set('dbsync.importSqlFile', true);
30+
$app['config']->set('dbsync.removeFileAfterImport', true);
31+
$app['config']->set('dbsync.defaultFileName', 'file.sql');
32+
$app['config']->set('dbsync.targetConnection', 'mysql');
33+
$app['config']->set('dbsync.mysqldumpSkipTzUtc', false);
34+
$app['config']->set('dbsync.localMysqlPath', '/usr/local/bin/mysql');
35+
$app['config']->set('dbsync.environments', [
36+
'local',
37+
'staging'
38+
]);
39+
}
1640
}

tests/Unit/DbSyncTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@
3030
config(['dbsync.database' => 'demo']);
3131

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

tests/Unit/RemoteSyncTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@
3030
config(['dbsync.database' => 'demo']);
3131

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

0 commit comments

Comments
 (0)