| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?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/Token/Request.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
- * @group Zend_Oauth_Token
- */
- class Zend_Oauth_Token_RequestTest extends PHPUnit_Framework_TestCase
- {
- public function testConstructorSetsResponseObject()
- {
- $response = new Zend_Http_Response(200, array());
- $token = new Zend_Oauth_Token_Request($response);
- $this->assertTrue($token->getResponse() instanceof Zend_Http_Response);
- }
- public function testConstructorParsesRequestTokenFromResponseBody()
- {
- $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri';
- $response = new Zend_Http_Response(200, array(), $body);
- $token = new Zend_Oauth_Token_Request($response);
- $this->assertEquals('jZaee4GF52O3lUb9', $token->getToken());
- }
- public function testConstructorParsesRequestTokenSecretFromResponseBody()
- {
- $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri';
- $response = new Zend_Http_Response(200, array(), $body);
- $token = new Zend_Oauth_Token_Request($response);
- $this->assertEquals('J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri', $token->getTokenSecret());
- }
- public function testPropertyAccessWorks()
- {
- $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri&foo=bar';
- $response = new Zend_Http_Response(200, array(), $body);
- $token = new Zend_Oauth_Token_Request($response);
- $this->assertEquals('J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri', $token->oauth_token_secret);
- }
- public function testTokenCastsToEncodedResponseBody()
- {
- $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri';
- $token = new Zend_Oauth_Token_Request();
- $token->setToken('jZaee4GF52O3lUb9');
- $token->setTokenSecret('J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri');
- $this->assertEquals($body, (string) $token);
- }
- public function testToStringReturnsEncodedResponseBody()
- {
- $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri';
- $token = new Zend_Oauth_Token_Request();
- $token->setToken('jZaee4GF52O3lUb9');
- $token->setTokenSecret('J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri');
- $this->assertEquals($body, $token->toString());
- }
- public function testIsValidDetectsBadResponse()
- {
- $body = 'oauthtoken=jZaee4GF52O3lUb9&oauthtokensecret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri';
- $response = new Zend_Http_Response(200, array(), $body);
- $token = new Zend_Oauth_Token_Request($response);
- $this->assertFalse($token->isValid());
- }
- public function testIsValidDetectsGoodResponse()
- {
- $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri';
- $response = new Zend_Http_Response(200, array(), $body);
- $token = new Zend_Oauth_Token_Request($response);
- $this->assertTrue($token->isValid());
- }
- }
|