コード例 #1
0
 public function setUp()
 {
     parent::setUp();
     $pluginHelper = new Omeka_Test_Helper_Plugin();
     $pluginHelper->setUp(self::PLUGIN_NAME);
     define('TEST_FILES_DIR', ARCHIVE_REPERTORY_DIR . '/tests/suite/_files');
     // Add constraints if derivatives have been added in the config file.
     $fileDerivatives = Zend_Registry::get('bootstrap')->getResource('Config')->fileDerivatives;
     if (!empty($fileDerivatives) && !empty($fileDerivatives->paths)) {
         foreach ($fileDerivatives->paths->toArray() as $type => $path) {
             set_option($type . '_constraint', 1);
         }
     }
     // Prepare config and set a test temporary storage in registry.
     $config = new Omeka_Test_Resource_Config();
     $configIni = $config->init();
     if (isset($configIni->paths->imagemagick)) {
         $this->convertDir = $configIni->paths->imagemagick;
     } else {
         $this->convertDir = dirname(`which convert`);
     }
     $storage = Zend_Registry::get('storage');
     $adapter = $storage->getAdapter();
     $adapterOptions = $adapter->getOptions();
     $this->_storagePath = $adapterOptions['localDir'];
     // Set default strategy for the creation of derivative files.
     $this->strategy = new Omeka_File_Derivative_Strategy_ExternalImageMagick();
     $this->strategy->setOptions(array('path_to_convert' => $this->convertDir));
     $this->creator = new Omeka_File_Derivative_Creator();
     $this->creator->setStrategy($this->strategy);
     Zend_Registry::set('file_derivative_creator', $this->creator);
     // Create one item on which attach files.
     $this->item = insert_item(array('public' => true));
     set_option('disable_default_file_validation', 1);
 }
コード例 #2
0
ファイル: CreatorTest.php プロジェクト: emhoracek/Omeka
 public function setUp()
 {
     $config = new Omeka_Test_Resource_Config();
     $configIni = $config->init();
     if (isset($configIni->paths->imagemagick)) {
         $this->convertDir = $configIni->paths->imagemagick;
     } else {
         $this->convertDir = dirname(`which convert`);
     }
     $this->invalidFile = '/foo/bar/baz.html';
     $this->validFilePath = dirname(__FILE__) . '/_files/valid-image.jpg';
     $this->validMimeType = 'image/jpeg';
     $this->fullsizeImgType = 'fullsize';
     $this->derivativeFilename = 'valid-image_deriv.jpg';
     // If we set up a test log, then log the ImageMagick commands instead
     // of executing via the commandline.
     $this->logWriter = new Zend_Log_Writer_Mock();
     $this->testLog = new Zend_Log($this->logWriter);
     $this->creator = new Omeka_File_Derivative_Creator();
     $this->strategy = new Omeka_File_Derivative_Strategy_ExternalImageMagick();
     $this->creator->setStrategy($this->strategy);
 }