YouTubeTest.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. * Copyright 2011 Google Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. class YouTubeTest extends BaseTest
  18. {
  19. /** @var Google_PlusService */
  20. public $plus;
  21. public function __construct()
  22. {
  23. parent::__construct();
  24. $this->youtube = new Google_Service_YouTube($this->getClient());
  25. }
  26. public function testMissingFieldsAreNull()
  27. {
  28. if (!$this->checkToken()) {
  29. return;
  30. }
  31. $parts = "id,brandingSettings";
  32. $opts = array("mine" => true);
  33. $channels = $this->youtube->channels->listChannels($parts, $opts);
  34. $newChannel = new Google_Service_YouTube_Channel();
  35. $newChannel->setId($channels[0]->getId());
  36. $newChannel->setBrandingSettings($channels[0]->getBrandingSettings());
  37. $simpleOriginal = $channels[0]->toSimpleObject();
  38. $simpleNew = $newChannel->toSimpleObject();
  39. $this->assertObjectHasAttribute('etag', $simpleOriginal);
  40. $this->assertObjectNotHasAttribute('etag', $simpleNew);
  41. $owner_details = new Google_Service_YouTube_ChannelContentOwnerDetails();
  42. $owner_details->setTimeLinked("123456789");
  43. $o_channel = new Google_Service_YouTube_Channel();
  44. $o_channel->setContentOwnerDetails($owner_details);
  45. $simpleManual = $o_channel->toSimpleObject();
  46. $this->assertObjectHasAttribute('timeLinked', $simpleManual->contentOwnerDetails);
  47. $this->assertObjectNotHasAttribute('contentOwner', $simpleManual->contentOwnerDetails);
  48. $owner_details = new Google_Service_YouTube_ChannelContentOwnerDetails();
  49. $owner_details->timeLinked = "123456789";
  50. $o_channel = new Google_Service_YouTube_Channel();
  51. $o_channel->setContentOwnerDetails($owner_details);
  52. $simpleManual = $o_channel->toSimpleObject();
  53. $this->assertObjectHasAttribute('timeLinked', $simpleManual->contentOwnerDetails);
  54. $this->assertObjectNotHasAttribute('contentOwner', $simpleManual->contentOwnerDetails);
  55. $owner_details = new Google_Service_YouTube_ChannelContentOwnerDetails();
  56. $owner_details['timeLinked'] = "123456789";
  57. $o_channel = new Google_Service_YouTube_Channel();
  58. $o_channel->setContentOwnerDetails($owner_details);
  59. $simpleManual = $o_channel->toSimpleObject();
  60. $this->assertObjectHasAttribute('timeLinked', $simpleManual->contentOwnerDetails);
  61. $this->assertObjectNotHasAttribute('contentOwner', $simpleManual->contentOwnerDetails);
  62. $ping = new Google_Service_YouTube_ChannelConversionPing();
  63. $ping->setContext("hello");
  64. $pings = new Google_Service_YouTube_ChannelConversionPings();
  65. $pings->setPings(array($ping));
  66. $simplePings = $pings->toSimpleObject();
  67. $this->assertObjectHasAttribute('context', $simplePings->pings[0]);
  68. $this->assertObjectNotHasAttribute('conversionUrl', $simplePings->pings[0]);
  69. }
  70. }