diff --git a/src/Endpoints/CustomHostnames.php b/src/Endpoints/CustomHostnames.php index 1a90d0f..507d41d 100644 --- a/src/Endpoints/CustomHostnames.php +++ b/src/Endpoints/CustomHostnames.php @@ -129,8 +129,7 @@ class CustomHostnames implements API * @param string $customOriginServer * @param bool|null $wildcard * @param string $bundleMethod - * @param string $customKey - * @param string $customCertificate + * @param array $customSsl * @return \stdClass */ public function updateHostname( @@ -142,8 +141,8 @@ class CustomHostnames implements API string $customOriginServer = '', ?bool $wildcard = null, string $bundleMethod = '', - string $customKey = '', - string $customCertificate = ''): \stdClass { + array $customSsl = [] + ): \stdClass { $query = []; if (!empty($sslMethod)) { @@ -166,12 +165,12 @@ class CustomHostnames implements API $query['bundle_method'] = $bundleMethod; } - if (empty($customKey) === false) { - $query['custom_key'] = $customKey; + if (empty($customSsl['key']) === false) { + $query['custom_key'] = $customSsl['key']; } - if (empty($customCertificate) === false) { - $query['custom_certificate'] = $customCertificate; + if (empty($customSsl['certificate']) === false) { + $query['custom_certificate'] = $customSsl['certificate']; } if (!empty($query)) { diff --git a/tests/Endpoints/CustomHostnamesTest.php b/tests/Endpoints/CustomHostnamesTest.php index ad752e6..b542c83 100644 --- a/tests/Endpoints/CustomHostnamesTest.php +++ b/tests/Endpoints/CustomHostnamesTest.php @@ -105,64 +105,11 @@ class CustomHostnamesTest extends TestCase { $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateHostname.json'); + $customSsl = $this->getCustomSsl(); + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); $mock->method('patch')->willReturn($response); - $customKey = <<expects($this->once()) ->method('patch') ->with( @@ -178,8 +125,8 @@ CERTIFICATE; 'min_tls_version' => '1.2' ], 'bundle_method' => 'optimal', - 'custom_key' => $customKey, - 'custom_certificate' => $customCertificate, + 'custom_key' => $customSsl['key'], + 'custom_certificate' => $customSsl['certificate'], 'wildcard' => true, ] @@ -201,8 +148,10 @@ CERTIFICATE; 'origin.example.com', true, 'optimal', - $customKey, - $customCertificate + [ + 'key' => $customSsl['key'], + 'certificate' => $customSsl['certificate'], + ] ); $this->assertObjectHasAttribute('id', $result); @@ -249,4 +198,68 @@ CERTIFICATE; $this->assertObjectHasAttribute('origin', $result); $this->assertObjectHasAttribute('status', $result); } + + private function getCustomSsl(): array + { + $customKey = << $customKey, + 'certificate' => $customCertificate, + ]; + } }