public function testHasStreamPublish() { /** @var CM_Model_StreamChannel_Media $streamChannel */ $streamChannel = CMTest_TH::createStreamChannel(); $this->assertFalse($streamChannel->hasStreamPublish()); CMTest_TH::createStreamPublish(null, $streamChannel); $this->assertTrue($streamChannel->hasStreamPublish()); }
public function testPaging() { $user = CMTest_TH::createUser(); $streamChannel = CMTest_TH::createStreamChannel(); CMTest_TH::createStreamPublish($user, $streamChannel); $streams = new CM_Paging_StreamPublish_User($user); $this->assertEquals(1, $streams->getCount()); $user->delete(); $streams = new CM_Paging_StreamPublish_User($user); $this->assertEquals(0, $streams->getCount()); }
public function testPaging() { $streamChannel = CMTest_TH::createStreamChannel(); $paging = new CM_Paging_FileUserContent_StreamChannelVideoThumbnails($streamChannel); $this->assertSame(0, $paging->getCount()); $this->assertSame(array(), $paging->getItems()); /** @var CM_Model_StreamChannel_Video $streamChannel */ $streamChannel = CMTest_TH::createStreamChannel(); CMTest_TH::createStreamPublish(null, $streamChannel); $streamChannel->setThumbnailCount(4); $paging = new CM_Paging_FileUserContent_StreamChannelVideoThumbnails($streamChannel); $this->assertSame(4, $paging->getCount()); $filename = $streamChannel->getId() . '-' . $streamChannel->getHash() . '-thumbs/1.png'; $this->assertEquals(new CM_File_UserContent('streamChannels', $filename, $streamChannel->getId()), $paging->getItem(0)); }
public function testSynchronizeMissingInPhp() { /** @var CM_Model_StreamChannel_Video $streamChannel */ $streamChannel = CMTest_TH::createStreamChannel(); $streamPublish = CMTest_TH::createStreamPublish(null, $streamChannel); $streamSubscribe = CMTest_TH::createStreamSubscribe(null, $streamChannel); $wowza = $this->getMock('CM_Stream_Adapter_Video_Wowza', array('_stopClient', '_fetchStatus')); $json = $this->_generateWowzaData(array($streamChannel)); $wowza->expects($this->any())->method('_fetchStatus')->will($this->returnValue($json)); $wowza->expects($this->at(1))->method('_stopClient')->with($streamPublish->getKey(), $streamChannel->getPrivateHost()); $wowza->expects($this->at(2))->method('_stopClient')->with($streamSubscribe->getKey(), $streamChannel->getPrivateHost()); $wowza->expects($this->exactly(2))->method('_stopClient'); /** @var $wowza CM_Stream_Adapter_Video_Wowza */ $wowza->unpublish($streamChannel->getKey()); $wowza->unsubscribe($streamChannel->getKey(), $streamSubscribe->getKey()); $wowza->synchronize(); }
public function testGetThumbnail() { /** @var CM_Model_StreamChannel_Video $streamChannel */ $streamChannel = CMTest_TH::createStreamChannel(); CMTest_TH::createStreamPublish(null, $streamChannel); $thumbnail = $streamChannel->getThumbnail(3); $this->assertInstanceOf('CM_File_UserContent', $thumbnail); $this->assertSame('streamChannels/' . $streamChannel->getId() . '/' . $streamChannel->getId() . '-' . $streamChannel->getHash() . '-thumbs/3.png', $thumbnail->getPathRelative()); }
/** * @expectedException CM_Exception_Invalid * @expectedExceptionMessage Cannot delete streamChannel with existing streams */ public function testDeleteWithPublishs() { /** @var CM_Model_StreamChannel_Mock $streamChannel */ $streamChannel = CMTest_TH::createStreamChannel(); CMTest_TH::createStreamPublish(null, $streamChannel); $streamChannel->delete(); }
public function testGetChannel() { $streamChannel = CMTest_TH::createStreamChannel(); $streamPublish = CMTest_TH::createStreamPublish(null, $streamChannel); $this->assertEquals($streamChannel, $streamPublish->getStreamChannel()); }
public function testSynchronizeMissingInPhp() { $streamChannel = CMTest_TH::createStreamChannel(null, CM_Janus_Service::getTypeStatic()); $streamChannelKey = $streamChannel->getKey(); $streamPublish = CMTest_TH::createStreamPublish(null, $streamChannel); $streamPublishKey = $streamPublish->getKey(); $streamSubscribe = CMTest_TH::createStreamSubscribe(null, $streamChannel); $streamSubscribeKey = $streamSubscribe->getKey(); $streamChannel2 = CMTest_TH::createStreamChannel(null, CM_Janus_Service::getTypeStatic()); $streamChannelKey2 = $streamChannel2->getKey(); CMTest_TH::createStreamPublish(null, $streamChannel2); //to make channel non empty $location = $this->mockClass('CM_Geo_Point')->newInstanceWithoutConstructor(); $server1 = $this->mockClass('CM_Janus_Server')->newInstance([1, 'key', 'http://mock', 'ws://mock', [], $location]); /** @var CM_Janus_ServerList|\Mocka\AbstractClassTrait $serverList */ $serverList = $this->mockObject('CM_Janus_ServerList'); $serverList->mockMethod('getAll')->set([$server1]); $status = [['id' => $streamPublishKey, 'channelName' => $streamChannelKey, 'isPublish' => true], ['id' => $streamSubscribeKey, 'channelName' => $streamChannelKey, 'isPublish' => false], ['id' => 'absentStreamKey', 'channelName' => 'absentChannelKey', 'isPublish' => false], ['id' => 'absentStreamKey2', 'channelName' => $streamChannelKey2, 'isPublish' => true]]; $httpApiClient = $this->mockClass('CM_Janus_HttpApiClient')->newInstanceWithoutConstructor(); $httpApiClient->mockMethod('fetchStatus')->set(function (CM_Janus_Server $passedServer) use($server1, $status) { $this->assertSame($server1, $passedServer); return $status; }); $stopStreamMethod = $httpApiClient->mockMethod('stopStream')->at(0, function ($server, $streamKey) use($streamPublishKey, $server1) { $this->assertEquals($server1, $server); $this->assertSame($streamPublishKey, $streamKey); })->at(1, function ($server, $streamKey) use($streamSubscribeKey, $server1) { $this->assertEquals($server1, $server); $this->assertSame($streamSubscribeKey, $streamKey); })->at(2, function ($server, $streamKey) use($server1) { $this->assertEquals($server1, $server); $this->assertSame('absentStreamKey', $streamKey); })->at(3, function ($server, $streamKey) use($server1) { $this->assertEquals($server1, $server); $this->assertSame('absentStreamKey2', $streamKey); }); /** @var CM_Janus_HttpApiClient $httpApiClient */ $janus = new CM_Janus_Service($serverList, $httpApiClient); $janus->getStreamRepository()->removeStream($streamPublish); $janus->getStreamRepository()->removeStream($streamSubscribe); $janus->synchronize(); $this->assertSame(4, $stopStreamMethod->getCallCount()); }
public function testFindById() { $streamChannel = $streamChannel = CMTest_TH::createStreamChannel(); $this->assertNull(CM_Model_StreamChannelArchive_Video::findById($streamChannel->getId())); CMTest_TH::createStreamPublish(null, $streamChannel); CM_Model_StreamChannelArchive_Video::createStatic(array('streamChannel' => $streamChannel)); $this->assertInstanceOf('CM_Model_StreamChannelArchive_Video', CM_Model_StreamChannelArchive_Video::findById($streamChannel->getId())); }