예제 #1
0
파일: CliTest.php 프로젝트: cargomedia/cm
 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());
 }
예제 #2
0
파일: Cli.php 프로젝트: cargomedia/cm
 public function iconRefresh()
 {
     /** @var CM_File[] $svgFileList */
     $svgFileList = array();
     foreach (CM_Bootloader::getInstance()->getModules() as $moduleName) {
         $iconPath = CM_Util::getModulePath($moduleName) . 'layout/default/resource/img/icon/';
         foreach (glob($iconPath . '*.svg') as $svgPath) {
             $svgFile = new CM_File($svgPath);
             $svgFileList[strtolower($svgFile->getFileName())] = $svgFile;
         }
     }
     if (0 === count($svgFileList)) {
         throw new CM_Exception_Invalid('Cannot process `0` icons');
     }
     $this->_getStreamOutput()->writeln('Processing ' . count($svgFileList) . ' unique icons...');
     $dirWork = CM_File::createTmpDir();
     $dirBuild = $dirWork->joinPath('/build');
     foreach ($svgFileList as $fontFile) {
         $fontFile->copyToFile($dirWork->joinPath($fontFile->getFileName()));
     }
     CM_Util::exec('fontcustom', array('compile', $dirWork->getPathOnLocalFilesystem(), '--no-hash', '--autowidth', '--font-name=icon-webfont', '--output=' . $dirBuild->getPathOnLocalFilesystem()));
     $cssFile = $dirBuild->joinPath('/icon-webfont.css');
     $less = preg_replace('/url\\("(?:.*?\\/)(.+?)(\\??#.+?)?"\\)/', 'url(urlFont("\\1") + "\\2")', $cssFile->read());
     CM_File::create(DIR_PUBLIC . 'static/css/library/icon.less', $less);
     foreach (glob($dirBuild->joinPath('/icon-webfont.*')->getPathOnLocalFilesystem()) as $fontPath) {
         $fontFile = new CM_File($fontPath);
         $fontFile->rename(DIR_PUBLIC . 'static/font/' . $fontFile->getFileName());
     }
     $dirWork->delete(true);
     $this->_getStreamOutput()->writeln('Created web-font and stylesheet.');
 }
예제 #3
0
파일: Cli.php 프로젝트: cargomedia/cm
 /**
  * @param string $namespace
  */
 private function _dbToFileSql($namespace)
 {
     $namespace = (string) $namespace;
     $tables = CM_Db_Db::exec("SHOW TABLES LIKE ?", array(strtolower($namespace) . '_%'))->fetchAllColumn();
     sort($tables);
     $dump = CM_Db_Db::getDump($tables, true);
     CM_File::create(CM_Util::getModulePath($namespace) . '/resources/db/structure.sql', $dump);
 }
예제 #4
0
 public function testUploadInvalidField()
 {
     $filename = 'test.jpg';
     $content = file_get_contents(DIR_TEST_DATA . 'img/' . $filename);
     $fileTmp = CM_File::create($this->_dir . 'test1', $content);
     $_FILES = array('file' => array('name' => $filename, 'tmp_name' => $fileTmp->getPath()));
     $site = CM_Site_Abstract::factory();
     $request = new CM_Http_Request_Post('/upload?field=nonexistent');
     $upload = CM_Http_Response_Upload::createFromRequest($request, $site, $this->getServiceManager());
     try {
         $upload->process();
         $this->fail('Should throw invalid exception');
     } catch (CM_Exception_Invalid $e) {
         $this->assertTrue(true);
     }
 }