From a1cbac0afb76daaaddf6d1aca7e496d73ed5bdbe Mon Sep 17 00:00:00 2001 From: printempw Date: Fri, 16 Feb 2018 18:32:22 +0800 Subject: [PATCH] Specify the user agent of requests by env variable --- tests/PluginControllerTest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/PluginControllerTest.php b/tests/PluginControllerTest.php index cbf70e31..7bf397d1 100644 --- a/tests/PluginControllerTest.php +++ b/tests/PluginControllerTest.php @@ -16,11 +16,14 @@ class PluginControllerTest extends TestCase 'example-plugin' => 'example-plugin_v1.0.zip', 'avatar-api' => 'avatar-api_v1.1.zip' ]; + foreach ($plugins as $plugin_name => $filename) { if (! file_exists(base_path('plugins/'.$plugin_name))) { + $user_agent = menv('USER_AGENT', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36'); + $context = stream_context_create(['http' => [ - 'method' => "GET", - 'header' => "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36" + 'method' => 'GET', + 'header' => "User-Agent: $user_agent" ]]); file_put_contents(