Quellcode durchsuchen

[ZF-12488] Merge r25166 to release-1.12

git-svn-id: http://framework.zend.com/svn/framework/standard/branches/release-1.12@25167 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew vor 13 Jahren
Ursprung
Commit
7469a7296a

+ 1 - 0
library/Zend/Oauth.php

@@ -38,6 +38,7 @@ class Zend_Oauth
     const PUT                        = 'PUT';
     const DELETE                     = 'DELETE';
     const HEAD                       = 'HEAD';
+    const OPTIONS                    = 'OPTIONS';
 
     /**
      * Singleton instance if required of the HTTP client

+ 4 - 2
library/Zend/Oauth/Client.php

@@ -196,10 +196,12 @@ class Zend_Oauth_Client extends Zend_Http_Client
             $this->setRequestMethod(self::POST);
         } elseif($method == self::PUT) {
             $this->setRequestMethod(self::PUT);
-        }  elseif($method == self::DELETE) {
+        } elseif($method == self::DELETE) {
             $this->setRequestMethod(self::DELETE);
-        }   elseif($method == self::HEAD) {
+        } elseif($method == self::HEAD) {
             $this->setRequestMethod(self::HEAD);
+        } elseif($method == self::OPTIONS) {
+            $this->setRequestMethod(self::OPTIONS);
         }
         return parent::setMethod($method);
     }

+ 1 - 0
library/Zend/Oauth/Config.php

@@ -581,6 +581,7 @@ class Zend_Oauth_Config implements Zend_Oauth_Config_ConfigInterface
                 Zend_Oauth::POST,
                 Zend_Oauth::PUT,
                 Zend_Oauth::DELETE,
+                Zend_Oauth::OPTIONS,
             ))
         ) {
             require_once 'Zend/Oauth/Exception.php';

+ 4 - 0
tests/Zend/Oauth/AllTests.php

@@ -25,6 +25,8 @@ if (!defined('PHPUnit_MAIN_METHOD')) {
 }
 
 require_once 'OauthTest.php';
+require_once 'ClientTest.php';
+require_once 'ConfigTest.php';
 require_once 'Oauth/ConsumerTest.php';
 require_once 'Oauth/Signature/AbstractTest.php';
 require_once 'Oauth/Signature/PlaintextTest.php';
@@ -58,6 +60,8 @@ class Zend_Oauth_AllTests
         $suite = new PHPUnit_Framework_TestSuite('Zend Framework - Zend_Oauth');
 
         $suite->addTestSuite('Zend_OauthTest');
+        $suite->addTestSuite('Zend_Oauth_ClientTest');
+        $suite->addTestSuite('Zend_Oauth_ConfigTest');
         $suite->addTestSuite('Zend_Oauth_ConsumerTest');
         $suite->addTestSuite('Zend_Oauth_Signature_AbstractTest');
         $suite->addTestSuite('Zend_Oauth_Signature_PlaintextTest');

+ 49 - 0
tests/Zend/Oauth/ClientTest.php

@@ -0,0 +1,49 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Oauth
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+require_once 'Zend/Oauth.php';
+require_once 'Zend/Oauth/Config.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Oauth
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @group      Zend_Oauth
+ */
+class Zend_Oauth_ClientTest extends PHPUnit_Framework_TestCase
+{
+    public function setUp()
+    {
+        $this->client = new Zend_Oauth_Client(array());
+    }
+
+    /**
+     * @group ZF-12488
+     */
+    public function testAllowsOptionsAsRequestMethod()
+    {
+        $this->client->setRequestMethod(Zend_Oauth_Client::OPTIONS);
+        $this->assertEquals(Zend_Oauth_Client::OPTIONS, $this->client->getRequestMethod());
+    }
+}

+ 49 - 0
tests/Zend/Oauth/ConfigTest.php

@@ -0,0 +1,49 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Oauth
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+require_once 'Zend/Oauth.php';
+require_once 'Zend/Oauth/Config.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Oauth
+ * @subpackage UnitTests
+ * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @group      Zend_Oauth
+ */
+class Zend_Oauth_ConfigTest extends PHPUnit_Framework_TestCase
+{
+    public function setUp()
+    {
+        $this->config = new Zend_Oauth_Config();
+    }
+
+    /**
+     * @group ZF-12488
+     */
+    public function testAllowsOptionsAsRequestMethod()
+    {
+        $this->config->setRequestMethod(Zend_Oauth::OPTIONS);
+        $this->assertEquals(Zend_Oauth::OPTIONS, $this->config->getRequestMethod());
+    }
+}