Exemplo n.º 1
0
 public function testImportVideoThumbnail()
 {
     $testFile1 = CM_File::create('test1.png', 'foo1', CM_Service_Manager::getInstance()->getFilesystems()->getTmp());
     $testFile2 = CM_File::create('test2.png', 'foo2', CM_Service_Manager::getInstance()->getFilesystems()->getTmp());
     $cli = new CM_MediaStreams_Cli();
     // streamchannel exists
     /** @var CM_Model_StreamChannel_Media $streamChannel */
     $streamChannel = CMTest_TH::createStreamChannel(null, null, 'foobar');
     $this->assertCount(0, $streamChannel->getThumbnails());
     $cli->importVideoThumbnail('foobar', $testFile1, 1234);
     $this->assertCount(1, $streamChannel->getThumbnails());
     /** @var CM_StreamChannel_Thumbnail $thumbnail */
     $thumbnail = $streamChannel->getThumbnails()->getItem(0);
     $this->assertSame(1234, $thumbnail->getCreateStamp());
     $this->assertSame('foo1', $thumbnail->getFile()->read());
     // archive exists
     $archive = CM_Model_StreamChannelArchive_Media::createStatic(['streamChannel' => $streamChannel]);
     $streamChannel->delete();
     $cli->importVideoThumbnail('foobar', $testFile2, 1235);
     $this->assertCount(2, $streamChannel->getThumbnails());
     /** @var CM_StreamChannel_Thumbnail $thumbnail */
     $thumbnail = $archive->getThumbnails()->getItem(1);
     $this->assertSame(1235, $thumbnail->getCreateStamp());
     $this->assertSame('foo2', $thumbnail->getFile()->read());
 }
Exemplo n.º 2
0
 protected function _onDeleteBefore()
 {
     parent::_onDeleteBefore();
     if (!CM_Model_StreamChannelArchive_Media::findById($this->getId())) {
         CM_Model_StreamChannelArchive_Media::createStatic(array('streamChannel' => $this));
     }
 }
Exemplo n.º 3
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());
 }
Exemplo n.º 4
0
Arquivo: TH.php Projeto: cargomedia/cm
 /**
  * @param CM_Model_StreamChannel_Media|null $streamChannel
  * @param CM_Model_User|null                $user
  * @param string|null                       $filename
  * @return CM_Model_StreamChannelArchive_Media
  */
 public static function createStreamChannelVideoArchive(CM_Model_StreamChannel_Media $streamChannel = null, CM_Model_User $user = null, $filename = null)
 {
     if (is_null($streamChannel)) {
         $streamChannel = static::createStreamChannel();
         static::createStreamPublish($user, $streamChannel);
     }
     if (!$streamChannel->hasStreamPublish()) {
         static::createStreamPublish($user, $streamChannel);
     }
     if (null !== $filename) {
         $filename = (string) $filename;
     }
     return CM_Model_StreamChannelArchive_Media::createStatic(array('streamChannel' => $streamChannel, 'file' => $filename));
 }
Exemplo n.º 5
0
 public function testFindByMediaId()
 {
     /** @var CM_Model_StreamChannel_Media $streamChannel */
     $streamChannel = $streamChannel = CMTest_TH::createStreamChannel(null, null, 'foo');
     $this->assertNull(CM_Model_StreamChannelArchive_Media::findByMediaId($streamChannel->getMediaId()));
     $streamChannelArchive = CM_Model_StreamChannelArchive_Media::createStatic(['streamChannel' => $streamChannel]);
     $this->assertEquals($streamChannelArchive, CM_Model_StreamChannelArchive_Media::findByMediaId($streamChannel->getMediaId()));
 }