Skip to content

Commit

Permalink
StorageAdapter tests are now skipped if required environment variable…
Browse files Browse the repository at this point in the history
…s to not exist
  • Loading branch information
arnegroskurth committed Jul 17, 2018
1 parent 1f24d12 commit 4f6bd42
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 4 additions & 1 deletion tests/StorageAdapter/AbstractStorageAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ abstract class AbstractStorageAdapterTest extends TestCase
{
public function testRoundtrip()
{
$adapter = $this->getStorageAdapter();
if (($adapter = $this->getStorageAdapter()) === null)
{
return;
}

$objectName = uniqid('test_file_');
$objectData = random_bytes(rand(10, 100));
Expand Down
14 changes: 10 additions & 4 deletions tests/StorageAdapter/FtpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ class FtpTest extends AbstractStorageAdapterTest

protected function getStorageAdapter(): StorageAdapterInterface
{
if (!getenv('ftpHost') || !getenv('ftpUser') || !getenv('ftpPass'))
{
$this->markTestSkipped('Skipping test because required environment variables do not exist.');

return null;
}

$vaultConfiguration = new VaultConfiguration($this->getConfigurationMock());
$vaultConfiguration->setSettings([
// https://dlptest.com/ftp-test/
'host' => 'ftp.dlptest.com',
'username' => 'dlpuser@dlptest.com',
'password' => '3D6XZV9MKdhM5fF',
'host' => getenv('ftpHost'),
'username' => getenv('ftpUser'),
'password' => getenv('ftpPass'),
]);

return new Ftp($vaultConfiguration);
Expand Down
7 changes: 7 additions & 0 deletions tests/StorageAdapter/S3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ class S3Test extends AbstractStorageAdapterTest

protected function getStorageAdapter(): StorageAdapterInterface
{
if (!getenv('s3key') || !getenv('s3bucket') || !getenv('s3region'))
{
$this->markTestSkipped('Skipping test because required environment variables do not exist.');

return null;
}

$vaultConfiguration = new VaultConfiguration($this->getConfigurationMock());
$vaultConfiguration->setSettings([
'key' => getenv('s3key'),
Expand Down

0 comments on commit 4f6bd42

Please sign in to comment.