diff --git a/sources/content/src/Tests/ContentEntitySourceUiTest.php b/sources/content/src/Tests/ContentEntitySourceUiTest.php index 195b990..aa7c2d5 100644 --- a/sources/content/src/Tests/ContentEntitySourceUiTest.php +++ b/sources/content/src/Tests/ContentEntitySourceUiTest.php @@ -28,7 +28,7 @@ class ContentEntitySourceUiTest extends EntityTestBase { * * @var array */ - public static $modules = array('tmgmt_content', 'comment', 'ckeditor', 'tmgmt_local'); + public static $modules = array('tmgmt_content', 'comment', 'ckeditor'); /** * {@inheritdoc} @@ -85,12 +85,8 @@ class ContentEntitySourceUiTest extends EntityTestBase { $this->assertText(t('One job needs to be checked out.')); $this->assertText($node->getTitle()); - $edit = [ - 'translator' => 'test_translator', - ]; - // Submit. - $this->drupalPostForm(NULL, $edit, t('Submit to provider')); + $this->drupalPostForm(NULL, array(), t('Submit to provider')); // Make sure that we're back on the translate tab. $this->assertEqual($node->url('canonical', array('absolute' => TRUE)) . '/translations', $this->getUrl()); @@ -144,10 +140,7 @@ class ContentEntitySourceUiTest extends EntityTestBase { // Verify that we are on the checkout page. $this->assertText(t('One job needs to be checked out.')); $this->assertText($node->getTitle()); - $edit = array( - 'translator' => 'test_translator', - ); - $this->drupalPostForm(NULL, $edit, t('Submit to provider')); + $this->drupalPostForm(NULL, array(), t('Submit to provider')); // Make sure that we're back on the originally defined destination URL. $this->assertEqual($node->url('canonical', array('absolute' => TRUE)), $this->getUrl()); @@ -195,10 +188,7 @@ class ContentEntitySourceUiTest extends EntityTestBase { 'languages[de]' => TRUE, ); $this->drupalPostForm(NULL, $edit, t('Request translation')); - $edit = array( - 'translator' => 'test_translator', - ); - $this->drupalPostForm(NULL, $edit, t('Submit to provider')); + $this->drupalPostForm(NULL, array(), t('Submit to provider')); $this->clickLink(t('Needs review')); // Delete the node and assert that the job can not be accepted. @@ -242,12 +232,9 @@ class ContentEntitySourceUiTest extends EntityTestBase { // Submit all jobs. $this->assertText($node->getTitle()); - $edit = [ - 'translator' => $default_translator->id(), - ]; - $this->drupalPostForm(NULL, $edit, t('Submit to provider and continue')); + $this->drupalPostForm(NULL, array(), t('Submit to provider and continue')); $this->assertText($node->getTitle()); - $this->drupalPostForm(NULL, $edit, t('Submit to provider')); + $this->drupalPostForm(NULL, array(), t('Submit to provider')); // Make sure that we're back on the translate tab. $this->assertEqual($node->url('canonical', array('absolute' => TRUE)) . '/translations', $this->getUrl()); @@ -341,15 +328,11 @@ class ContentEntitySourceUiTest extends EntityTestBase { // Verify that we are on the translate tab. $this->assertText(t('2 jobs need to be checked out.')); - $edit = [ - 'translator' => $default_translator->id(), - ]; - // Submit all jobs. $this->assertText($comment->getSubject()); - $this->drupalPostForm(NULL, $edit, t('Submit to provider and continue')); + $this->drupalPostForm(NULL, array(), t('Submit to provider and continue')); $this->assertText($comment->getSubject()); - $this->drupalPostForm(NULL, $edit, t('Submit to provider')); + $this->drupalPostForm(NULL, array(), t('Submit to provider')); // Make sure that we're back on the translate tab. $this->assertUrl($comment->url('canonical', array('absolute' => TRUE)) . '/translations'); @@ -758,61 +741,4 @@ class ContentEntitySourceUiTest extends EntityTestBase { $this->assertText($updated_body, 'Source updated correctly.'); } - /** - * Test local translator with content entity sources. - */ - public function testLocalTranslatorWithContentEntitySource() { - $user = $this->loginAsAdmin([ - 'administer translation tasks', - 'provide translation services', - 'view the administration theme', - 'administer themes', - 'translate any entity', - 'create content translations', - 'view own unpublished content', - ]); - - $edit = array( - 'tmgmt_translation_skills[0][language_from]' => 'en', - 'tmgmt_translation_skills[0][language_to]' => 'de', - ); - $this->drupalPostForm('user/' . $user->id() . '/edit', $edit, t('Save')); - - // Create an english source node. - $node = $this->createTranslatableNode('page', 'en'); - $node->setPublished(FALSE); - $node->save(); - - // Go to the translate tab. - $this->drupalGet('node/' . $node->id()); - $this->clickLink('Translate'); - - // Request a translation for german. - $edit = array( - 'languages[de]' => TRUE, - ); - $this->drupalPostForm(NULL, $edit, t('Request translation')); - $this->assertText($node->getTitle()); - - // Submit job. - $edit = [ - 'settings[translator]' => $user->id(), - ]; - $this->drupalPostForm(NULL, $edit, t('Submit to provider')); - - $this->drupalLogin($user); - - // Go to local task item form. - $this->drupalGet('translate'); - $this->clickLink(t('View')); - $this->clickLink(t('Translate')); - - // Assert source link - $this->assertLink($node->getTitle()); - - // Test that local translator can access an unpublished node. - $this->clickLink($node->getTitle()); - $this->assertText($node->getTitle()); - } - } diff --git a/translators/tmgmt_local/src/Form/LocalTaskForm.php b/translators/tmgmt_local/src/Form/LocalTaskForm.php index 64a30bb..d52f814 100644 --- a/translators/tmgmt_local/src/Form/LocalTaskForm.php +++ b/translators/tmgmt_local/src/Form/LocalTaskForm.php @@ -58,7 +58,7 @@ class LocalTaskForm extends ContentEntityForm { $form['info'] = array( '#type' => 'container', - '#attributes' => array('class' => array('tmgmt-ui-localTask-info', 'clearfix')), + '#attributes' => array('class' => array('tmgmt-local-task-info', 'clearfix')), '#weight' => 0, '#tree' => TRUE, ); diff --git a/translators/tmgmt_local/src/Form/LocalTaskItemForm.php b/translators/tmgmt_local/src/Form/LocalTaskItemForm.php index d91f6a9..d93b982 100644 --- a/translators/tmgmt_local/src/Form/LocalTaskItemForm.php +++ b/translators/tmgmt_local/src/Form/LocalTaskItemForm.php @@ -47,7 +47,7 @@ class LocalTaskItemForm extends ContentEntityForm { $form['info'] = array( '#type' => 'container', - '#attributes' => array('class' => array('tmgmt-ui-localTask-info', 'clearfix')), + '#attributes' => array('class' => array('tmgmt-local-task-info', 'clearfix')), '#weight' => 0, ); diff --git a/translators/tmgmt_local/src/Tests/LocalTranslatorPreviewTest.php b/translators/tmgmt_local/src/Tests/LocalTranslatorPreviewTest.php index 06f38cf..5f1db37 100755 --- a/translators/tmgmt_local/src/Tests/LocalTranslatorPreviewTest.php +++ b/translators/tmgmt_local/src/Tests/LocalTranslatorPreviewTest.php @@ -24,9 +24,14 @@ class LocalTranslatorPreviewTest extends LocalTranslatorTestBase { * Test the preview of TMGMT local. */ public function testPreview() { + $user_permissions = $this->localManagerPermissions; + $user_permissions[] = 'view own unpublished content'; + $this->loginAsAdmin($user_permissions); // Create translatable node. $this->createNodeType('article', 'Article', TRUE); $node = $this->createTranslatableNode('article', 'en'); + $node->setPublished(FALSE); + $node->save(); $translator = Translator::load('local'); $job = $this->createJob('en', 'de'); $job->translator = $translator; @@ -34,8 +39,6 @@ class LocalTranslatorPreviewTest extends LocalTranslatorTestBase { $job_item = tmgmt_job_item_create('content', $node->getEntityTypeId(), $node->id(), array('tjid' => $job->id())); $job_item->save(); - // Create another local translator with the required abilities. - $this->loginAsAdmin($this->localManagerPermissions); // Configure language abilities. $edit = array( 'tmgmt_translation_skills[0][language_from]' => 'en', @@ -62,6 +65,17 @@ class LocalTranslatorPreviewTest extends LocalTranslatorTestBase { $this->assertResponse(200); $this->assertText($translation1); $this->assertText($translation2); + + $this->drupalGet('translate'); + $this->clickLink('View'); + $this->clickLink('Translate'); + + // Assert source link + $this->assertLink($node->getTitle()); + + // Test that local translator can access an unpublished node. + $this->clickLink($node->getTitle()); + $this->assertText($node->getTitle()); } }