diff options
author | matt <matt@twilio.com> | 2016-08-18 14:29:08 -0700 |
---|---|---|
committer | matt <matt@twilio.com> | 2016-08-18 14:29:08 -0700 |
commit | 3476a559f7f18c01c2e67a8fc3a443433acc1777 (patch) | |
tree | 1c2d2a4bc405a8d77cbbde92fda94a48759b4709 /Twilio/Tests/Unit/Http/CurlClientTest.php | |
parent | 18c61feb86698b123990f01cb260adea9c499ae6 (diff) | |
parent | fe4fe265e4e53df2e1f99f748d2f16287d35bdef (diff) | |
download | twilio-php-5.0.3-alpha1.zip twilio-php-5.0.3-alpha1.tar.gz twilio-php-5.0.3-alpha1.tar.bz2 |
Merge branch 'master' into alpha5.0.3-alpha1
# Conflicts:
# Twilio/VersionInfo.php
Diffstat (limited to 'Twilio/Tests/Unit/Http/CurlClientTest.php')
-rw-r--r-- | Twilio/Tests/Unit/Http/CurlClientTest.php | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/Twilio/Tests/Unit/Http/CurlClientTest.php b/Twilio/Tests/Unit/Http/CurlClientTest.php index b8725e0..2c6c952 100644 --- a/Twilio/Tests/Unit/Http/CurlClientTest.php +++ b/Twilio/Tests/Unit/Http/CurlClientTest.php @@ -229,4 +229,84 @@ class CurlClientTest extends UnitTest { $this->assertEquals('a=1&b=2', fread($actual[CURLOPT_INFILE], $actual[CURLOPT_INFILESIZE])); $this->assertEquals(7, $actual[CURLOPT_INFILESIZE]); } + + /** + * @param string $message Case message, displayed on assertion error + * @param mixed[] $options Options to inject + * @param mixed[] $expected Partial array to expect + * @dataProvider userInjectedOptionsProvider + */ + public function testUserInjectedOptions($message, $options, $expected) { + $client = new CurlClient($options); + $actual = $client->options( + 'GET', + 'url', + array('param-key' => 'param-value'), + array('data-key' => 'data-value'), + array('header-key' => 'header-value'), + 'user', + 'password', + 20 + ); + foreach ($expected as $key => $value) { + $this->assertEquals($value, $actual[$key], $message); + } + } + + public function userInjectedOptionsProvider() { + return array( + array( + 'No Conflict Options', + array( + CURLOPT_VERBOSE => true, + ), + array( + CURLOPT_VERBOSE => true, + ), + ), + array( + 'Options preferred over Defaults', + array( + CURLOPT_TIMEOUT => 1000, + ), + array( + CURLOPT_TIMEOUT => 1000, + ), + ), + array( + 'Required Options can not be injected', + array( + CURLOPT_HTTPGET => false, + ), + array( + CURLOPT_HTTPGET => true, + ), + ), + array( + 'Injected URL decorated with Query String', + array( + CURLOPT_URL => 'user-provided-url', + ), + array( + CURLOPT_URL => 'user-provided-url?param-key=param-value', + ), + ), + array( + 'Injected Headers are additive', + array( + CURLOPT_HTTPHEADER => array( + 'injected-key: injected-value', + ), + ), + array( + CURLOPT_HTTPHEADER => array( + 'injected-key: injected-value', + 'header-key: header-value', + 'Authorization: Basic ' . base64_encode('user:password'), + ), + ), + ), + ); + } + } |