public function testSynchronizeMissingInWowza() { $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('_fetchStatus')); $json = $this->_generateWowzaData(array()); $wowza->expects($this->any())->method('_fetchStatus')->will($this->returnValue($json)); /** @var $wowza CM_Stream_Video */ $wowza->synchronize(); $this->assertEquals($streamChannel, CM_Model_StreamChannel_Abstract::findByKeyAndAdapter($streamChannel->getKey(), $wowza->getType())); $this->assertEquals($streamPublish, CM_Model_Stream_Publish::findByKeyAndChannel($streamPublish->getKey(), $streamChannel)); $this->assertEquals($streamSubscribe, CM_Model_Stream_Subscribe::findByKeyAndChannel($streamSubscribe->getKey(), $streamChannel)); CMTest_TH::timeForward(5); $wowza->synchronize(); $this->assertNull(CM_Model_StreamChannel_Abstract::findByKeyAndAdapter($streamChannel->getKey(), $wowza->getType())); $this->assertNull(CM_Model_Stream_Publish::findByKeyAndChannel($streamPublish->getKey(), $streamChannel)); $this->assertNull(CM_Model_Stream_Subscribe::findByKeyAndChannel($streamSubscribe->getKey(), $streamChannel)); }
public function testFindKeyNonexistent() { $streamChannel = CMTest_TH::createStreamChannel(); $videoStreamPublish = CM_Model_Stream_Publish::findByKeyAndChannel('doesnotexist', $streamChannel); $this->assertNull($videoStreamPublish); }
public function testSynchronizeMissingInJanus() { $streamChannel = CMTest_TH::createStreamChannel(null, CM_Janus_Service::getTypeStatic()); $streamPublish = CMTest_TH::createStreamPublish(null, $streamChannel); $streamSubscribe = CMTest_TH::createStreamSubscribe(null, $streamChannel); $existingStreamChannel = CMTest_TH::createStreamChannel(null, CM_Janus_Service::getTypeStatic()); $existingStreamPublish = CMTest_TH::createStreamPublish(null, $existingStreamChannel); $existingStreamSubscribe = CMTest_TH::createStreamSubscribe(null, $existingStreamChannel); $emptyStreamChannel = CMTest_TH::createStreamChannel(null, CM_Janus_Service::getTypeStatic()); $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]); /** @var CM_Janus_HttpApiClient|\Mocka\AbstractClassTrait $httpApiClient */ $httpApiClient = $this->mockClass('CM_Janus_HttpApiClient')->newInstanceWithoutConstructor(); $httpApiClient->mockMethod('fetchStatus')->set([['id' => $existingStreamPublish->getKey(), 'channelName' => $existingStreamChannel->getKey(), 'isPublish' => true], ['id' => $existingStreamSubscribe->getKey(), 'channelName' => $existingStreamChannel->getKey(), 'isPublish' => false]]); $janus = new CM_Janus_Service($serverList, $httpApiClient); $janus->synchronize(); $this->assertEquals($streamChannel, CM_Model_StreamChannel_Abstract::findByKeyAndAdapter($streamChannel->getKey(), $janus->getType())); $this->assertEquals($streamPublish, CM_Model_Stream_Publish::findByKeyAndChannel($streamPublish->getKey(), $streamChannel)); $this->assertEquals($streamSubscribe, CM_Model_Stream_Subscribe::findByKeyAndChannel($streamSubscribe->getKey(), $streamChannel)); $this->assertEquals($existingStreamChannel, CM_Model_StreamChannel_Abstract::findByKeyAndAdapter($existingStreamChannel->getKey(), $janus->getType())); $this->assertEquals($existingStreamPublish, CM_Model_Stream_Publish::findByKeyAndChannel($existingStreamPublish->getKey(), $existingStreamChannel)); $this->assertEquals($existingStreamSubscribe, CM_Model_Stream_Subscribe::findByKeyAndChannel($existingStreamSubscribe->getKey(), $existingStreamChannel)); $this->assertNull(CM_Model_StreamChannel_Abstract::findByKeyAndAdapter($emptyStreamChannel->getKey(), $janus->getType())); CMTest_TH::timeForward(5); $janus->synchronize(); $this->assertNull(CM_Model_StreamChannel_Abstract::findByKeyAndAdapter($streamChannel->getKey(), $janus->getType())); $this->assertNull(CM_Model_Stream_Publish::findByKeyAndChannel($streamPublish->getKey(), $streamChannel)); $this->assertNull(CM_Model_Stream_Subscribe::findByKeyAndChannel($streamSubscribe->getKey(), $streamChannel)); $this->assertEquals($existingStreamChannel, CM_Model_StreamChannel_Abstract::findByKeyAndAdapter($existingStreamChannel->getKey(), $janus->getType())); $this->assertEquals($existingStreamPublish, CM_Model_Stream_Publish::findByKeyAndChannel($existingStreamPublish->getKey(), $existingStreamChannel)); $this->assertEquals($existingStreamSubscribe, CM_Model_Stream_Subscribe::findByKeyAndChannel($existingStreamSubscribe->getKey(), $existingStreamChannel)); }