Refactor MultiDownloaderClientTest class and update constructor usage
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This commit is contained in:
parent
43fd2c26cb
commit
941202e925
@ -20,18 +20,9 @@ class MultiDownloaderClientTest extends TestCase
|
|||||||
}, $this->testFiles);
|
}, $this->testFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getProperty($object, $property)
|
|
||||||
{
|
|
||||||
$reflectedClass = new \ReflectionClass($object);
|
|
||||||
$reflection = $reflectedClass->getProperty($property);
|
|
||||||
$reflection->setAccessible(true);
|
|
||||||
|
|
||||||
return $reflection->getValue($object);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDownloadAsString()
|
public function testDownloadAsString()
|
||||||
{
|
{
|
||||||
$client = new MultiDownloaderClient();
|
$client = new MultiDownloaderClient(['apiKey' => 'test', 'apiSecret' => 'test' ]);
|
||||||
|
|
||||||
$client->setFiles($this->testFiles());
|
$client->setFiles($this->testFiles());
|
||||||
|
|
||||||
@ -44,7 +35,7 @@ class MultiDownloaderClientTest extends TestCase
|
|||||||
|
|
||||||
public function testDownloadTo()
|
public function testDownloadTo()
|
||||||
{
|
{
|
||||||
$client = new MultiDownloaderClient();
|
$client = new MultiDownloaderClient(['apiKey' => 'test', 'apiSecret' => 'test' ]);
|
||||||
|
|
||||||
$path = sys_get_temp_dir() . '/testDownloadTo.zip';
|
$path = sys_get_temp_dir() . '/testDownloadTo.zip';
|
||||||
|
|
||||||
@ -57,40 +48,11 @@ class MultiDownloaderClientTest extends TestCase
|
|||||||
$this->assertEquals('ea9726d2ecbe6b820899ba125bf0ae94', $md5);
|
$this->assertEquals('ea9726d2ecbe6b820899ba125bf0ae94', $md5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testApiKeyEnv()
|
|
||||||
{
|
|
||||||
putenv('MULTI_DOWNLOADER_ACCESS_KEY=1234567890');
|
|
||||||
|
|
||||||
$client = new MultiDownloaderClient();
|
|
||||||
$apiKey = self::getProperty($client, 'apiKey');
|
|
||||||
$this->assertEquals('1234567890', $apiKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testForm()
|
public function testForm()
|
||||||
{
|
{
|
||||||
$client = new MultiDownloaderClient();
|
$client = new MultiDownloaderClient(['apiKey' => 'test', 'apiSecret' => 'test' ]);
|
||||||
$client->setFiles($this->testFiles());
|
$client->setFiles($this->testFiles());
|
||||||
|
|
||||||
echo $client->htmlForm($this->testFiles());
|
echo $client->htmlForm($this->testFiles());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testApiKeyParam()
|
|
||||||
{
|
|
||||||
$client = new MultiDownloaderClient([
|
|
||||||
'apiKey' => 'test_key'
|
|
||||||
]);
|
|
||||||
|
|
||||||
$apiKey = self::getProperty($client, 'apiKey');
|
|
||||||
$this->assertEquals('test_key', $apiKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testApiKeyMissing()
|
|
||||||
{
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
$this->expectExceptionMessage('API key is required');
|
|
||||||
|
|
||||||
putenv('MULTI_DOWNLOADER_ACCESS_KEY');
|
|
||||||
|
|
||||||
new MultiDownloaderClient();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user