Base class for local translator tests.
Expanded class hierarchy of LocalTranslatorTestBase
abstract class LocalTranslatorTestBase extends TMGMTTestBase {
use TmgmtEntityTestTrait;
/**
* Translator user.
*
* @var object
*/
protected $assignee;
protected $localTranslatorPermissions = array(
'provide translation services',
);
protected $localManagerPermissions = [
'administer translation tasks',
'provide translation services',
'view the administration theme',
'administer themes',
];
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'user',
'tmgmt',
'tmgmt_language_combination',
'tmgmt_local',
];
/**
* {@inheritdoc}
*/
public function setUp() : void {
parent::setUp();
$this
->loginAsAdmin();
$this
->addLanguage('de');
$this
->drupalPlaceBlock('system_breadcrumb_block');
}
/**
* Asserts task status icon.
*
* @param int $row
* The row of the item you want to check.
* @param string $view
* The view where we want to assert.
* @param string $overview
* The overview table to check.
* @param int $state
* The expected state.
*/
protected function assertTaskStatusIcon($row, $view, $overview, $state) {
$result = $this
->xpath('//*[@id="views-form-tmgmt-local-' . $view . '-' . $overview . '"]/table/tbody/tr[' . $row . ']/td[2]/img')[0];
$this
->assertEquals($state, $result
->getAttribute('title'));
}
/**
* Asserts task item status icon.
*
* @param string $row
* Identifier for the row.
* @param int $state
* The expected state.
*/
protected function assertTaskItemStatusIcon($row, $state) {
$result = $this
->xpath('//*[@id="edit-items"]/div/div/table/tbody/tr[td//text()[contains(., :row)]]/td[1]/img', [
':row' => $row,
])[0];
$this
->assertEquals($state, $result
->getAttribute('title'));
}
/**
* Asserts the task progress bar.
*
* @param int $row
* The row of the item you want to check.
* @param string $overview
* The overview to be checked.
* @param int $untranslated
* The amount of untranslated items.
* @param int $translated
* The amount of translated items.
* @param int $completed
* The amount of completed items.
*/
protected function assertTaskProgress($row, $overview, $untranslated, $translated, $completed) {
$result = $this
->xpath('//*[@id="views-form-tmgmt-local-task-overview-' . $overview . '"]/table/tbody/tr[' . $row . ']/td[3]')[0];
$div_number = 1;
if ($untranslated > 0) {
$this
->assertEquals('tmgmt-local-progress-untranslated', $result
->find('css', "div > div:nth-child({$div_number})")
->getAttribute('class'));
$div_number++;
}
else {
$this
->assertNotEquals('tmgmt-local-progress-untranslated', $result
->find('css', "div > div:nth-child({$div_number})")
->getAttribute('class'));
}
if ($translated > 0) {
$this
->assertEquals('tmgmt-local-progress-translated', $result
->find('css', "div > div:nth-child({$div_number})")
->getAttribute('class'));
$div_number++;
}
else {
$child = $result
->find('css', "div > div:nth-child({$div_number})");
$this
->assertTrue(!$child || $child
->getAttribute('class'), 'tmgmt-local-progress-translated');
}
if ($completed > 0) {
$this
->assertEquals('tmgmt-local-progress-completed', $result
->find('css', "div > div:nth-child({$div_number})")
->getAttribute('class'));
}
else {
$child = $result
->find('css', "div > div:nth-child({$div_number})");
$this
->assertTrue(!$child || $child
->getAttribute('class'), 'tmgmt-local-progress-completed');
}
$title = t('Untranslated: @untranslated, translated: @translated, completed: @completed.', array(
'@untranslated' => $untranslated,
'@translated' => $translated,
'@completed' => $completed,
));
$this
->assertEquals($title, $result
->find('css', 'div')
->getAttribute('title'));
}
/**
* Asserts the task item progress bar.
*
* @param string $row
* Identifier for the row.
* @param int $untranslated
* The amount of untranslated items.
* @param int $translated
* The amount of translated items.
* @param int $completed
* The amount of completed items.
*/
protected function assertTaskItemProgress($row, $untranslated, $translated, $completed) {
$result = $this
->xpath('//*[@id="edit-items"]/div/div/table/tbody/tr[td//text()[contains(., :row)]]/td[2]', [
':row' => $row,
])[0];
$div_number = 1;
if ($untranslated > 0) {
$this
->assertEquals('tmgmt-local-progress-untranslated', $result
->find('css', "div > div:nth-child({$div_number})")
->getAttribute('class'));
$div_number++;
}
else {
$this
->assertNotEquals('tmgmt-local-progress-untranslated', $result
->find('css', "div > div:nth-child({$div_number})")
->getAttribute('class'));
}
if ($translated > 0) {
$this
->assertEquals('tmgmt-local-progress-translated', $result
->find('css', "div > div:nth-child({$div_number})")
->getAttribute('class'));
$div_number++;
}
else {
$child = $result
->find('css', "div > div:nth-child({$div_number})");
$this
->assertTrue(!$child || $child
->getAttribute('class'), 'tmgmt-local-progress-translated');
}
if ($completed > 0) {
$this
->assertEquals('tmgmt-local-progress-completed', $result
->find('css', "div > div:nth-child({$div_number})")
->getAttribute('class'));
}
else {
$child = $result
->find('css', "div > div:nth-child({$div_number})");
$this
->assertTrue(!$child || $child
->getAttribute('class'), 'tmgmt-local-progress-completed');
}
$title = t('Untranslated: @untranslated, translated: @translated, completed: @completed.', array(
'@untranslated' => $untranslated,
'@translated' => $translated,
'@completed' => $completed,
));
$this
->assertEquals($title, $result
->find('css', 'div')
->getAttribute('title'));
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LocalTranslatorTestBase:: |
public | function |
Overrides DrupalWebTestCase::setUp() Overrides TMGMTTestBase:: |
|
LocalTranslatorTestBase:: |
protected | function | Asserts task status icon. | |
LocalTranslatorTestBase:: |
protected | function | Asserts task item status icon. | |
LocalTranslatorTestBase:: |
protected | function | Asserts the task progress bar. | |
LocalTranslatorTestBase:: |
protected | function | Asserts the task item progress bar. | |
TmgmtEntityTestTrait:: |
function | Creates node type with several text fields with different cardinality. | ||
TmgmtEntityTestTrait:: |
function | Creates taxonomy vocabulary with custom fields. | ||
TmgmtEntityTestTrait:: |
function | Creates fields of type text and text_with_summary of different cardinality. | ||
TmgmtEntityTestTrait:: |
protected | function | Creates a node of a given bundle. | |
TmgmtEntityTestTrait:: |
function | Creates a taxonomy term of a given vocabulary. | ||
TmgmtTestTrait:: |
function | Will create a user with admin permissions and log it in. | ||
TmgmtTestTrait:: |
function | Will create a user with translator permissions and log it in. | ||
TmgmtTestTrait:: |
function | Creates, saves and returns a translator. | ||
TmgmtTestTrait:: |
function | Creates, saves and returns a translation job. | ||
TmgmtTestTrait:: |
function | Sets the proper environment. | ||
TmgmtTestTrait:: |
function | Asserts job item language codes. | ||
TmgmtTestTrait:: |
function | Clicks on an image link with the provided title attribute. | ||
TmgmtTestTrait:: |
protected | function | Asserts text in the page with an xpath expression. | |
LocalTranslatorTestBase:: |
protected | property | Translator user. | |
LocalTranslatorTestBase:: |
protected | property | ||
LocalTranslatorTestBase:: |
protected | property | ||
LocalTranslatorTestBase:: |
protected static | property |
Modules to enable. Overrides TMGMTTestBase:: |
2 |
TmgmtEntityTestTrait:: |
public | property | ||
TMGMTTestBase:: |
protected | property | A default translator using the test translator. | |
TMGMTTestBase:: |
protected | property | ||
TmgmtTestTrait:: |
protected | property | List of permissions used by loginAsAdmin(). | |
TmgmtTestTrait:: |
protected | property | Drupal user object created by loginAsAdmin(). | |
TmgmtTestTrait:: |
protected | property | List of permissions used by loginAsTranslator(). | |
TmgmtTestTrait:: |
protected | property | Drupal user object created by loginAsTranslator(). | |
TmgmtTestTrait:: |
protected | property | The language weight for new languages. |