LingotekConfigTranslationPreSaveHookTest.php in Lingotek Translation 8
File
src/Tests/LingotekConfigTranslationPreSaveHookTest.php
View source
<?php
namespace Drupal\lingotek\Tests;
use Drupal\language\Entity\ConfigurableLanguage;
class LingotekConfigTranslationPreSaveHookTest extends LingotekTestBase {
public static $modules = [
'block',
];
protected function setUp() {
parent::setUp();
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_MX')
->save();
$edit = [
'table[block][enabled]' => 1,
'table[block][profile]' => 'automatic',
];
$this
->drupalPostForm('admin/lingotek/settings', $edit, 'Save', [], [], 'lingoteksettings-tab-configuration-form');
}
public function testBlockTranslation() {
$this
->drupalLogin($this->rootUser);
$block = $this
->drupalPlaceBlock('system_powered_by_block', array(
'label' => t('Title with [site:name]'),
));
$block_id = $block
->id();
$data = json_decode(\Drupal::state()
->get('lingotek.uploaded_content', '[]'), true);
$this
->assertEqual($data['settings.label'], 'Title with [***c2l0ZTpuYW1l***]');
$this
->drupalGet("admin/lingotek/config/upload/block/{$block_id}");
$this
->drupalGet("admin/lingotek/config/request/block/{$block_id}/es_ES");
$this
->drupalGet("admin/lingotek/config/check_download/block/{$block_id}/es_ES");
$this
->drupalGet("admin/lingotek/config/download/block/{$block_id}/es_ES");
$this
->drupalGet("admin/structure/block/manage/{$block_id}/translate/es/edit");
$this
->assertFieldByName("translation[config_names][block.block.{$block_id}][settings][label]", 'Title with [site:name]');
}
}