From 5ea05f6c29caeee6dcd4deba7f3e0fbf6acbd838 Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Fri, 14 Jun 2024 15:35:00 +0530 Subject: [PATCH] chore: fixing put test --- tests/Twilio/Unit/Http/CurlClientTest.php | 24 ++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tests/Twilio/Unit/Http/CurlClientTest.php b/tests/Twilio/Unit/Http/CurlClientTest.php index 48361f997..df4205d32 100644 --- a/tests/Twilio/Unit/Http/CurlClientTest.php +++ b/tests/Twilio/Unit/Http/CurlClientTest.php @@ -248,12 +248,26 @@ public function postFieldsProvider(): array { ]; } - public function testPutFile(): void { + /** + * @param array|string $params Parameters to put + * @param array|string $data Data to put + * @param string $expectedContentType Excpected Content-Type header + * @param string $expectedBody Expected POSTFIELDS + * @dataProvider postFieldsProvider + * @throws \Twilio\Exceptions\EnvironmentException + */ + public function testPutFile($params, $data, string $expectedContentType, string $expectedBody): void { $client = new CurlClient(); - $actual = $client->options('PUT', 'url', [], ['a' => 1, 'b' => 2]); - $this->assertNotNull($actual[CURLOPT_INFILE]); - $this->assertEquals('a=1&b=2', \fread($actual[CURLOPT_INFILE], $actual[CURLOPT_INFILESIZE])); - $this->assertEquals(7, $actual[CURLOPT_INFILESIZE]); + $actual = $client->options('PUT', 'url', $params, $data); + + foreach ($actual[CURLOPT_HTTPHEADER] as $header) { + if (strpos($header, 'Content-Type: ') === 0) { + $this->assertStringMatchesFormat($expectedContentType, substr($header, 14)); + break; + } + } + + $this->assertStringMatchesFormat($expectedBody, $actual[CURLOPT_POSTFIELDS]); } /**