summaryrefslogtreecommitdiff
path: root/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/CurlAuth/CurlAuthPluginTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/CurlAuth/CurlAuthPluginTest.php')
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/CurlAuth/CurlAuthPluginTest.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/CurlAuth/CurlAuthPluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/CurlAuth/CurlAuthPluginTest.php
new file mode 100644
index 0000000..2a4b49e
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/CurlAuth/CurlAuthPluginTest.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\CurlAuth;
+
+use Guzzle\Common\Version;
+use Guzzle\Plugin\CurlAuth\CurlAuthPlugin;
+use Guzzle\Http\Client;
+
+/**
+ * @covers Guzzle\Plugin\CurlAuth\CurlAuthPlugin
+ */
+class CurlAuthPluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testAddsBasicAuthentication()
+ {
+ Version::$emitWarnings = false;
+ $plugin = new CurlAuthPlugin('michael', 'test');
+ $client = new Client('http://www.test.com/');
+ $client->getEventDispatcher()->addSubscriber($plugin);
+ $request = $client->get('/');
+ $this->assertEquals('michael', $request->getUsername());
+ $this->assertEquals('test', $request->getPassword());
+ Version::$emitWarnings = true;
+ }
+
+ public function testAddsDigestAuthentication()
+ {
+ Version::$emitWarnings = false;
+ $plugin = new CurlAuthPlugin('julian', 'test', CURLAUTH_DIGEST);
+ $client = new Client('http://www.test.com/');
+ $client->getEventDispatcher()->addSubscriber($plugin);
+ $request = $client->get('/');
+ $this->assertEquals('julian', $request->getUsername());
+ $this->assertEquals('test', $request->getPassword());
+ $this->assertEquals('julian:test', $request->getCurlOptions()->get(CURLOPT_USERPWD));
+ $this->assertEquals(CURLAUTH_DIGEST, $request->getCurlOptions()->get(CURLOPT_HTTPAUTH));
+ Version::$emitWarnings = true;
+ }
+}