YouTubeTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_Gdata_YouTube
  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 'TestHelper.php';
  23. require_once 'Zend/Gdata/YouTube.php';
  24. require_once 'Zend/Http/Client.php';
  25. /**
  26. * @category Zend
  27. * @package Zend_Gdata_YouTube
  28. * @subpackage UnitTests
  29. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. * @group Zend_Gdata
  32. * @group Zend_Gdata_YouTube
  33. */
  34. class Zend_Gdata_YouTubeTest extends PHPUnit_Framework_TestCase
  35. {
  36. public function setUp()
  37. {
  38. // These tests shouldn't be doing anything online, so we can use
  39. // bogus authentication credentials.
  40. $this->gdata = new Zend_Gdata_YouTube(null);
  41. $this->responseText = file_get_contents(
  42. 'Zend/Gdata/YouTube/_files/FormUploadTokenResponseSample.xml',
  43. true);
  44. }
  45. public function testGetFormUploadTokenResponseHandler()
  46. {
  47. $responseArray = Zend_Gdata_YouTube::parseFormUploadTokenResponse($this->responseText);
  48. $this->assertEquals('https://uploads.gdata.youtube.com/action/FormDataUpload/AIwbF1_JjEQ9cGTjEAd5FKwV42SeNWJexmc5y7XR-eFj24uqbqU6NRcxKJW_4R-sYISLxQ',
  49. $responseArray['url']);
  50. $this->assertEquals('AIwbFAQ21fImpR2iYPaFnfuCvfbCB3qBxl5qXiZlpH3lfkungiSPoyw1iOM1gFB6Nx-wmY-kjprNT3qtdp7LJCLfngn11Ne_X9Jd44Vz8AzygtEtaDGyib5tnri0O0-V5pwcAPCHIJurOMsOpA2zInW8V8qHk2S2LheXfTXVbqc0Li9iCBpsoBGbykYU0moNoyGAaKRbSBD0oPnCv6v9Rll5Zjvivi2hQt-Br2JDb9wVeLv3qyAFaeyN6X6k32RyaAHs_n8d8d_oSriQmvS8g1HxSCS4dnoGL7tafQ4SBqnrQEb-hxFeu1ZrAwCLv',
  51. $responseArray['token']);
  52. }
  53. public function testSetClientIDAndDeveloperKeyHeader()
  54. {
  55. $applicationId = 'MyTestCompany-MyTestApp-0.1';
  56. $clientId = 'MyClientId';
  57. $developerKey = 'MyDeveloperKey';
  58. $httpClient = new Zend_Http_Client();
  59. $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
  60. $this->assertTrue($yt instanceOf Zend_Gdata_YouTube);
  61. $client = $yt->getHttpClient();
  62. $this->assertEquals($client->getHeader('X-Gdata-Key'), 'key='. $developerKey);
  63. $this->assertEquals($client->getHeader('X-Gdata-Client'), $clientId);
  64. }
  65. }