View source
<?php
namespace Drupal\lingotek\Tests;
use Drupal\Core\Url;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;
class LingotekContentTypeBulkDebugTest extends LingotekTestBase {
public static $modules = [
'block',
'node',
];
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType(array(
'type' => 'article',
'name' => 'Article',
));
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_MX')
->save();
$edit = [
'table[node_type][enabled]' => 1,
'table[node_type][profile]' => 'automatic',
];
$this
->drupalPostForm('admin/lingotek/settings', $edit, 'Save', [], [], 'lingoteksettings-tab-configuration-form');
}
public function testDebugOptionsDisplay() {
$this
->drupalLogin($this->rootUser);
$this
->goToConfigBulkManagementForm();
$this
->assertFalse($this
->xpath('//select[@id=:id]//optgroup[@label=:label]', array(
':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
->assertTrue($this
->xpath('//select[@id=:id]//optgroup[@label=:label]', array(
':id' => 'edit-operation',
':label' => 'debug',
)), 'There is a debug group.');
$this
->assertTrue($this
->xpath('//select[@id=:id]//option[@value=:value]', array(
':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('node_type');
$edit = [
'table[article]' => TRUE,
'operation' => 'debug.export',
];
$this
->drupalPostForm(NULL, $edit, t('Execute'));
$this
->assertText('Exports available');
$this
->clickLink('config.node_type.json');
$response = json_decode($this->content, true);
$this
->assertIdentical('Article', $response['node.type.article']['name']);
$this
->assertIdentical(NULL, $response['node.type.article']['description']);
$this
->assertIdentical(NULL, $response['node.type.article']['help']);
$this
->assertIdentical('node_type (config): Article content type', $response['_debug']['title']);
$this
->assertIdentical('automatic', $response['_debug']['profile']);
$this
->assertIdentical('en_US', $response['_debug']['source_locale']);
}
}