YouTubeTest.php 2.6 KB

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