9
9
class VideoServiceTest extends SharePointTestCase
10
10
{
11
11
12
+ /**
13
+ * @var $manager VideoServiceManager
14
+ */
15
+ protected static $ manager ;
16
+
17
+
18
+ /**
19
+ * @var $targetChannel VideoChannel
20
+ */
21
+ protected static $ targetChannel ;
22
+
23
+
12
24
public function testGetDiscoverer ()
13
25
{
14
26
$ discoverer = new VideoServiceDiscoverer (self ::$ context );
@@ -26,8 +38,8 @@ public function testGetDiscoverer()
26
38
*/
27
39
public function testEnsureChannel (VideoServiceDiscoverer $ discoverer )
28
40
{
29
- $ manager = new VideoServiceManager (self ::$ context ,$ discoverer ->getVideoPortalUrl ());
30
- $ channels = $ manager ->getChannels ();
41
+ self :: $ manager = new VideoServiceManager (self ::$ context ,$ discoverer ->getVideoPortalUrl ());
42
+ $ channels = self :: $ manager ->getChannels ();
31
43
self ::$ context ->load ($ channels );
32
44
self ::$ context ->executeQuery ();
33
45
@@ -39,15 +51,15 @@ function (VideoChannel $item) use ($channelName) {
39
51
});
40
52
41
53
if (is_null ($ result )){
42
- $ targetChannel = $ channels ->add ($ channelName ); #oh crap.. not supported by REST service yet
54
+ self :: $ targetChannel = $ channels ->add ($ channelName ); #oh crap.. not supported by REST service yet
43
55
self ::$ context ->executeQuery ();
44
56
}
45
57
else {
46
- $ targetChannel = $ result [0 ];
58
+ self :: $ targetChannel = $ result [0 ];
47
59
}
48
60
49
- self ::assertEquals ($ targetChannel ->getProperty ("Title " ),$ channelName );
50
- return $ targetChannel ;
61
+ self ::assertEquals (self :: $ targetChannel ->getProperty ("Title " ),$ channelName );
62
+ return self :: $ targetChannel ;
51
63
}
52
64
53
65
@@ -77,7 +89,45 @@ public function testUploadVideo(VideoItem $videoItem)
77
89
$ filePath = "$ {parentPath}examples/data/big_buck_bunny.mp4 " ;
78
90
$ videoContent = file_get_contents ($ filePath );
79
91
$ videoItem ->saveBinaryStream ($ videoContent );
92
+ }
93
+
94
+ /**
95
+ * @depends testCreateVideo
96
+ * @param VideoItem $videoItem
97
+ */
98
+ public function testUpdateVideo (VideoItem $ videoItem )
99
+ {
100
+ $ desc = TestUtilities::createUniqueName ("Video sample " );
101
+ $ videoItem ->setProperty ("Description " ,$ desc );
102
+ $ videoItem ->update ();
103
+ self ::$ context ->executeQuery ();
104
+
105
+ $ result = self ::$ targetChannel ->getAllVideos ()->filter ("Description eq ' $ desc' " );
106
+ self ::$ context ->load ($ result );
107
+ self ::$ context ->executeQuery ();
108
+ self ::assertNotEmpty ($ result ->getCount ());
109
+ }
110
+
111
+
112
+ /**
113
+ * @depends testCreateVideo
114
+ * @param VideoItem $videoItem
115
+ */
116
+ public function testDeleteVideo (VideoItem $ videoItem )
117
+ {
118
+ $ videoId = $ videoItem ->getProperty ("ID " );
119
+ $ videoItem ->deleteObject ();
120
+ self ::$ context ->executeQuery ();
121
+
122
+ $ allVideos = self ::$ targetChannel ->getAllVideos ();
123
+ self ::$ context ->load ($ allVideos );
124
+ self ::$ context ->executeQuery ();
125
+ $ result = $ allVideos ->findItems (
126
+ function (VideoItem $ item ) use ($ videoId ) {
127
+ return $ item ->getProperty ("ID " ) === $ videoId ;
128
+ });
80
129
130
+ self ::assertEmpty (count ($ result ));
81
131
}
82
132
83
133
0 commit comments