View source
<?php
namespace Drupal\Tests\lingotek\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\language\Entity\ContentLanguageSettings;
class LingotekConfigSubscriberTest extends LingotekTestBase {
public static $modules = [
'block',
'node',
];
protected function setUp() : void {
parent::setUp();
$this
->drupalPlaceBlock('page_title_block', [
'id' => 'block_1',
'label' => 'Title block',
'region' => 'content',
'weight' => -5,
]);
$this
->drupalPlaceBlock('local_tasks_block', [
'id' => 'block_2',
'label' => 'Local tasks block',
'region' => 'content',
'weight' => -10,
]);
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_MX')
->save();
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
$this
->rebuildContainer();
$this
->saveLingotekContentTranslationSettingsForNodeTypes();
\Drupal::state()
->set('lingotek.uploaded_content_type', 'block.title');
}
public function testDeletingTranslatedConfig() {
$this
->goToConfigBulkManagementForm('block');
$this
->clickLink('EN');
$data = json_decode(\Drupal::state()
->get('lingotek.uploaded_content', '[]'), TRUE);
$this
->verbose(var_export($data, TRUE));
$this
->assertText('Title block uploaded successfully');
$this
->clickLink('ES');
$this
->clickLink('ES');
$this
->clickLink('ES');
$this
->assertText('Translation to es_MX downloaded successfully');
$this
->drupalGet('/admin/modules');
$this
->assertSession()
->checkboxChecked('modules[block][enable]');
$this
->clickLink('Uninstall');
$edit = [
'uninstall[block]' => '1',
];
$this
->drupalPostForm(NULL, $edit, 'Uninstall');
$this
->assertText('The following modules will be completely uninstalled from your site, and all data from these modules will be lost!');
$this
->assertSession()
->responseContains('Block');
$this
->assertSession()
->responseContains('The listed configuration will be deleted.');
$this
->assertSession()
->responseContains('Lingotek Config Metadata');
$this
->assertSession()
->responseContains('block.block_1');
$this
->drupalPostForm(NULL, [], 'Uninstall');
$this
->assertSession()
->responseContains('The selected modules have been uninstalled.');
}
}