View source
<?php
namespace Drupal\Tests\lingotek\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
class LingotekSystemSiteBulkDebugTest extends LingotekTestBase {
public static $modules = [
'block',
'node',
];
protected $node;
protected function setUp() : void {
parent::setUp();
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_MX')
->save();
}
public function testDebugOptionsDisplay() {
$this
->drupalLogin($this->rootUser);
$this
->goToConfigBulkManagementForm();
$this
->assertEmpty($this
->xpath('//select[@id=:id]//optgroup[@label=:label]', [
':id' => 'edit-operation',
':label' => 'debug',
]), 'There is no debug group.');
$this
->drupalGet('admin/lingotek/settings');
$this
->drupalPostForm(NULL, [], t('Enable debug operations'));
$this
->goToConfigBulkManagementForm();
$this
->assertNotEmpty($this
->xpath('//select[@id=:id]//optgroup[@label=:label]', [
':id' => 'edit-operation',
':label' => 'debug',
]), 'There is a debug group.');
$this
->assertNotEmpty($this
->xpath('//select[@id=:id]//option[@value=:value]', [
':id' => 'edit-operation',
':value' => 'debug.export',
]), 'There is a debug export option.');
}
public function testDebugExport() {
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('admin/lingotek/settings');
$this
->drupalPostForm(NULL, [], t('Enable debug operations'));
$this
->goToConfigBulkManagementForm();
$edit = [
'table[system.site_information_settings]' => TRUE,
$this
->getBulkOperationFormName() => 'debug.export',
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$this
->assertText('Exports available');
$this
->clickLink('config.system.site_information_settings.json');
$response = json_decode($this
->getSession()
->getPage()
->getContent(), TRUE);
$this
->assertIdentical('Drupal', $response['system.site']['name']);
$this
->assertIdentical('', $response['system.site']['slogan']);
$this
->assertIdentical('system.site_information_settings (config): System information', $response['_debug']['title']);
$this
->assertIdentical('manual', $response['_debug']['profile']);
$this
->assertIdentical('en_US', $response['_debug']['source_locale']);
}
}