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+
18+ require_once 'Google/Service/YouTube.php ' ;
19+
20+ class YouTubeTests extends PHPUnit_Framework_TestSuite {
21+ public static function suite () {
22+ $ suite = new PHPUnit_Framework_TestSuite ();
23+ $ suite ->setName ('Google YouTube API tests ' );
24+ $ suite ->addTestSuite ('YouTubeTest ' );
25+ return $ suite ;
26+ }
27+ }
28+
29+ class YouTubeTest extends BaseTest {
30+ /** @var Google_PlusService */
31+ public $ plus ;
32+ public function __construct () {
33+ parent ::__construct ();
34+ $ this ->youtube = new Google_Service_YouTube ($ this ->getClient ());
35+ }
36+
37+ public function testMissingFieldsAreNull () {
38+ $ parts = "id,brandingSettings " ;
39+ $ opts = array ("mine " => true );
40+ $ channels = $ this ->youtube ->channels ->listChannels ($ parts , $ opts );
41+
42+ $ newChannel = new Google_Service_YouTube_Channel ();
43+ $ newChannel ->setId ($ channels [0 ]->getId ());
44+ $ newChannel ->setBrandingSettings ($ channels [0 ]->getBrandingSettings ());
45+
46+ $ simpleOriginal = $ channels [0 ]->toSimpleObject ();
47+ $ simpleNew = $ newChannel ->toSimpleObject ();
48+
49+ $ this ->assertObjectHasAttribute ('etag ' , $ simpleOriginal );
50+ $ this ->assertObjectNotHasAttribute ('etag ' , $ simpleNew );
51+
52+ $ owner_details = new Google_Service_YouTube_ChannelContentOwnerDetails ();
53+ $ owner_details ->setTimeLinked ("123456789 " );
54+ $ o_channel = new Google_Service_YouTube_Channel ();
55+ $ o_channel ->setContentOwnerDetails ($ owner_details );
56+ $ simpleManual = $ o_channel ->toSimpleObject ();
57+ $ this ->assertObjectHasAttribute ('timeLinked ' , $ simpleManual ->contentOwnerDetails );
58+ $ this ->assertObjectNotHasAttribute ('contentOwner ' , $ simpleManual ->contentOwnerDetails );
59+
60+ $ owner_details = new Google_Service_YouTube_ChannelContentOwnerDetails ();
61+ $ owner_details ->timeLinked = "123456789 " ;
62+ $ o_channel = new Google_Service_YouTube_Channel ();
63+ $ o_channel ->setContentOwnerDetails ($ owner_details );
64+ $ simpleManual = $ o_channel ->toSimpleObject ();
65+ $ this ->assertObjectHasAttribute ('timeLinked ' , $ simpleManual ->contentOwnerDetails );
66+ $ this ->assertObjectNotHasAttribute ('contentOwner ' , $ simpleManual ->contentOwnerDetails );
67+
68+ $ owner_details = new Google_Service_YouTube_ChannelContentOwnerDetails ();
69+ $ owner_details ['timeLinked ' ] = "123456789 " ;
70+ $ o_channel = new Google_Service_YouTube_Channel ();
71+ $ o_channel ->setContentOwnerDetails ($ owner_details );
72+ $ simpleManual = $ o_channel ->toSimpleObject ();
73+ $ this ->assertObjectHasAttribute ('timeLinked ' , $ simpleManual ->contentOwnerDetails );
74+ $ this ->assertObjectNotHasAttribute ('contentOwner ' , $ simpleManual ->contentOwnerDetails );
75+
76+ $ ping = new Google_Service_YouTube_ChannelConversionPing ();
77+ $ ping ->setContext ("hello " );
78+ $ pings = new Google_Service_YouTube_ChannelConversionPings ();
79+ $ pings ->setPings (array ($ ping ));
80+ $ simplePings = $ pings ->toSimpleObject ();
81+ $ this ->assertObjectHasAttribute ('context ' , $ simplePings ->pings [0 ]);
82+ $ this ->assertObjectNotHasAttribute ('conversionUrl ' , $ simplePings ->pings [0 ]);
83+ }
84+ }
0 commit comments