Skip to content

Commit f9dd2ed

Browse files
committed
VideoService API fixes and additional resources
1 parent ef450d5 commit f9dd2ed

File tree

7 files changed

+124
-9
lines changed

7 files changed

+124
-9
lines changed

src/SharePoint/Publishing/VideoChannel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public function getTileHtmlColor(){
3333

3434

3535
/**
36-
* @return VideoChannelCollection
36+
* @return VideoCollection
3737
*/
3838
public function GetAllVideos(){
39-
return new VideoChannelCollection(
39+
return new VideoCollection(
4040
$this->getContext(),
41-
new ResourcePathEntity($this->getContext(),$this->getResourcePath(),"AllVideos")
41+
new ResourcePathEntity($this->getContext(),$this->getResourcePath(),"GetAllVideos")
4242
);
4343
}
4444

src/SharePoint/Publishing/VideoCollection.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,13 @@ public function add($title,$description=null,$fileName=null)
2323
$this->addChild($videoItem);
2424
return $videoItem;
2525
}
26+
27+
28+
/**
29+
* @return string
30+
*/
31+
public function getItemTypeName()
32+
{
33+
return __NAMESPACE__ . "\\" . "VideoItem";
34+
}
2635
}

src/SharePoint/Publishing/VideoItem.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
namespace Office365\PHP\Client\SharePoint\Publishing;
55

66

7+
use Office365\PHP\Client\Runtime\ClientActionDeleteEntity;
8+
use Office365\PHP\Client\Runtime\ClientActionUpdateEntity;
79
use Office365\PHP\Client\Runtime\ClientObject;
810
use Office365\PHP\Client\Runtime\HttpMethod;
911
use Office365\PHP\Client\Runtime\Utilities\RequestOptions;
@@ -13,6 +15,19 @@
1315
class VideoItem extends ClientObject
1416
{
1517

18+
19+
public function update()
20+
{
21+
$qry = new ClientActionUpdateEntity($this);
22+
$this->getContext()->addQuery($qry);
23+
}
24+
25+
public function deleteObject()
26+
{
27+
$qry = new ClientActionDeleteEntity($this);
28+
$this->getContext()->addQuery($qry);
29+
}
30+
1631
public function saveBinaryStream($content){
1732
$ctx = $this->getContext();
1833
$methodName = "GetFile()/SaveBinaryStream";
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
4+
namespace Office365\PHP\Client\SharePoint\Publishing;
5+
6+
7+
use Office365\PHP\Client\Runtime\ClientObject;
8+
9+
class VideoPermissionGroup extends ClientObject
10+
{
11+
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
4+
namespace Office365\PHP\Client\SharePoint\Publishing;
5+
6+
7+
class VideoPlaybackOrigin
8+
{
9+
10+
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
4+
namespace Office365\PHP\Client\SharePoint\Publishing;
5+
6+
7+
class ViewControlState
8+
{
9+
10+
const DefaultState = 0;
11+
12+
const Popular = 1;
13+
14+
const Newest = 2;
15+
16+
const MyVideos = 3;
17+
18+
}

tests/VideoServiceTest.php

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@
99
class VideoServiceTest extends SharePointTestCase
1010
{
1111

12+
/**
13+
* @var $manager VideoServiceManager
14+
*/
15+
protected static $manager;
16+
17+
18+
/**
19+
* @var $targetChannel VideoChannel
20+
*/
21+
protected static $targetChannel;
22+
23+
1224
public function testGetDiscoverer()
1325
{
1426
$discoverer = new VideoServiceDiscoverer(self::$context);
@@ -26,8 +38,8 @@ public function testGetDiscoverer()
2638
*/
2739
public function testEnsureChannel(VideoServiceDiscoverer $discoverer)
2840
{
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();
3143
self::$context->load($channels);
3244
self::$context->executeQuery();
3345

@@ -39,15 +51,15 @@ function (VideoChannel $item) use ($channelName) {
3951
});
4052

4153
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
4355
self::$context->executeQuery();
4456
}
4557
else{
46-
$targetChannel = $result[0];
58+
self::$targetChannel = $result[0];
4759
}
4860

49-
self::assertEquals($targetChannel->getProperty("Title"),$channelName);
50-
return $targetChannel;
61+
self::assertEquals(self::$targetChannel->getProperty("Title"),$channelName);
62+
return self::$targetChannel;
5163
}
5264

5365

@@ -77,7 +89,45 @@ public function testUploadVideo(VideoItem $videoItem)
7789
$filePath = "${parentPath}examples/data/big_buck_bunny.mp4";
7890
$videoContent = file_get_contents($filePath);
7991
$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+
});
80129

130+
self::assertEmpty(count($result));
81131
}
82132

83133

0 commit comments

Comments
 (0)