From ae0bf01ff77b9ccae98979e5d73fcdc42a2ee216 Mon Sep 17 00:00:00 2001 From: RLT Date: Thu, 23 Jan 2025 14:37:38 -0600 Subject: [PATCH 01/10] Resolve all Problems detected --- .../TripalCultivatePhenoshareImporter.php | 373 +++++++++--------- 1 file changed, 187 insertions(+), 186 deletions(-) diff --git a/trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php b/trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php index bcf3d178..7718b876 100644 --- a/trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php +++ b/trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php @@ -1,44 +1,38 @@ 'The full name of the trait as you would like it to appear on a trait page. This should not be abbreviated (e.g. Days till one open flower).', 'Method Name' => 'A short (<4 words) name describing the method. This should uniquely identify the method while being very succinct (e.g. 10% Plot at R1).', @@ -69,47 +74,51 @@ class TripalCultivatePhenoshareImporter extends ChadoImporterBase implements Con 'Data Collector' => 'The name of the person or organization which measured the phenotype.', ]; - // Service: Make the following services available to all stages. - // Genus Ontology configuration service. - protected $service_genusontology; - /** - * Injection of services through setter methods. - * - * @param \Symfony\Component\DependencyInjection\ContainerInterface $container - * @param array $configuration - * @param string $plugin_id - * @param mixed $plugin_definition + * Genus Ontology Service. * - * @return static + * @var Drupal\trpcultivate_phenotypes\Service\TripalCultivatePhenotypesGenusOntologyService */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - $service = $container->get('trpcultivate_phenotypes.genus_ontology'); + protected $service_PhenoGenusOntology; + + /** + * Constructs the Phenotypes Share importer. + */ + public function __construct( + array $configuration, + string $plugin_id, + mixed $plugin_definition, + ChadoConnection $chado_connection, + TripalCultivatePhenotypesGenusOntologyService $service_PhenoGenusOntology, + ) { + parent::__construct($configuration, $plugin, $plugin_definition, $chado_connection); + + // Call service setter method to set the service. + $this->setServiceGenusOntology($service_PhenoGenusOntology); + } - $instance = new static( + /** + * {@inheritDoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return new static( $configuration, $plugin_id, $plugin_definition, $container->get('tripal_chado.database'), - $service + $container->get('trpcultivate_phenotypes.genus_ontology'), ); - - // Call service setter method to set the service. - $instance->setServiceGenusOntology($service); - - return $instance; } /** - * Service setter method: - * Set genus ontology configuration service. + * Set phenotype genus ontology configuration service. * - * @param $service - * Service as created/injected through create method. + * @param Drupal\trpcultivate_phenotypes\Service\TripalCultivatePhenotypesGenusOntologyService $service + * The PhenoGenoOntology service as created/injected through create method. */ public function setServiceGenusOntology($service) { if ($service) { - $this->service_genusontology = $service; + $this->service_PhenoGenusOntology = $service; } } @@ -132,7 +141,7 @@ public function form($form, &$form_state) { ->get('trpcultivate.phenotypes.ontology.allownew'); if ($allownew == FALSE) { - $allownew_minder = t('This module is set to NOT to allow new trait, new method and new unit to be added + $allownew_minder = $this->t('This module is set to NOT to allow new trait, new method and new unit to be added during the upload process. Please make sure that all trait, method and unit exist in Chado (cvterm) before uploading your data file.'); @@ -140,47 +149,47 @@ public function form($form, &$form_state) { } // This is a reminder to user about expected phenotypic data. - $phenotypes_minder = t('Phenotypic data should be filtered for outliers and mis-entries before + $phenotypes_minder = $this('Phenotypic data should be filtered for outliers and mis-entries before being uploaded here. Do not upload data that should not be used in the final analysis for a scientific article. Furthermore, data should NOT BE AVERAGED across replicates or site-year.'); \Drupal::messenger()->addWarning($phenotypes_minder); // Cacheing of stage number: // Cache current stage and id field to allow script to reference this value. - - // Account for failed validation. - // Refer to Drupal $storage system for validation result values saved. + // Account for failed validation by referring to Drupal $storage system + // for full validation result values saved. $storage = $form_state->getStorage(); - // Full validation result. - - $validation_result = []; + // Flag to indicate if validation has returned a failed status. $has_fail = FALSE; - if (isset($storage[ $this->validation_result ])) { - $has_fail = $this->hasFailedValidation($storage[ $this->validation_result ]); + if (isset($storage[$this->validation_result])) { + $has_fail = $this->hasFailedValidation($storage[$this->validation_result]); } $triggering_element = $form_state->getTriggeringElement(); $valid_triggering_element = [ - 'Validate Data File', // Stage 1 - 'Check Values', // Stage 2 - 'Skip' // Stage 2 + // Stage 1. + 'Validate Data File', + // Stage 2. + 'Check Values', + // Stage 2. + 'Skip', ]; $stage = (!$has_fail && $form_state->getValue('trigger_element') && in_array($triggering_element['#value'], $valid_triggering_element)) - ? (int) $form_state->getValue( $this->current_stage ) + 1 + ? (int) $form_state->getValue($this->current_stage) + 1 : 1; - $form[ $this->current_stage ] = [ + $form[$this->current_stage] = [ '#type' => 'hidden', '#value' => $stage, - '#attributes' => ['id' => 'tcp-current-stage'] + '#attributes' => ['id' => 'tcp-current-stage'], ]; - // Rendering of Stage: // Compose stage array that will become the basis of the stages rendered in - // stage accordion layout. Each stage is a method titled stage + stage no (ie. stage1). + // stage accordion layout. Each stage is a method titled stage + stage no + // (ie. stage1). $stage_methods = get_class_methods(get_class($this)); $total_stages = 0; @@ -188,8 +197,7 @@ public function form($form, &$form_state) { if (preg_match('/stage([1-9])/', $method, $matches)) { if ($stage_no = $matches[1]) { // Call method to build stage. - // Set the status of the stage (current, complete, upcoming). - + // Set the status of the stage (current, complete, or upcoming). $stage_status = ''; if ($stage == $stage_no) { // Is the current stage. @@ -206,11 +214,10 @@ public function form($form, &$form_state) { } } - // Submit button. // Manage importer submit button: Import - // By default, is disabled in the plugin annotation definition: submit_disabled - // and enabled one less stage of the total stages. + // By default, is disabled in the plugin annotation definition: + // submit_disabled and enabled one less stage of the total stages. if ($stage > ($total_stages - 1)) { $storage['disable_TripalImporter_submit'] = FALSE; $form_state->setStorage($storage); @@ -219,15 +226,13 @@ public function form($form, &$form_state) { return $form; } - - /// Stage accordion methods. - /** * Stage 1: Upload data file. Method/Function template. * * Subsequent stages in accordion will correspond to a public method titled - * stage + stage number (ie. stage1, or stage2). In each method - * will define the stage markup and form render array using the structure below: + * stage + stage number (ie. stage1, or stage2). + * In each method will define the stage markup and form render array using + * the structure below: * *
Title
*
@@ -240,53 +245,55 @@ public function form($form, &$form_state) { * * accordion_stage + STAGE NUMBER (ie. accordion_stage1) * - * @param $form - * Drupal form object. - * @param $form_state + * @param array $form + * Drupal form array. + * @param object $form_state * Drupal form state object. - * @param $stage_status - * String, class name to style each stage with the correct css class + * @param string $stage_status + * CSS class selector name to style each stage with the correct css class * corresponding to a stage - completed, current and upcoming stage. */ public function stage1(&$form, $form_state, $stage_status = '') { // Describe stage by providing the stage number and title of the stage. - // The status key in the stage description array corresponds to the parameter of the method - // and is determined by the method call to render stage in the form build above. + // The status key in the stage description array corresponds to the + // parameter of the method and is determined by the method call to render + // stage in the form build above. $stage = [ 'stage#' => 1, 'title' => 'Upload Data File', - 'status' => $stage_status + 'status' => $stage_status, ]; - // Field wrapper name. All additional elements that go into this stage should - // use this name to encapsulate into a specific stage in the accordion. + // Field wrapper name. All additional elements that go into this stage + // should use this name to encapsulate into a specific stage in + // the accordion. $fld_wrapper = 'accordion_stage' . $stage['stage#']; - $form[ $fld_wrapper ] = $this->createStageAccordion($stage); + $form[$fld_wrapper] = $this->createStageAccordion($stage); // Validation result. $storage = $form_state->getStorage(); // Full validation result. - if (isset($storage[ $this->validation_result ])) { - $validation_result = $storage[ $this->validation_result ]; + if (isset($storage[$this->validation_result])) { + $validation_result = $storage[$this->validation_result]; - $form[ $fld_wrapper ]['validation_result'] = [ + $form[$fld_wrapper]['validation_result'] = [ '#type' => 'inline_template', '#theme' => 'result_window', '#data' => [ - 'validation_result' => $validation_result + 'validation_result' => $validation_result, ], - '#weight' => -100 + '#weight' => -100, ]; } // Other relevant fields here. // Select experiment, Genus field will reflect the genus project is set to. - $form[ $fld_wrapper ]['project'] = [ - '#title' => t('Project/Experiment'), + $form[$fld_wrapper]['project'] = [ + '#title' => 'Project/Experiment', '#type' => 'textfield', '#weight' => -100, '#required' => TRUE, - '#description' => t('Enter the name of the experiment or project your data was generated as part of.'), + '#description' => $this->t('Enter the name of the experiment or project your data was generated as part of.'), '#attributes' => ['placeholder' => 'Project/Experiment Name', 'class' => ['tcp-autocomplete']], '#autocomplete_route_name' => 'tripal_chado.project_autocomplete', '#autocomplete_route_parameters' => ['type_id' => 0, 'count' => 5], @@ -303,28 +310,28 @@ public function stage1(&$form, $form_state, $stage_status = '') { 'type' => 'throbber', 'message' => '', ], - 'wrapper' => 'trpcultivate-field-genus-wrapper' - ] + 'wrapper' => 'trpcultivate-field-genus-wrapper', + ], ]; // Field Genus: // Prepare select options with only active genus. - $all_genus = $this->service_genusontology->getConfiguredGenusList(); + $all_genus = $this->service_PhenoGenusOntology->getConfiguredGenusList(); $active_genus = array_combine($all_genus, $all_genus); - $form[ $fld_wrapper ]['genus'] = [ - '#title' => t('Genus'), + $form[$fld_wrapper]['genus'] = [ + '#title' => 'Genus', '#type' => 'select', '#options' => $active_genus, '#weight' => -90, '#required' => TRUE, - '#description' => t('Select Genus. When experiment or project has genus set, a value will be selected.'), + '#description' => $this->t('Select Genus. When experiment or project has genus set, a value will be selected.'), // States. '#states' => [ 'disabled' => [ ':input[name="project"]' => ['filled' => FALSE], - ] + ], ], // Used by script to pre-select when project was supplied. @@ -339,38 +346,35 @@ public function stage1(&$form, $form_state, $stage_status = '') { // For the file upload field to conform to the accordion layout, // this override script must be performed. $file_upload = $form['file']; - $form[ $fld_wrapper ]['file'] = $file_upload; + $form[$fld_wrapper]['file'] = $file_upload; // Omit old copy so there would not be duplicate file // element in the upload data file stage. $form['file'] = []; // Other relevant fields here. - // This importer does not support using file sources from existing field. // #access: (bool) Whether the element is accessible or not; when FALSE, // the element is not rendered and the user submitted value is not taken // into consideration. - $form[ $fld_wrapper ]['file']['file_upload_existing']['#access'] = FALSE; + $form[$fld_wrapper]['file']['file_upload_existing']['#access'] = FALSE; // Stage submit button. - $form[ $fld_wrapper ]['validate_stage'] = [ + $form[$fld_wrapper]['validate_stage'] = [ '#type' => 'submit', '#value' => 'Validate Data File', - '#name' => 'trigger_element' + '#name' => 'trigger_element', ]; } /** * Stage 2: Validate data. * - * @see stage 1 method template. - * - * @param $form - * Drupal form object. - * @param $form_state + * @param array $form + * Drupal form array. + * @param object $form_state * Drupal form state object. - * @param $stage_status - * String, class name to style each stage with the correct css class + * @param string $stage_status + * CSS class selector name to style each stage with the correct css class * corresponding to a stage - completed, current and upcoming stage. */ public function stage2(&$form, $form_state, $stage_status = '') { @@ -378,42 +382,40 @@ public function stage2(&$form, $form_state, $stage_status = '') { $stage = [ 'stage#' => 2, 'title' => 'Describe Traits', - 'status' => $stage_status + 'status' => $stage_status, ]; $fld_wrapper = 'accordion_stage' . $stage['stage#']; - $form[ $fld_wrapper ] = $this->createStageAccordion($stage); + $form[$fld_wrapper] = $this->createStageAccordion($stage); // Other relevant fields here. - $form[ $fld_wrapper ]['field_elements'] = [ - '#markup' => '

Stage 2 field elements here

' + $form[$fld_wrapper]['field_elements'] = [ + '#markup' => '

Stage 2 field elements here

', ]; // Stage submit button. - $form[ $fld_wrapper ]['validate_stage'] = [ + $form[$fld_wrapper]['validate_stage'] = [ '#type' => 'submit', '#value' => 'Check Values', - '#name' => 'trigger_element' + '#name' => 'trigger_element', ]; - $form[ $fld_wrapper ]['skip_stage'] = [ + $form[$fld_wrapper]['skip_stage'] = [ '#type' => 'submit', '#value' => 'Skip', - '#name' => 'trigger_element' + '#name' => 'trigger_element', ]; } /** * Stage 3: Describe and save data. * - * @see stage 1 method template. - * - * @param $form - * Drupal form object. - * @param $form_state + * @param array $form + * Drupal form array. + * @param object $form_state * Drupal form state object. - * @param $stage_status - * String, class name to style each stage with the correct css class + * @param string $stage_status + * CSS class selector name to style each stage with the correct css class * corresponding to a stage - completed, current and upcoming stage. */ public function stage3(&$form, $form_state, $stage_status = '') { @@ -421,23 +423,18 @@ public function stage3(&$form, $form_state, $stage_status = '') { $stage = [ 'stage#' => 3, 'title' => 'Review Data', - 'status' => $stage_status + 'status' => $stage_status, ]; $fld_wrapper = 'accordion_stage' . $stage['stage#']; - $form[ $fld_wrapper ] = $this->createStageAccordion($stage); + $form[$fld_wrapper] = $this->createStageAccordion($stage); // Other relevant fields here. - $form[ $fld_wrapper ]['field_elements'] = [ - '#markup' => '

Stage 3 summary table here

' + $form[$fld_wrapper]['field_elements'] = [ + '#markup' => '

Stage 3 summary table here

', ]; } - // End stage accordion methods. - - /// - - /** * {@inheritdoc} */ @@ -452,24 +449,24 @@ public function formValidate($form, &$form_state) { $form_state_values = $form_state->getValues(); // Current stage. - // Get the cached stage value from the formstate values and perform validation - // when it is set to a value. Starting with index 1 - as stage 1, index 2 as stage 2 - // and so on to the last stage. - + // Get the cached stage value from the formstate values and perform + // validation when it is set to a value. Starting with index 1 - as stage 1, + // index 2 as stage 2 and so on to the last stage. + // // NOTE: not all stages require a validation and a subsequent condition will // target a specific stage to perform pertinent validation. - - // NOTE: $this->current_stage is the name of the field in the formstate that holds - // the current stage value (cacheing of stage no.). See $current_stage property. + // NOTE: $this->current_stage is the name of the field in the formstate that + // holds the current stage value (cacheing of stage no.). + // See $current_stage property. if (array_key_exists($this->current_stage, $form_state_values)) { - $stage = $form_state_values[ $this->current_stage ]; + $stage = $form_state_values[$this->current_stage]; // This will support re-upload of a file but form has performed // validation of a previously uploaded file. if ($stage > 1 && $form_state->getValue('trigger_element') == 'Validate Data File') { - // Stage is no longer stage 1 from previous upload and triggering element + // Stage is no longer stage 1 from previous upload and + // triggering element // is the upload file (in stage 1). - // Reset the stage to stage 1 to perform validation below. $stage = 1; // Cache stage. @@ -478,14 +475,14 @@ public function formValidate($form, &$form_state) { if ($stage >= 1) { // Validate Stage 1. - // Counter, count number of validators that failed. $failed_validator = 0; // Call validator manager service. $manager = \Drupal::service('plugin.manager.trpcultivate_validator'); - // All values will be accessible to every instance of the validator Plugin. + // All values will be accessible to every instance of the + // validator Plugin. $project = $form_state_values['project']; $genus = $form_state_values['genus']; $file = $form_state_values['file_upload']; @@ -498,22 +495,24 @@ public function formValidate($form, &$form_state) { // Each result is keyed by the scope. $validation = []; - foreach($scopes as $scope) { - // Create instance of the scope-specific plugin and perform validation. + foreach ($scopes as $scope) { + // Create instance of the scope-specific plugin and + // perform validation. $validator = $manager->getValidatorIdWithScope($scope); $instance = $manager->createInstance($validator); - // Set other validation level to upcoming/todo if a validation failed. + // Set other validation level to upcoming/todo if a + // validation failed. $skip = ($failed_validator > 0) ? 1 : 0; // Load values. $instance->loadAssets($project, $genus, $file, $headers, $skip); // Perform current scope level validation. - $validation[ $scope ] = $instance->validate(); + $validation[$scope] = $instance->validate(); // Inspect for any failed validation to halt the importer. - if ($validation[ $scope ]['status'] == 'fail') { + if ($validation[$scope]['status'] == 'fail') { $failed_validator++; } } @@ -521,13 +520,14 @@ public function formValidate($form, &$form_state) { // Save all validation results in Drupal storage to be used by // validation window to create summary report. $storage = $form_state->getStorage(); - $storage[ $this->validation_result ] = $validation; + $storage[$this->validation_result] = $validation; $form_state->setStorage($storage); if ($failed_validator > 0) { - // There are issues in the submission and are detailed in the validation result window. - // Prevent this form from submitting and reload form with all the validation errors - // in the storage system. + // There are issues in the submission and are detailed in the + // validation result window. + // Prevent this form from submitting and reload form with all the + // validation errors in the storage system. $form_state->setRebuild(TRUE); } } @@ -566,27 +566,28 @@ public function describeUploadFileFormat() { '#theme' => 'importer_header', '#data' => [ 'headers' => $this->headers, - 'template_file' => $file_link - ] + 'template_file' => $file_link, + ], ]; return \Drupal::service('renderer')->render($build); } /** - * Construct markup for a stage with title and a corresponding content area - * that will be rendered as a stage in the accordion. Each stage will utilize - * the structure below: + * Construct markup for a stage. + * + * Each stage will utilize the HTML markup structure below: * *
Title
*
Stage Body/Content
* - * @param $stage + * @param array $stage * An associative array with the following keys. * - stage#: integer, stage number. * - title : string, stage title. * - status: string, class name to correctly style each stage. - * Class is assigned in the method call to render stage in form build method above. + * CSS class selector name is assigned in the method call to render stage + * in form build method above. * - tcp-current-stage: active/current stage * - tcp-completed-stage: completed stage. * - Default to empty string in each stage method: upcoming stage. @@ -595,15 +596,15 @@ public function createStageAccordion($stage) { // Stage number. $stage_no = $stage['stage#']; // Stage title. - $title = $stage['title']; + $title = $stage['title']; // Stage status - class name. $status = $stage['status']; $markup = [ - '#prefix' => t('
STAGE @stage#: @title
+ '#prefix' => $this->t('
STAGE @stage#: @title
', ['@stage_status' => $status, '@stage#' => $stage_no, '@title' => $title]), - '#suffix' => '
' + '#suffix' => '
', ]; return $markup; @@ -612,21 +613,21 @@ public function createStageAccordion($stage) { /** * Check if validation failed. * - * @param $validation_result + * @param array $validation_result * An associative array where each element is the validation summary of each * level (PROJECT, GENUS, FILE etc.). * [level => [ * 'status' => 'fail', // pass, todo - * 'detail' => 'String, describing more details about the failed validation' + * 'detail' => 'String describing details about the failed validation' * ], * ... - * ] + * ]. */ public function hasFailedValidation($validation_result = []) { $has_fail = FALSE; if ($validation_result) { - foreach($validation_result as $validator) { + foreach ($validation_result as $validator) { // Inspect the validation result summary and if any one level // failed validation should suffice to stop import. if ($validator['status'] == 'fail') { @@ -639,17 +640,16 @@ public function hasFailedValidation($validation_result = []) { return $has_fail; } - // AJAX callback. - /** * Load genus of project. * - * @param $form - * Drupal form object. - * @param $form_state + * @param array $form + * Drupal form array. + * @param object $form_state * Drupal form state object. * - * @return Drupal\Core\Ajax\AjaxResponse. + * @return Drupal\Core\Ajax\AjaxResponse + * Drupal AJAX Response. */ public static function ajaxLoadGenusOfProject($form, &$form_state) { // Project name. @@ -675,7 +675,8 @@ public static function ajaxLoadGenusOfProject($form, &$form_state) { $genus_of_project = ''; } - $response->addCommand(new InvokeCommand('#trpcultivate-fld-genus', 'val', [ $genus_of_project ])); + $response->addCommand(new InvokeCommand('#trpcultivate-fld-genus', 'val', [$genus_of_project])); return $response; } + } From f0e9e0a96cddce645016315f0055637a13458ae5 Mon Sep 17 00:00:00 2001 From: RLT Date: Thu, 23 Jan 2025 16:29:07 -0600 Subject: [PATCH 02/10] Fix problems in core module files --- .../tests/src/Functional/InstallTest.php | 36 +++++++++++++------ .../trpcultivate_phenoshare.module | 8 ++--- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php b/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php index 30542456..c617c2cc 100644 --- a/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php +++ b/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php @@ -8,11 +8,16 @@ /** * Simple test to ensure that main page loads with module enabled. * - * @group TripGeno Genetics + * @group TripPheno Share * @group Installation */ class InstallTest extends ChadoTestBrowserBase { + /** + * Default theme. + * + * @var string + */ protected $defaultTheme = 'stark'; /** @@ -20,23 +25,31 @@ class InstallTest extends ChadoTestBrowserBase { * * @var array */ - protected static $modules = ['help', 'trpcultivate_phenoshare']; + protected static $modules = [ + 'help', + 'trpcultivate_phenoshare', + ]; /** - * The name of your module in the .info.yml + * The name of your module in the .info.yml. + * + * @var string */ protected static $module_name = 'Phenotypic Data Sharing'; /** * The machine name of this module. + * + * @var string */ protected static $module_machinename = 'trpcultivate_phenoshare'; /** - * A small excert from your help page. - * Do not cross newlines. + * A small excert from your help page (Do not cross newlines). + * + * @var string */ - protected static $help_text_excerpt = 'rovides trait pages, downloads and visualization tools to facillitate sharing published phenotypic data with'; + protected static $help_text_excerpt = 'provides trait pages, downloads and visualization tools to facillitate sharing published phenotypic data with'; /** * Tests that a specific set of pages load with a 200 response. @@ -59,8 +72,7 @@ public function testLoad() { $this->drupalGet('admin/modules'); $status_code = $session->getStatusCode(); $this->assertEquals(200, $status_code, "The module install page should be able to load $context."); - $this->assertSession()->pageTextContains( self::$module_name ); - + $this->assertSession()->pageTextContains(self::$module_name); } /** @@ -72,7 +84,11 @@ public function testHelp() { $some_extected_text = self::$help_text_excerpt; // Ensure we have an admin user. - $permissions = ['access administration pages','administer modules', 'access help pages']; + $permissions = [ + 'access administration pages', + 'administer modules', + 'access help pages', + ]; $user = $this->drupalCreateUser($permissions); $this->drupalLogin($user); @@ -80,7 +96,7 @@ public function testHelp() { // Call the hook to ensure it is returning text. $name = 'help.page.' . $this::$module_machinename; - $match = $this->createStub(\Drupal\Core\Routing\RouteMatch::class); + $match = $this->createStub(RouteMatch::class); $hook_name = self::$module_machinename . '_help'; $output = $hook_name($name, $match); $this->assertNotEmpty($output, "The help hook should return output $context."); diff --git a/trpcultivate_phenoshare/trpcultivate_phenoshare.module b/trpcultivate_phenoshare/trpcultivate_phenoshare.module index 66f4858a..1b600382 100644 --- a/trpcultivate_phenoshare/trpcultivate_phenoshare.module +++ b/trpcultivate_phenoshare/trpcultivate_phenoshare.module @@ -16,14 +16,10 @@ function trpcultivate_phenoshare_help($route_name, RouteMatchInterface $route_ma case 'help.page.trpcultivate_phenoshare': $output = ''; $output .= '

' . t('About') . '

'; - - $output .= ''; + $output .= ''; return $output; default: } -} \ No newline at end of file +} From caf612c5b5a9664ec164c3b7e38ae6356e98ff64 Mon Sep 17 00:00:00 2001 From: RLT Date: Thu, 23 Jan 2025 16:54:56 -0600 Subject: [PATCH 03/10] Fixes failed install test --- .../tests/src/Functional/InstallTest.php | 30 ++++++++++++++----- .../trpcultivate_phenocollect.module | 5 +--- .../tests/src/Functional/InstallTest.php | 1 + 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/trpcultivate_phenocollect/tests/src/Functional/InstallTest.php b/trpcultivate_phenocollect/tests/src/Functional/InstallTest.php index b2d90ca7..6023e265 100644 --- a/trpcultivate_phenocollect/tests/src/Functional/InstallTest.php +++ b/trpcultivate_phenocollect/tests/src/Functional/InstallTest.php @@ -8,11 +8,16 @@ /** * Simple test to ensure that main page loads with module enabled. * - * @group TripGeno Genetics + * @group TripPheno Collect * @group Installation */ class InstallTest extends ChadoTestBrowserBase { + /** + * Default theme. + * + * @var string + */ protected $defaultTheme = 'stark'; /** @@ -20,21 +25,30 @@ class InstallTest extends ChadoTestBrowserBase { * * @var array */ - protected static $modules = ['help', 'trpcultivate_phenotypes', 'trpcultivate_phenocollect']; + protected static $modules = [ + 'help', + 'trpcultivate_phenotypes', + 'trpcultivate_phenocollect', + ]; /** - * The name of your module in the .info.yml + * The name of your module in the .info.yml. + * + * @var string */ protected static $module_name = 'Phenotypic Data Collection'; /** * The machine name of this module. + * + * @var string */ protected static $module_machinename = 'trpcultivate_phenocollect'; /** - * A small excert from your help page. - * Do not cross newlines. + * A small excert from your help page (Do not cross newlines). + * + * @var string */ protected static $help_text_excerpt = 'tools to backup and upload phenotypic data while it is being collected in a access controlled environment.'; @@ -59,7 +73,7 @@ public function testLoad() { $this->drupalGet('admin/modules'); $status_code = $session->getStatusCode(); $this->assertEquals(200, $status_code, "The module install page should be able to load $context."); - $this->assertSession()->pageTextContains( self::$module_name ); + $this->assertSession()->pageTextContains(self::$module_name); } @@ -72,7 +86,7 @@ public function testHelp() { $some_extected_text = self::$help_text_excerpt; // Ensure we have an admin user. - $permissions = ['access administration pages','administer modules', 'access help pages']; + $permissions = ['access administration pages', 'administer modules', 'access help pages']; $user = $this->drupalCreateUser($permissions); $this->drupalLogin($user); @@ -80,7 +94,7 @@ public function testHelp() { // Call the hook to ensure it is returning text. $name = 'help.page.' . $this::$module_machinename; - $match = $this->createStub(\Drupal\Core\Routing\RouteMatch::class); + $match = $this->createStub(RouteMatch::class); $hook_name = self::$module_machinename . '_help'; $output = $hook_name($name, $match); $this->assertNotEmpty($output, "The help hook should return output $context."); diff --git a/trpcultivate_phenocollect/trpcultivate_phenocollect.module b/trpcultivate_phenocollect/trpcultivate_phenocollect.module index 455f99b4..88060303 100644 --- a/trpcultivate_phenocollect/trpcultivate_phenocollect.module +++ b/trpcultivate_phenocollect/trpcultivate_phenocollect.module @@ -16,10 +16,7 @@ function trpcultivate_phenocollect_help($route_name, RouteMatchInterface $route_ case 'help.page.trpcultivate_phenocollect': $output = ''; $output .= '

' . t('About') . '

'; - - $output .= '
    ' - . '
  • ' . t('Provides tools to backup and upload phenotypic data while it is being collected in a access controlled environment.') . '
  • ' - . '
'; + $output .= '
  • ' . t('Provides tools to backup and upload phenotypic data while it is being collected in a access controlled environment.') . '
'; return $output; diff --git a/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php b/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php index c617c2cc..729c9642 100644 --- a/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php +++ b/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\trpcultivate_phenoshare\Functional; +use Drupal\Core\Routing\RouteMatch; use Drupal\Core\Url; use Drupal\Tests\tripal_chado\Functional\ChadoTestBrowserBase; From 19a0c3d57094b764e98e7e8868ced4a528800a22 Mon Sep 17 00:00:00 2001 From: RLT Date: Fri, 24 Jan 2025 07:24:25 -0600 Subject: [PATCH 04/10] Fixes failed install test --- trpcultivate_phenocollect/tests/src/Functional/InstallTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/trpcultivate_phenocollect/tests/src/Functional/InstallTest.php b/trpcultivate_phenocollect/tests/src/Functional/InstallTest.php index 6023e265..94225b35 100644 --- a/trpcultivate_phenocollect/tests/src/Functional/InstallTest.php +++ b/trpcultivate_phenocollect/tests/src/Functional/InstallTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\trpcultivate_phenocollect\Functional; +use Drupal\Core\Routing\RouteMatch; use Drupal\Core\Url; use Drupal\Tests\tripal_chado\Functional\ChadoTestBrowserBase; From b41a408a45ed57335b21d3ca822e580635f6ca58 Mon Sep 17 00:00:00 2001 From: RLT Date: Fri, 24 Jan 2025 07:49:05 -0600 Subject: [PATCH 05/10] Fixes failed install test --- trpcultivate_phenoshare/tests/src/Functional/InstallTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php b/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php index 729c9642..78ec0f3a 100644 --- a/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php +++ b/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php @@ -50,7 +50,7 @@ class InstallTest extends ChadoTestBrowserBase { * * @var string */ - protected static $help_text_excerpt = 'provides trait pages, downloads and visualization tools to facillitate sharing published phenotypic data with'; + protected static $help_text_excerpt = 'Provides trait pages, downloads and visualization tools to facillitate sharing published phenotypic data with'; /** * Tests that a specific set of pages load with a 200 response. From eca0689d86d67ae3a425bb94e649d07b8700fb38 Mon Sep 17 00:00:00 2001 From: RLT Date: Wed, 29 Jan 2025 15:46:41 -0600 Subject: [PATCH 06/10] Update trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php Co-authored-by: Lacey-Anne Sanderson --- .../Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php b/trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php index 7718b876..392d17bf 100644 --- a/trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php +++ b/trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php @@ -149,7 +149,7 @@ public function form($form, &$form_state) { } // This is a reminder to user about expected phenotypic data. - $phenotypes_minder = $this('Phenotypic data should be filtered for outliers and mis-entries before + $phenotypes_minder = $this->t('Phenotypic data should be filtered for outliers and mis-entries before being uploaded here. Do not upload data that should not be used in the final analysis for a scientific article. Furthermore, data should NOT BE AVERAGED across replicates or site-year.'); \Drupal::messenger()->addWarning($phenotypes_minder); From 7310c510f321a5d86a56b779ec69976f468e5c9f Mon Sep 17 00:00:00 2001 From: RLT Date: Wed, 29 Jan 2025 15:50:09 -0600 Subject: [PATCH 07/10] Update trpcultivate_phenocollect/trpcultivate_phenocollect.module Co-authored-by: Carolyn T Caron --- trpcultivate_phenocollect/trpcultivate_phenocollect.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trpcultivate_phenocollect/trpcultivate_phenocollect.module b/trpcultivate_phenocollect/trpcultivate_phenocollect.module index 88060303..0f5ae8ef 100644 --- a/trpcultivate_phenocollect/trpcultivate_phenocollect.module +++ b/trpcultivate_phenocollect/trpcultivate_phenocollect.module @@ -16,7 +16,7 @@ function trpcultivate_phenocollect_help($route_name, RouteMatchInterface $route_ case 'help.page.trpcultivate_phenocollect': $output = ''; $output .= '

' . t('About') . '

'; - $output .= '
  • ' . t('Provides tools to backup and upload phenotypic data while it is being collected in a access controlled environment.') . '
'; + $output .= '
  • ' . t('Provides tools to backup and upload phenotypic data while it is being collected in an access controlled environment.') . '
'; return $output; From c51f53fde286f6a8ac428deced44ab46f09841e9 Mon Sep 17 00:00:00 2001 From: RLT Date: Wed, 29 Jan 2025 15:50:42 -0600 Subject: [PATCH 08/10] Update trpcultivate_phenoshare/tests/src/Functional/InstallTest.php Co-authored-by: Carolyn T Caron --- trpcultivate_phenoshare/tests/src/Functional/InstallTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php b/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php index 78ec0f3a..0729e52a 100644 --- a/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php +++ b/trpcultivate_phenoshare/tests/src/Functional/InstallTest.php @@ -46,7 +46,7 @@ class InstallTest extends ChadoTestBrowserBase { protected static $module_machinename = 'trpcultivate_phenoshare'; /** - * A small excert from your help page (Do not cross newlines). + * A small excerpt from your help page (Do not cross newlines). * * @var string */ From 7496c576652e917dca4953de171d8e65269e1f90 Mon Sep 17 00:00:00 2001 From: RLT Date: Wed, 29 Jan 2025 15:54:07 -0600 Subject: [PATCH 09/10] Revert importer label text --- .../Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php b/trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php index 392d17bf..9d25e003 100644 --- a/trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php +++ b/trpcultivate_phenoshare/src/Plugin/TripalImporter/TripalCultivatePhenoshareImporter.php @@ -19,7 +19,7 @@ * * @TripalImporter( * id = "trpcultivate-phenotypes-share", - * label = @Translation("Tripal Cultivate: Phenotypic Share Importer"), + * label = @Translation("Tripal Cultivate: Open Science Phenotypic Data"), * description = @Translation("Imports phenotypic data which has already been published or which is ready to be freely shared."), * file_types = {"tsv"}, * upload_description = @Translation("Please provide a data file."), From 16629d3cacc52b6e230f22a5274db75a3e06ca35 Mon Sep 17 00:00:00 2001 From: Lacey-Anne Sanderson Date: Thu, 30 Jan 2025 13:51:19 -0600 Subject: [PATCH 10/10] Make test match change in module. --- trpcultivate_phenocollect/tests/src/Functional/InstallTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trpcultivate_phenocollect/tests/src/Functional/InstallTest.php b/trpcultivate_phenocollect/tests/src/Functional/InstallTest.php index 94225b35..8e9008df 100644 --- a/trpcultivate_phenocollect/tests/src/Functional/InstallTest.php +++ b/trpcultivate_phenocollect/tests/src/Functional/InstallTest.php @@ -51,7 +51,7 @@ class InstallTest extends ChadoTestBrowserBase { * * @var string */ - protected static $help_text_excerpt = 'tools to backup and upload phenotypic data while it is being collected in a access controlled environment.'; + protected static $help_text_excerpt = 'tools to backup and upload phenotypic data while it is being collected in an access controlled environment.'; /** * Tests that a specific set of pages load with a 200 response.