-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change will make it possible to provide a proxy when downloading. For that the content of the environment-variable `HTTP_PROXY` is used. Alternatively one can also use `http_proxy` (as used by curl) can be used. For proxy-authentication you can set user and password for basic- authentication via the environment variable `HTTP_PROXY_AUTH`
- Loading branch information
1 parent
34af1d3
commit cf122d1
Showing
3 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phive xmlns="https://phar.io/phive"> | ||
<phar name="phpunit" version="^9.3" location="./tools/phpunit" copy="false" installed="9.4.2"/> | ||
<phar name="phpunit" version="^9.3" location="./tools/phpunit" copy="true" installed="9.5.21"/> | ||
<phar name="psalm" version="^3.11" location="./tools/psalm" copy="false" installed="3.18.2"/> | ||
<phar name="php-cs-fixer" version="^2.16" location="./tools/php-cs-fixer" copy="false" installed="2.16.7"/> | ||
</phive> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace PharIo\ComposerDistributorTest\unit\Service; | ||
|
||
use PharIo\ComposerDistributor\Service\Download; | ||
use PharIo\ComposerDistributor\Url; | ||
use PHPUnit\Framework\TestCase; | ||
use SplFileInfo; | ||
use function file_get_contents; | ||
use function putenv; | ||
use function sys_get_temp_dir; | ||
use function tempnam; | ||
|
||
class DownloadTest extends TestCase | ||
{ | ||
public function testDownloadWithoutProxy(): void | ||
{ | ||
putenv('http_proxy='); | ||
|
||
$temp = new SplFileInfo(tempnam(sys_get_temp_dir(), 'tests')); | ||
|
||
$download = new Download(Url::fromString('https://example.org')); | ||
|
||
$download->toLocation($temp); | ||
|
||
self::assertStringContainsString('example', file_get_contents($temp->getPathname())); | ||
} | ||
|
||
public function testDownloadWithProxy(): void | ||
{ | ||
putenv('http_proxy=tcp://172.16.1.184:8888'); | ||
|
||
$temp = new SplFileInfo(tempnam(sys_get_temp_dir(), 'tests')); | ||
|
||
$download = new Download(Url::fromString('https://example.org')); | ||
|
||
$this->expectWarning(); | ||
|
||
$download->toLocation($temp); | ||
} | ||
} |