public function FreelinkingMultilingualTest::testFreelinking in Freelinking 4.0.x
Same name and namespace in other branches
- 8.3 tests/src/Functional/FreelinkingMultilingualTest.php \Drupal\Tests\freelinking\Functional\FreelinkingMultilingualTest::testFreelinking()
Asserts that node title is translated into user's preferred language.
Throws
\Drupal\Core\Entity\EntityStorageException
\Behat\Mink\Exception\ExpectationException
File
- tests/
src/ Functional/ FreelinkingMultilingualTest.php, line 99
Class
- FreelinkingMultilingualTest
- Tests that multilingual capabilities of Freelinking.
Namespace
Drupal\Tests\freelinking\FunctionalCode
public function testFreelinking() {
$edit = [];
$edit['title[0][value]'] = t('Testing all freelinking plugins');
$edit['body[0][value]'] = <<<EOF
<ul>
<li>Default plugin (nodetitle): [[First page]]</li>
<li>Nodetitle: [[nodetitle:First page]]</li>
<li>Nid: [[nid:1]]</li>
</ul>
EOF;
$this
->drupalGet('node/add/page');
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->linkExists('First page', 0, 'Generate default plugin (nodetitle) freelink.');
$this
->assertSession()
->linkExists('First page', 0, 'Generate Nodetitle freelink.');
$this
->assertSession()
->linkExists('First page', 0, 'Generate Nid freelink.');
$this
->drupalLogout();
// Create an user with preferred language of Spanish.
$esUser = $this
->createUser([
'access content',
]);
$esUser
->set('preferred_langcode', 'es');
$esUser
->save();
$this
->assertEquals('es', $esUser
->getPreferredLangcode());
$this
->drupalLogin($esUser);
$this
->drupalGet('/node/3');
$this
->assertSession()
->linkExists('Primera página', 0, 'Generate default plugin (nodetitle) freelink in Spanish.');
$this
->assertSession()
->linkExists('Primera página', 0, 'Generate Nodetitle freelink in Spanish.');
$this
->assertSession()
->linkExists('Primera página', 0, 'Generate Nid freelink in Spanish.');
}