Drupal modules for browsing and managing Fedora-based digital repositories.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.4 KiB

<?php
namespace Drupal\Tests\islandora_video\Functional;
use Drupal\Tests\islandora\Functional\GenerateDerivativeTestBase;
/**
* Tests the GenerateVideoDerivative action.
*
* @group islandora_video
*/
class GenerateVideoDerivativeTest extends GenerateDerivativeTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['context_ui', 'islandora_video'];
/**
* @covers \Drupal\islandora_video\Plugin\Action\GenerateVideoDerivative::defaultConfiguration
* @covers \Drupal\islandora_video\Plugin\Action\GenerateVideoDerivative::buildConfigurationForm
* @covers \Drupal\islandora_video\Plugin\Action\GenerateVideoDerivative::validateConfigurationForm
*/
public function testGenerateVideoDerivativeFromScratch() {
// Create a test user.
$account = $this->drupalCreateUser([
'bypass node access',
'administer contexts',
'administer actions',
'view media',
'create media',
'update media',
]);
$this->drupalLogin($account);
// Create an action to generate a jpeg thumbnail.
$this->drupalGet('admin/config/system/actions');
$this->getSession()->getPage()->findById("edit-action")->selectOption("Generate a video derivative");
D9 islandora (#809) * update messenger for d9 * fix dependency injection * update info files * stream_for updates for d9 * remove deprecated entity query * replace deprecated functions * use dependency injection for messenger and fix other deprecated functions for d9 * fix deprecations in tests * fix test * phpcs fixes * fix toUrl method * properly use StringTranslationTrait * phpcs fixes and using dependency injection * more deprecations with upgrade_status 3.x version and more phpcs fixes * add defaultTheme per https://www.drupal.org/node/3083055 * replace deprecated context definition method - per https://www.drupal.org/node/2976400 * fix context definitions * remove more deprecations * fix deprecations in tests * codesniffer fixes - dependencies must be prefixed with drupal: and missing variable doc comments * replace more url() -> toUrl() and remove unused variables * more code sniffer fixes * some of these urls are necessary as strings * d9 requires update to flysystem module * update migrate_source_csv * temporarily point crayfish-commons to branch with d9 dependencies * another composer dependency adjustment * point composer to d9 branch of jsonld * remove hook_post_action for d9 * remove hook_post_action as a dependency - this does break multifile media FOR NOW * update migration keys -> ids per https://www.drupal.org/node/3060246 * fix url method * point jsonld back to dev since PR has been merged * wrong branch name * add update hook for change in migration source * update travis.yml for php 7.4 * add doc comment * build on php7.2, 7.3, 7.4 * use this instead of Drupal:: * just php 7.3 and 7.4 * swap back to dev-dev crayfish-commons since PR was merged * perhaps this fixes the config thing * trying to fix config * ugh errant semicolon * missing variable name * maybe it would help if i named the variables consistently * please work... * i can't get the dependency injection of config correct * sad panda * thanks @seth-shaw-unlv for this magical fix * fix dependency injection * putting the config in the AbstractGenerateDerivativeMediaFile class instead * already the system.file config * update test module info file * fix implode ordre of parameters * remove unused use statement * fix geminiclient tests * phpcs fix * check for fedora key in flysystem * check for array not being null * more null checks * try on the downgrade-symfony branch * set fedora url to null if it isn't in the settings * testing the crayfish-commons version fix * fixes for new classes in newer version of guzzlehttp but still needing to support old methods * update phpunit.xml? * transform 1 response from preg_match to a boolean * reorder crayfish-commons version fix * code sniffer fixes * abstract awaying the shared constructor so that phpcpd is happy about less duplicated code * attempt to reduce shared code in the FedoraAdapterTest * remove unused use statement * code sniffer fixes...not sure how i missed these... * remove reliance on branch of crayfish-commons since PR has been merged
4 years ago
$this->getSession()->getPage()->pressButton($this->t('Create'));
$this->assertSession()->statusCodeEquals(200);
$this->getSession()->getPage()->fillField('edit-label', "Generate video test derivative");
$this->getSession()->getPage()->fillField('edit-id', "generate_video_test_derivative");
$this->getSession()->getPage()->fillField('edit-queue', "generate-video-test-derivative");
$this->getSession()->getPage()->fillField('edit-destination-media-type', $this->testMediaType->label());
$this->getSession()->getPage()->fillField("edit-source-term", $this->preservationMasterTerm->label());
$this->getSession()->getPage()->fillField("edit-derivative-term", $this->serviceFileTerm->label());
$this->getSession()->getPage()->fillField('edit-mimetype', "video/mp4");
$this->getSession()->getPage()->fillField('edit-args', "-f mp4");
$this->getSession()->getPage()->fillField('edit-scheme', "public");
$this->getSession()->getPage()->fillField('edit-path', "derp.mov");
D9 islandora (#809) * update messenger for d9 * fix dependency injection * update info files * stream_for updates for d9 * remove deprecated entity query * replace deprecated functions * use dependency injection for messenger and fix other deprecated functions for d9 * fix deprecations in tests * fix test * phpcs fixes * fix toUrl method * properly use StringTranslationTrait * phpcs fixes and using dependency injection * more deprecations with upgrade_status 3.x version and more phpcs fixes * add defaultTheme per https://www.drupal.org/node/3083055 * replace deprecated context definition method - per https://www.drupal.org/node/2976400 * fix context definitions * remove more deprecations * fix deprecations in tests * codesniffer fixes - dependencies must be prefixed with drupal: and missing variable doc comments * replace more url() -> toUrl() and remove unused variables * more code sniffer fixes * some of these urls are necessary as strings * d9 requires update to flysystem module * update migrate_source_csv * temporarily point crayfish-commons to branch with d9 dependencies * another composer dependency adjustment * point composer to d9 branch of jsonld * remove hook_post_action for d9 * remove hook_post_action as a dependency - this does break multifile media FOR NOW * update migration keys -> ids per https://www.drupal.org/node/3060246 * fix url method * point jsonld back to dev since PR has been merged * wrong branch name * add update hook for change in migration source * update travis.yml for php 7.4 * add doc comment * build on php7.2, 7.3, 7.4 * use this instead of Drupal:: * just php 7.3 and 7.4 * swap back to dev-dev crayfish-commons since PR was merged * perhaps this fixes the config thing * trying to fix config * ugh errant semicolon * missing variable name * maybe it would help if i named the variables consistently * please work... * i can't get the dependency injection of config correct * sad panda * thanks @seth-shaw-unlv for this magical fix * fix dependency injection * putting the config in the AbstractGenerateDerivativeMediaFile class instead * already the system.file config * update test module info file * fix implode ordre of parameters * remove unused use statement * fix geminiclient tests * phpcs fix * check for fedora key in flysystem * check for array not being null * more null checks * try on the downgrade-symfony branch * set fedora url to null if it isn't in the settings * testing the crayfish-commons version fix * fixes for new classes in newer version of guzzlehttp but still needing to support old methods * update phpunit.xml? * transform 1 response from preg_match to a boolean * reorder crayfish-commons version fix * code sniffer fixes * abstract awaying the shared constructor so that phpcpd is happy about less duplicated code * attempt to reduce shared code in the FedoraAdapterTest * remove unused use statement * code sniffer fixes...not sure how i missed these... * remove reliance on branch of crayfish-commons since PR has been merged
4 years ago
$this->getSession()->getPage()->pressButton($this->t('Save'));
$this->assertSession()->statusCodeEquals(200);
// Create a context and add the action as a derivative reaction.
$this->createContext('Test', 'test');
$this->addPresetReaction('test', 'derivative', "generate_video_test_derivative");
$this->assertSession()->statusCodeEquals(200);
// Create a new preservation master belonging to the node.
$values = [
'name[0][value]' => 'Test Media',
'files[field_media_file_0]' => __DIR__ . '/../../fixtures/test_file.txt',
'field_media_of[0][target_id]' => 'Test Node',
2 years ago
'field_media_use[0][target_id]' => $this->preservationMasterTerm->label(),
];
2 years ago
$this->drupalGet('media/add/' . $this->testMediaType->id());
$this->submitForm($values, $this->t('Save'));
$expected = [
'source_uri' => 'test_file.txt',
'destination_uri' => "node/1/media/{$this->testMediaType->id()}/3",
'file_upload_uri' => 'public://derp.mov',
'mimetype' => 'video/mp4',
'args' => '-f mp4',
'queue' => 'islandora-connector-homarus',
];
// Check the message gets published and is of the right shape.
$this->checkMessage($expected);
}
}