-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The initial 1.x release was written without scope for comprehensive automated testing. If we wanted to fully add coverage for this module, here's how to go about completing that story:
- Create
8.x-2.xbranch for development. - Refactor references to
\Drupal::messenger()&$_SESSIONto class properties that can be easily mocked during test setup. - Wrap module functions in Service Class
- The functions for
.modulearen't easily PHPUnit testable since they lean on Drupal's old hook design. We can wrap these functions with method calls to a service class where they can be tested.- Define
tmgmt_lilt.hooks(Drupal\tmgmt_lilt\Hooks) intmgmt_lilt.services.yml - Create static methods that have the same signature as the
.modulefunctions then : tmgmt_lilt_entity_operation(EntityInterface $entity)->entityOperationtmgmt_lilt_form_tmgmt_job_abort_form_alter(&$form, $form_state)->formAlterJobAborttmgmt_lilt_form_tmgmt_job_delete_form_alter(&$form, $form_state)->formAlterJobDeletetmgmt_lilt_form_tmgmt_job_item_edit_form_alter(&$form, $form_state)->formAlterJobItemEdittmgmt_lilt_form_tmgmt_job_edit_form_alter(&$form, $form_state)->formAlterJobEdittmgmt_lilt_form_views_exposed_form_alter(&$form, $form_state)->formAlterViewsExposedtmgmt_lilt_form_tmgmt_job_delete_form_delete_submit(array $form, FormStateInterface $form_state)->formSubmitJobDeletetmgmt_lilt_form_tmgmt_job_item_edit_form_accept_submit(array $form, FormStateInterface $form_state)->formSubmitJobItemEdit
- Define
- Write test cases for static methods.
- The functions for
- Break Lilt API client methods out of
LiltTranslatorLiltTranslatoris taking on 2 responsibilities of calling Lilt APIs & servicing the TMGMT ops. Break them apart and unit test each chunk of functionality in its own test class.- Define
tmgmt_lilt.lilt_api(Drupal\tmgmt_lilt\LiltApi) intmgmt_lilt.services.yml - Add
@config.factorydependency &configproperty so$this->config->get('tmgmt.translator.lilt')->get('settings');can be used to retrieve API creds. - Move 17 methods to
LiltApi:archiveLiltProject($project_id)checkLiltAuth()createLiltProject(JobInterface $job)createLiltRemoteFile($xliff, $name, $project_id)deleteLiltProject($project_id)getLanguages()function getLiltAppUrl(TranslatorInterface $translator)getLiltDocument($document_id)getLiltProject($project_id)- `getTranslationMemories($trglang = '')``
- `getServiceRoot()
logApiRequest($method, $url, $request, $response)request($path, $method = 'GET', array $params = [], $download = FALSE, $code = FALSE, $body = NULL)sendApiRequest($path, $method = 'GET', array $params = [], $download = FALSE, $code = FALSE, $body = NULL)sendFiles(JobItemInterface $job_item, $project_id)setTranslator(TranslatorInterface $translator)
- Define
- Refactor
LiltTranslator&LiltTranslatorUiaccordingly - Write tests for new methods.
- Add more FunctionalJS Testing (not comprehensive):
- Update
./tests.shin https://github.com/lilt/lilt_drupal_env to accept optional Lilt API key - Test Settings Form API Connection
- Test Settings Change Settings
- Test Translation Lilt Provider Exists In New Job
- Test Lilt Provider Job Checkout Options (Due Date/TM/Etc)
- Test Lilt Provider Job Submission
- Test Lilt Provider Job Workflow (Approval/Deletion/Abort/Etc)
- Update
PS: This should probably be broken up into more bite-sized chunks.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request