Add test to cover

This commit is contained in:
Pig Fang 2019-08-22 11:44:51 +08:00
parent 7021ef49b4
commit 5d8814e900

View File

@ -20,7 +20,6 @@ class PackageManagerTest extends TestCase
public function testDownload()
{
$mock = new MockHandler([
new Response(200, [], 'contents'),
new Response(200, [], 'contents'),
new RequestException('error', new Request('GET', 'url')),
]);
@ -34,13 +33,22 @@ class PackageManagerTest extends TestCase
$package->download('url', storage_path('packages/temp'))
);
$this->expectException(Exception::class);
$package->download('url', storage_path('packages/temp'), 'deadbeef');
$this->expectException(Exception::class);
$this->expectExceptionMessage(trans('admin.download.errors.download', ['error' => 'error']));
$package->download('url', storage_path('packages/temp'));
}
public function testShasumCheck()
{
$mock = new MockHandler([new Response(200, [], 'contents')]);
$handler = HandlerStack::create($mock);
$client = new Client(['handler' => $handler]);
$this->instance(Client::class, $client);
$package = resolve(PackageManager::class);
$this->expectExceptionMessage(trans('admin.download.errors.shasum'));
$package->download('url', storage_path('packages/temp'), 'deadbeef');
}
public function testExtract()
{
$this->mock(ZipArchive::class, function ($mock) {