View source
<?php
namespace Drupal\lingotek\Tests;
use Drupal\node\NodeInterface;
class LingotekSystemSiteLocaleTranslationTest extends LingotekTestBase {
public static $modules = [
'block',
'node',
'image',
'comment',
];
protected $node;
protected function setUp() {
parent::setUp();
$this
->drupalPlaceBlock('local_tasks_block');
$this
->drupalPlaceBlock('page_title_block');
$post = [
'code' => 'es_ES',
'language' => 'Spanish',
'native' => 'Español',
'direction' => '',
];
$this
->drupalPost('/admin/lingotek/dashboard_endpoint', 'application/json', $post);
$post = [
'code' => 'es_AR',
'language' => 'Spanish',
'native' => 'Español',
'direction' => '',
];
$this
->drupalPost('/admin/lingotek/dashboard_endpoint', 'application/json', $post);
drupal_static_reset();
\Drupal::entityManager()
->clearCachedDefinitions();
\Drupal::service('entity.definition_update_manager')
->applyUpdates();
$this
->rebuildContainer();
}
public function testSystemSiteTranslation() {
\Drupal::state()
->set('lingotek.uploaded_content_type', 'system.site');
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('/admin/config/regional/config-translation');
$this
->clickLink(t('Translate'), 2);
$this
->clickLink(t('Upload'));
$this
->assertText(t('System information uploaded successfully'));
$data = json_decode(\Drupal::state()
->get('lingotek.uploaded_content', '[]'), TRUE);
$this
->assertEqual(1, count($data));
$this
->assertTrue(array_key_exists('system.site', $data));
$this
->assertEqual(2, count($data['system.site']));
$this
->assertTrue(array_key_exists('name', $data['system.site']));
$this
->assertTrue(array_key_exists('slogan', $data['system.site']));
$uploaded_url = \Drupal::state()
->get('lingotek.uploaded_url');
$this
->assertIdentical(NULL, $uploaded_url, 'The automatic profile was used.');
$used_profile = \Drupal::state()
->get('lingotek.used_profile');
$this
->assertIdentical('automatic', $used_profile, 'The automatic profile was used.');
$this
->clickLink(t('Check upload status'));
$this
->assertText(t('System information status checked successfully'));
$this
->clickLinkHelper(t('Request translation'), 0, '//a[normalize-space()=:label and contains(@href,\'es_AR\')]');
$this
->assertText(t('Translation to es_AR requested successfully'));
$this
->assertIdentical('es_AR', \Drupal::state()
->get('lingotek.added_target_locale'));
$this
->clickLink(t('Check Download'));
$this
->assertText(t('Translation to es_AR checked successfully'));
$this
->clickLink('Download');
$this
->assertText(t('Translation to es_AR downloaded successfully'));
$basepath = \Drupal::request()
->getBasePath();
$this
->assertLinkByHref($basepath . '/admin/config/system/site-information/translate/es-ar/edit');
}
}