Skip to content

Commit

Permalink
chore: fixing put test
Browse files Browse the repository at this point in the history
  • Loading branch information
tiwarishubham635 committed Jun 14, 2024
1 parent 2aa8e58 commit 5ea05f6
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions tests/Twilio/Unit/Http/CurlClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

/**
Expand Down

0 comments on commit 5ea05f6

Please sign in to comment.