本文整理汇总了PHP中CMTest_TH::createStreamSubscribe方法的典型用法代码示例。如果您正苦于以下问题:PHP CMTest_TH::createStreamSubscribe方法的具体用法?PHP CMTest_TH::createStreamSubscribe怎么用?PHP CMTest_TH::createStreamSubscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMTest_TH
的用法示例。
在下文中一共展示了CMTest_TH::createStreamSubscribe方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOnSubscribe
public function testOnSubscribe()
{
$user = CMTest_TH::createUser();
/** @var CM_Model_StreamChannel_Message_User $channel */
$channel = CM_Model_StreamChannel_Message_User::createStatic(['key' => CM_Model_StreamChannel_Message_User::getKeyByUser($user), 'adapterType' => CM_MessageStream_Adapter_SocketRedis::getTypeStatic()]);
$this->assertSame(false, $user->getOnline());
$subscribe = CMTest_TH::createStreamSubscribe($user, $channel);
CMTest_TH::reinstantiateModel($user);
$this->assertSame(true, $user->getOnline());
}
示例2: testPaging
public function testPaging()
{
$user = CMTest_TH::createUser();
$streamChannel = CMTest_TH::createStreamChannel();
CMTest_TH::createStreamSubscribe($user, $streamChannel);
$streams = new CM_Paging_StreamSubscribe_User($user);
$this->assertEquals(1, $streams->getCount());
$user->delete();
$streams = new CM_Paging_StreamSubscribe_User($user);
$this->assertEquals(0, $streams->getCount());
}
示例3: testPaging
public function testPaging()
{
$usersExpected = array(CMTest_TH::createUser(), CMTest_TH::createUser(), CMTest_TH::createUser());
$streamChannel = CMTest_TH::createStreamChannel();
foreach ($usersExpected as $user) {
CMTest_TH::createStreamSubscribe($user, $streamChannel);
}
CMTest_TH::createStreamSubscribe(null, $streamChannel);
CMTest_TH::createStreamSubscribe(null, $streamChannel);
$usersActual = new CM_Paging_User_StreamChannelSubscriber($streamChannel);
$this->assertEquals(3, $usersActual->getCount());
foreach ($usersExpected as $user) {
$this->assertContains($user, $usersActual);
}
}
示例4: testSynchronizeMissingInPhp
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();
}
示例5: testGetChannel
public function testGetChannel()
{
$streamChannel = CMTest_TH::createStreamChannel();
$streamPublish = CMTest_TH::createStreamSubscribe(CMTest_TH::createUser(), $streamChannel);
$this->assertEquals($streamChannel, $streamPublish->getStreamChannel());
}
示例6: testSynchronizeMissingInPhp
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());
}