From 22cbc82fd8fb12a9206f0296d3fc67328b7255a5 Mon Sep 17 00:00:00 2001 From: Froxz Date: Thu, 9 Mar 2023 16:07:27 +0200 Subject: [PATCH 1/3] Bugfix creating env --- lib/Github/Api/Environment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Github/Api/Environment.php b/lib/Github/Api/Environment.php index 057d1edf0d8..8a8bb11a337 100644 --- a/lib/Github/Api/Environment.php +++ b/lib/Github/Api/Environment.php @@ -53,7 +53,7 @@ public function show($username, $repository, $name) */ public function createOrUpdate($username, $repository, $name, array $params = []) { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments', $params); + return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($name), $params); } /** From ce974e1009ec36cd363113024c3d8ce3b7d8cc05 Mon Sep 17 00:00:00 2001 From: Froxz Date: Thu, 9 Mar 2023 16:09:48 +0200 Subject: [PATCH 2/3] fixed tests --- test/Github/Tests/Api/EnvironmentTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Github/Tests/Api/EnvironmentTest.php b/test/Github/Tests/Api/EnvironmentTest.php index 56efbc0afc8..3b6f6f417fe 100644 --- a/test/Github/Tests/Api/EnvironmentTest.php +++ b/test/Github/Tests/Api/EnvironmentTest.php @@ -13,7 +13,7 @@ public function shouldCreateOrUpdateEnvironment() $api->expects($this->once()) ->method('put') - ->with('/repos/KnpLabs/php-github-api/environments'); + ->with('/repos/KnpLabs/php-github-api/environments/production'); $api->createOrUpdate('KnpLabs', 'php-github-api', 'production'); } From 8b365a303bfeb3a4cfd08c429d832dbe21090465 Mon Sep 17 00:00:00 2001 From: Froxz Date: Thu, 9 Mar 2023 16:11:27 +0200 Subject: [PATCH 3/3] added rawurlencode for $name --- lib/Github/Api/Environment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Github/Api/Environment.php b/lib/Github/Api/Environment.php index 8a8bb11a337..c154666daf3 100644 --- a/lib/Github/Api/Environment.php +++ b/lib/Github/Api/Environment.php @@ -36,7 +36,7 @@ public function all($username, $repository, array $params = []) */ public function show($username, $repository, $name) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.$name); + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($name)); } /** @@ -65,6 +65,6 @@ public function createOrUpdate($username, $repository, $name, array $params = [] */ public function remove(string $username, string $repository, string $name) { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.$name); + return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($name)); } }