44
44
$ret = $this->_markPluginParametersForCleanup('module', 'ffmpeg');
45
if ($ret->isError()) {
46
print $ret->getAsHtml();
47
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
50
$gallery->_platform = new AdminFfmpegControllerTestPlatform();
46
print $ret->getAsHtml();
47
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
50
list ($ret, $this->_movie) =
51
$this->_createRandomDataItem($this->_getRootId(), 'video/mpeg');
53
print $ret->getAsHtml();
54
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
56
$this->_markForCleanup($this->_movie);
58
list ($ret, $this->_thumbnail) = $this->_createDerivative(
59
$this->_movie, $this->_movie->getId(), DERIVATIVE_TYPE_IMAGE_THUMBNAIL,
60
'convert-to-image/jpeg;thumbnail|150');
62
print $ret->getAsHtml();
63
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
66
$this->_savePlatform =& $gallery->getPlatform();
67
$gallery->setPlatform(new AdminFfmpegControllerTestPlatform());
53
70
function testSaveGoodPath() {
66
83
/* Verify the settings went in properly */
67
list ($ret, $path) = GalleryCoreApi::getPluginParameter('module', 'ffmpeg', 'path');
68
if ($ret->isError()) {
69
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
71
$this->assertEquals('/validPath/ffmpeg', $path);
84
list ($ret, $params) = GalleryCoreApi::fetchAllPluginParameters('module', 'ffmpeg');
86
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
88
$this->assertEquals('/validPath/ffmpeg', $params['path']);
89
$this->assertEquals('0', $params['useWatermark']);
92
function testSaveUseWatermark() {
93
GalleryUtilities::putRequestVariable('form[action][save]', 1);
94
GalleryUtilities::putRequestVariable('form[path]', '/validPath/ffmpeg');
95
GalleryUtilities::putRequestVariable('form[useWatermark]', 1);
97
/* Perform the request and verify that we succeeded */
98
$results = $this->handleRequest();
99
$this->assertEquals(array('redirect' => array('view' => 'core.SiteAdmin',
100
'subView' => 'ffmpeg.AdminFfmpeg'),
101
'status' => array('saved' => 1),
105
/* Verify the settings went in properly */
106
list ($ret, $params) = GalleryCoreApi::fetchAllPluginParameters('module', 'ffmpeg');
108
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
110
$this->assertEquals('/validPath/ffmpeg', $params['path']);
111
$this->assertEquals('1', $params['useWatermark']);
74
114
function testSaveIncompletePath() {
169
209
'error' => array('form[error][path][missing]')),
213
function testAddRemoveWatermark() {
215
$gallery->setPlatform($this->_savePlatform);
217
$ret = $this->_saveThumbnailOps();
219
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
222
list ($ret, $path) = GalleryCoreApi::getPluginParameter('module', 'ffmpeg', 'path');
224
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
227
GalleryUtilities::putRequestVariable('form[path]', $path);
228
GalleryUtilities::putRequestVariable('form[action][save]', 1);
229
GalleryUtilities::putRequestVariable('form[addWatermark]', 1);
231
$results = $this->handleRequest();
232
$this->assertEquals(array('redirect' => array('view' => 'core.SiteAdmin',
233
'subView' => 'ffmpeg.AdminFfmpeg'),
234
'status' => array('added' => 1, 'saved' => 1),
238
list ($ret, $thumbnail) = $this->_thumbnail->refresh();
240
$this->failWithStatus($ret->wrap(__FILE__, __LINE__));
243
$this->assertEquals('convert-to-image/jpeg;thumbnail|150;composite|plugins_data/modules/' .
244
'ffmpeg/filmreel.png,image/png,12,399,top-left,0,0;composite|plugins_data/modules/' .
245
'ffmpeg/filmreel.png,image/png,12,399,top-right,0,0',
246
$thumbnail->getDerivativeOperations(), 'add watermark');
248
GalleryUtilities::putRequestVariable('form[addWatermark]', 0);
249
GalleryUtilities::putRequestVariable('form[removeWatermark]', 1);
251
$results = $this->handleRequest();
252
$this->assertEquals(array('redirect' => array('view' => 'core.SiteAdmin',
253
'subView' => 'ffmpeg.AdminFfmpeg'),
254
'status' => array('removed' => 1, 'saved' => 1),
258
list ($ret, $thumbnail) = $this->_thumbnail->refresh();
260
$this->failWithStatus($ret->wrap(__FILE__, __LINE__));
263
$this->assertEquals('convert-to-image/jpeg;thumbnail|150',
264
$thumbnail->getDerivativeOperations(), 'remove watermark');
266
$ret = $this->_restoreThumbnailOps();
268
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
272
function _saveThumbnailOps() {
275
SELECT [GalleryDerivative::id], [GalleryDerivative::derivativeOperations]
276
FROM [GalleryDerivative], [GalleryChildEntity], [GalleryEntity]
277
WHERE [GalleryDerivative::id] = [GalleryChildEntity::id]
278
AND [GalleryChildEntity::parentId] = [GalleryEntity::id]
279
AND [GalleryEntity::entityType] = \'GalleryMovieItem\'';
280
list ($ret, $searchResults) = $gallery->search($query);
282
return $ret->wrap(__FILE__, __LINE__);
284
$this->_thumbnailOps = array();
285
while ($result = $searchResults->nextResult()) {
286
$this->_thumbnailOps[(int)$result[0]] = $result[1];
291
function _restoreThumbnailOps() {
292
if (empty($this->_thumbnailOps)) {
295
list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock(array_keys($this->_thumbnailOps));
297
return $ret->wrap(__FILE__, __LINE__);
299
list ($ret, $thumbnails) =
300
GalleryCoreApi::loadEntitiesById(array_keys($this->_thumbnailOps));
302
GalleryCoreApi::releaseLocks($lockId);
303
return $ret->wrap(__FILE__, __LINE__);
305
foreach ($thumbnails as $thumbnail) {
306
$thumbnail->setDerivativeOperations($this->_thumbnailOps[$thumbnail->getId()]);
307
$ret = $thumbnail->save();
309
GalleryCoreApi::releaseLocks($lockId);
310
return $ret->wrap(__FILE__, __LINE__);
313
$ret = GalleryCoreApi::releaseLocks($lockId);
315
return $ret->wrap(__FILE__, __LINE__);