public function LingotekConfigTranslationPreSaveHookTest::testBlockTranslation in Lingotek Translation 3.5.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/LingotekConfigTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigTranslationPreSaveHookTest::testBlockTranslation()
- 4.0.x tests/src/Functional/LingotekConfigTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigTranslationPreSaveHookTest::testBlockTranslation()
- 3.0.x tests/src/Functional/LingotekConfigTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigTranslationPreSaveHookTest::testBlockTranslation()
- 3.1.x tests/src/Functional/LingotekConfigTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigTranslationPreSaveHookTest::testBlockTranslation()
- 3.2.x tests/src/Functional/LingotekConfigTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigTranslationPreSaveHookTest::testBlockTranslation()
- 3.3.x tests/src/Functional/LingotekConfigTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigTranslationPreSaveHookTest::testBlockTranslation()
- 3.4.x tests/src/Functional/LingotekConfigTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigTranslationPreSaveHookTest::testBlockTranslation()
- 3.6.x tests/src/Functional/LingotekConfigTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigTranslationPreSaveHookTest::testBlockTranslation()
- 3.7.x tests/src/Functional/LingotekConfigTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigTranslationPreSaveHookTest::testBlockTranslation()
- 3.8.x tests/src/Functional/LingotekConfigTranslationPreSaveHookTest.php \Drupal\Tests\lingotek\Functional\LingotekConfigTranslationPreSaveHookTest::testBlockTranslation()
Tests that a block can be translated.
File
- tests/
src/ Functional/ LingotekConfigTranslationPreSaveHookTest.php, line 41
Class
- LingotekConfigTranslationPreSaveHookTest
- Tests the Lingotek config translation pre save hook.
Namespace
Drupal\Tests\lingotek\FunctionalCode
public function testBlockTranslation() {
// Login as admin.
$this
->drupalLogin($this->rootUser);
// Place the block with title that contains a token.
$block = $this
->drupalPlaceBlock('system_powered_by_block', [
'id' => 'powered_by_block',
'label' => t('Title with [site:name]'),
'label_display' => TRUE,
]);
$block_id = $block
->id();
// Check that [token] is encoded via hook_lingotek_config_entity_document_upload().
// @see lingotek_test_lingotek_config_entity_document_upload()
$data = json_decode(\Drupal::state()
->get('lingotek.uploaded_content', '[]'), TRUE);
$this
->verbose(var_export($data, TRUE));
$this
->assertEqual($data['settings.label'], 'Title with [***SITE:NAME***]');
// Translate the block using the Lingotek translate config admin form.
$this
->drupalGet("admin/structure/block/manage/{$block_id}/translate");
$this
->clickLink('Upload');
$this
->clickLink('Request translation');
$this
->clickLink('Check Download');
$this
->clickLink('Download');
// Check that [token] is decoded via hook_lingotek_config_entity_translation_presave().
// @see lingotek_test_lingotek_config_entity_translation_presave()
$this
->drupalGet("admin/structure/block/manage/{$block_id}/translate/es/edit");
$this
->assertFieldByName("translation[config_names][block.block.{$block_id}][settings][label]", 'Título con [site:name]');
$this
->drupalGet('es/user');
$this
->assertText('Título con [site:name]');
}