View source
<?php
namespace Drupal\Tests\lingotek\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
class LingotekConfigEntityBulkProfileTest extends LingotekTestBase {
public static $modules = [
'block',
'node',
];
protected $node;
protected function setUp() : void {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_MX')
->save();
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
\Drupal::state()
->set('lingotek.uploaded_content_type', 'content_type');
}
public function testChangeTranslationProfileBulk() {
\Drupal::state()
->set('lingotek.uploaded_content_type', 'system.site');
$this
->drupalLogin($this->rootUser);
$this
->goToConfigBulkManagementForm('node_type');
$basepath = \Drupal::request()
->getBasePath();
$edit = [
'table[article]' => TRUE,
$this
->getBulkOperationFormName() => 'change_profile:automatic',
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$automatic_profile = $this
->xpath("//td[contains(text(), 'Automatic')]");
$this
->assertEqual(count($automatic_profile), 1, 'Automatic Profile set');
$edit = [
'table[article]' => TRUE,
$this
->getBulkOperationFormName() => 'change_profile:manual',
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$manual_profile = $this
->xpath("//td[contains(text(), 'Manual')]");
$this
->assertEqual(count($manual_profile), 1, 'Manual Profile set');
$edit = [
'table[article]' => TRUE,
$this
->getBulkOperationFormName() => 'change_profile:disabled',
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$disabled_profile = $this
->xpath("//td[contains(text(), 'Disabled')]");
$this
->assertEqual(count($disabled_profile), 1, 'Disabled Profile set');
$edit = [
'table[article]' => TRUE,
$this
->getBulkOperationFormName() => 'change_profile:automatic',
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$automatic_profile = $this
->xpath("//td[contains(text(), 'Automatic')]");
$this
->assertEqual(count($automatic_profile), 1, 'Automatic Profile set');
}
public function testChangeTranslationProfileBulkAfterCancelling() {
$this
->drupalLogin($this->rootUser);
$this
->goToConfigBulkManagementForm('node_type');
$basepath = \Drupal::request()
->getBasePath();
$edit = [
'table[article]' => TRUE,
$this
->getBulkOperationFormName() => $this
->getBulkOperationNameForCancel('node'),
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$edit = [
'table[article]' => TRUE,
$this
->getBulkOperationFormName() => 'change_profile:automatic',
];
$this
->drupalPostForm(NULL, $edit, $this
->getApplyActionsButtonLabel());
$automatic_profile = $this
->xpath("//td[contains(text(), 'Automatic')]");
$this
->assertEqual(count($automatic_profile), 1, 'Automatic Profile set');
}
}