コード例 #1
0
 public function testCreateStreamChannel()
 {
     $repository = new CM_MediaStreams_StreamRepository(1);
     $mediaId = '444-bar';
     $channel = $repository->createStreamChannel('foo', CM_Model_StreamChannel_Media::getTypeStatic(), 2, $mediaId);
     $this->assertInstanceOf('CM_Model_StreamChannel_Media', $channel);
     CM_Model_StreamChannelArchive_Media::createStatic(['streamChannel' => $channel]);
     $exception = $this->catchException(function () use($repository, $mediaId) {
         $repository->createStreamChannel('bar', CM_Model_StreamChannel_Media::getTypeStatic(), 2, $mediaId);
     });
     $this->assertInstanceOf('CM_Exception_Invalid', $exception);
     /** @var CM_Exception_Invalid $exception */
     $this->assertSame('Channel archive with this mediaId already exists', $exception->getMessage());
     $this->assertSame(['mediaId' => $mediaId], $exception->getMetaInfo());
 }
コード例 #2
0
ファイル: TypeTest.php プロジェクト: cargomedia/cm
 public function testPaging()
 {
     CMTest_TH::createStreamChannelVideoArchive();
     $archive = CMTest_TH::createStreamChannelVideoArchive();
     CMTest_TH::timeForward(30);
     CMTest_TH::createStreamChannelVideoArchive();
     /** @var CM_Model_StreamChannel_Media $streamChannel */
     $streamChannel = CMTest_TH::createStreamChannel();
     $mockBuilder = $this->getMockBuilder('CM_Model_StreamChannel_Media');
     $mockBuilder->setMethods(['getType']);
     $mockBuilder->setConstructorArgs([$streamChannel->getId()]);
     $streamChannelMock = $mockBuilder->getMock();
     $streamChannelMock->expects($this->any())->method('getType')->will($this->returnValue(3));
     CMTest_TH::createStreamChannelVideoArchive($streamChannelMock);
     $paging = new CM_Paging_StreamChannelArchiveMedia_Type(CM_Model_StreamChannel_Media::getTypeStatic());
     $this->assertSame(3, $paging->getCount());
     $paging = new CM_Paging_StreamChannelArchiveMedia_Type($streamChannelMock->getType());
     $this->assertSame(1, $paging->getCount());
     $paging = new CM_Paging_StreamChannelArchiveMedia_Type(CM_Model_StreamChannel_Media::getTypeStatic(), $archive->getCreated());
     $this->assertSame(2, $paging->getCount());
 }
コード例 #3
0
ファイル: ParamsTest.php プロジェクト: cargomedia/cm
 public function testGetStreamChannelMedia()
 {
     $streamChannel = CMTest_TH::createStreamChannel(CM_Model_StreamChannel_Media::getTypeStatic());
     $params = new CM_Params(['channel' => $streamChannel]);
     $this->assertEquals($streamChannel, $params->getStreamChannelMedia('channel'));
 }
コード例 #4
0
ファイル: TH.php プロジェクト: cargomedia/cm
 /**
  * @param int|null    $type
  * @param int|null    $adapterType
  * @param string|null $mediaId
  * @return CM_Model_StreamChannel_Abstract
  */
 public static function createStreamChannel($type = null, $adapterType = null, $mediaId = null)
 {
     if (null === $type) {
         $type = CM_Model_StreamChannel_Media::getTypeStatic();
     }
     if (null === $adapterType) {
         $adapterType = CM_Janus_Service::getTypeStatic();
     }
     $data = array('key' => rand(1, 10000) . '_' . rand(1, 100));
     $className = CM_Model_Abstract::getClassName($type);
     if ('CM_Model_StreamChannel_Media' === $className || is_subclass_of($className, 'CM_Model_StreamChannel_Media')) {
         $mediaId = null !== $mediaId ? (string) $mediaId : null;
         $data['width'] = 480;
         $data['height'] = 720;
         $data['serverId'] = 1;
         $data['adapterType'] = $adapterType;
         $data['mediaId'] = $mediaId;
     }
     return CM_Model_StreamChannel_Abstract::createType($type, $data);
 }
コード例 #5
0
ファイル: MediaTest.php プロジェクト: cargomedia/cm
 public function testDeleteOlder()
 {
     $archivesDeleted = [];
     $archivesNotDeleted = [];
     for ($i = 0; $i < 2; $i++) {
         $archive = CMTest_TH::createStreamChannelVideoArchive();
         $archivesDeleted[] = $archive;
     }
     $streamChannel = CMTest_TH::createStreamChannel();
     $mockBuilder = $this->getMockBuilder('CM_Model_StreamChannel_Media');
     $mockBuilder->setMethods(['getType']);
     $mockBuilder->setConstructorArgs([$streamChannel->getId()]);
     $streamChannelMock = $mockBuilder->getMock();
     $streamChannelMock->expects($this->any())->method('getType')->will($this->returnValue(3));
     $archive = CMTest_TH::createStreamChannelVideoArchive($streamChannelMock);
     $archivesNotDeleted[] = $archive;
     CMTest_TH::timeForward(20);
     for ($i = 0; $i < 3; $i++) {
         $archive = CMTest_TH::createStreamChannelVideoArchive();
         $archivesNotDeleted[] = $archive;
     }
     $this->assertCount(6, new CM_Paging_StreamChannelArchiveMedia_All());
     CM_Model_StreamChannelArchive_Media::deleteOlder(10, CM_Model_StreamChannel_Media::getTypeStatic());
     $this->assertCount(4, new CM_Paging_StreamChannelArchiveMedia_All());
     foreach ($archivesNotDeleted as $archive) {
         $exception = $this->catchException(function () use($archive) {
             CMTest_TH::reinstantiateModel($archive);
         });
         $this->assertNull($exception, 'Deleted archive that was too young or the wrong type');
     }
     foreach ($archivesDeleted as $archive) {
         $exception = $this->catchException(function () use($archive) {
             CMTest_TH::reinstantiateModel($archive);
         });
         $this->assertInstanceOf('CM_Exception_Nonexistent', $exception, 'Didn\'t delete old archive');
     }
 }