ClientTest.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Oauth
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. require_once 'Zend/Oauth.php';
  23. require_once 'Zend/Oauth/Config.php';
  24. require_once 'Zend/Oauth/Client.php';
  25. class Test_Oauth_Client extends Zend_Oauth_Client {
  26. public function getSignableParametersAsQueryString()
  27. {
  28. return $this->_getSignableParametersAsQueryString();
  29. }
  30. }
  31. /**
  32. * @category Zend
  33. * @package Zend_Oauth
  34. * @subpackage UnitTests
  35. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. * @group Zend_Oauth
  38. */
  39. class Zend_Oauth_ClientTest extends PHPUnit_Framework_TestCase
  40. {
  41. public function setUp()
  42. {
  43. $this->client = new Zend_Oauth_Client(array());
  44. }
  45. /**
  46. * @group ZF-12488
  47. */
  48. public function testAllowsOptionsAsRequestMethod()
  49. {
  50. $this->client->setRequestMethod(Zend_Oauth_Client::OPTIONS);
  51. $this->assertEquals(Zend_Oauth_Client::OPTIONS, $this->client->getRequestMethod());
  52. }
  53. /**
  54. * zendframework / zf1 # 244
  55. */
  56. public function testIncludesParametersForSignatureOnPostEncUrlEncoded()
  57. {
  58. $client = new Test_Oauth_Client(array());
  59. $client->setEncType(Zend_Http_Client::ENC_URLENCODED);
  60. $params = array(
  61. 'param1' => 'dummy1',
  62. 'param2' => 'dummy2',
  63. );
  64. $client->setParameterPost($params);
  65. $client->setMethod(Zend_Http_Client::POST);
  66. $this->assertEquals(2, count($client->getSignableParametersAsQueryString()));
  67. }
  68. /**
  69. * zendframework / zf1 # 244
  70. */
  71. public function testExcludesParametersOnPostEncFormData()
  72. {
  73. $client = new Test_Oauth_Client(array());
  74. $client->setEncType(Zend_Http_Client::ENC_FORMDATA);
  75. $params = array(
  76. 'param1' => 'dummy1',
  77. 'param2' => 'dummy2',
  78. );
  79. $client->setParameterPost($params);
  80. $client->setMethod(Zend_Http_Client::POST);
  81. $this->assertEquals(0, count($client->getSignableParametersAsQueryString()));
  82. }
  83. }