/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->addLanguage('de'); // Override plugin params to query tmgmt_google_test mock service instead // of Google Translate service. $url = Url::fromUri('base://tmgmt_google_test', array('absolute' => TRUE))->toString(); $this->translator = $this->createTranslator(['plugin' => 'google', 'settings' => ['url' => $url]]); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $basic_html_format = FilterFormat::load('basic_html'); $restricted_html_format = FilterFormat::create(array('format' => 'restricted_html', 'name' => 'Restricted HTML')); $restricted_html_format->save(); $full_html_format = FilterFormat::create(array('format' => 'full_html', 'name' => 'Full HTML')); $full_html_format->save(); $this->loginAsAdmin(['access content overview', 'administer tmgmt', 'translate any entity', 'edit any translatable_node content', $basic_html_format->getPermissionName(), $restricted_html_format->getPermissionName(), $full_html_format->getPermissionName()]); }
/** * {@inheritdoc} */ function setUp() { parent::setUp(); // Login as admin to be able to set environment variables. $this->loginAsAdmin(); $this->addLanguage('es'); $this->addLanguage('sk'); $this->addLanguage('cs'); // Login as translator only with limited permissions to run these tests. $this->loginAsTranslator(array('access administration pages', 'create translation jobs', 'submit translation jobs'), TRUE); }
/** * {@inheritdoc} */ function setUp() { parent::setUp(); $this->langcode = 'de'; $this->context = 'default'; file_unmanaged_copy(drupal_get_path('module', 'tmgmt_locale') . '/tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE); $file = new \stdClass(); $file->uri = \Drupal::service('file_system')->realpath(drupal_get_path('module', 'tmgmt_locale') . '/tests/test.xx.po'); $file->langcode = $this->langcode; Gettext::fileToDatabase($file, array()); $this->addLanguage($this->langcode); $this->addLanguage('gsw-berne'); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->addLanguage('de'); $this->translator = $this->createTranslator(['plugin' => 'microsoft', 'settings' => ['url' => URL::fromUri('base://tmgmt_microsoft_mock/v2/Http.svc', array('absolute' => TRUE))->toString()]]); }
/** * {@inheritdoc} */ function setUp() { parent::setUp(); $this->loginAsAdmin(); $this->addLanguage('de'); }
/** * Tests creating and deleting a translator. */ function testTranslatorHandling() { // Create a translator for later deletion. $translator = parent::createTranslator(); // Does the translator exist in the listing? $this->drupalGet('admin/tmgmt/translators'); $this->assertText($translator->label()); $this->assertEqual(count($this->xpath('//tbody/tr')), 2); // Create job, attach to the translator and activate. $job = $this->createJob(); $job->settings = array(); $job->save(); $job->setState(Job::STATE_ACTIVE); $item = $job->addItem('test_source', 'test', 1); $this->drupalGet('admin/tmgmt/items/' . $item->id()); $this->assertText(t('(Undefined)')); $job->translator = $translator; $job->save(); // Try to delete the translator, should fail because of active job. $delete_url = '/admin/tmgmt/translators/manage/' . $translator->id() . '/delete'; $this->drupalGet($delete_url); $this->assertResponse(403); // Create a continuous job. $continuous = $this->createJob('en', 'de', 1, ['label' => 'Continuous', 'job_type' => Job::TYPE_CONTINUOUS]); $continuous->translator = $translator; $continuous->save(); // Delete a provider using an API call and assert that active job and its // job item used by deleted translator were aborted. $translator->delete(); /** @var \Drupal\tmgmt\JobInterface $job */ $job = Job::load($job->id()); $continuous = Job::load($continuous->id()); $this->assertEqual($job->getState(), Job::STATE_ABORTED); $item = $job->getMostRecentItem('test_source', 'test', 1); $this->assertEqual($item->getState(), JobItem::STATE_ABORTED); $this->assertEqual($continuous->getState(), Job::STATE_ABORTED); // Delete a finished job. $translator = parent::createTranslator(); $job = $this->createJob(); $job->translator = $translator; $item = $job->addItem('test_source', 'test', 2); $job->setState(Job::STATE_FINISHED); $delete_url = '/admin/tmgmt/translators/manage/' . $translator->id() . '/delete'; $this->drupalPostForm($delete_url, array(), 'Delete'); $this->assertText(t('Add provider')); // Check if the list of translators has 1 row. $this->assertEqual(count($this->xpath('//tbody/tr')), 1); $this->assertText(t('@label has been deleted.', array('@label' => $translator->label()))); // Check if the clone action works. $this->clickLink('Clone'); $edit = array('name' => $translator->id() . '_clone'); $this->drupalPostForm(NULL, $edit, 'Save'); // Check if the list of translators has 2 row. $this->assertEqual(count($this->xpath('//tbody/tr')), 2); $this->assertText('configuration has been created'); // Assert that the job works and there is a text saying that the translator // is missing. $this->drupalGet('admin/tmgmt/jobs/' . $job->id()); $this->assertText(t('The job has no provider assigned.')); // Assert that also the job items are working. $this->drupalGet('admin/tmgmt/items/' . $item->id()); $this->assertText(t('(Missing)')); // Testing the translators form with no installed translator plugins. // Uninstall the test module (which provides a translator). \Drupal::service('module_installer')->uninstall(array('tmgmt_test'), FALSE); // Assert that job deletion works correctly. \Drupal::service('module_installer')->install(array('tmgmt_file'), FALSE); $this->drupalPostForm('/admin/tmgmt/jobs/' . $job->id() . '/delete', [], t('Delete')); $this->assertResponse(200); $this->assertText(t('The translation job @value has been deleted.', array('@value' => $job->label()))); \Drupal::service('module_installer')->uninstall(array('tmgmt_file'), FALSE); // Get the overview. $this->drupalGet('admin/tmgmt/translators'); $this->assertNoText(t('Add provider')); $this->assertText(t('There are no provider plugins available. Please install a provider plugin.')); }