diff --git a/core/modules/views/src/Tests/Handler/FieldDropButtonTest.php b/core/modules/views/src/Tests/Handler/FieldDropButtonTest.php index 8cbb081..7aaef35 100644 --- a/core/modules/views/src/Tests/Handler/FieldDropButtonTest.php +++ b/core/modules/views/src/Tests/Handler/FieldDropButtonTest.php @@ -7,6 +7,7 @@ namespace Drupal\views\Tests\Handler; +use Drupal\language\Entity\ConfigurableLanguage; use Drupal\views\Tests\ViewTestData; /** @@ -29,7 +30,7 @@ class FieldDropButtonTest extends HandlerTestBase { * * @var array */ - public static $modules = array('node'); + public static $modules = array('node', 'locale'); /** * Tests dropbutton field. @@ -43,6 +44,8 @@ public function testDropbutton() { $this->drupalGet('test-dropbutton'); foreach ($nodes as $node) { + $result = $this->xpath('//div[contains(@class, views-field-nothing)]/span/a[contains(@href, :path) and text()=:title]', array(':path' => '/node/' . $node->id(), ':title' => t('Custom Text'))); + $this->assertEqual(count($result), 1, 'Just one custom text was found.'); $result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', array(':path' => '/node/' . $node->id(), ':title' => $node->label())); $this->assertEqual(count($result), 1, 'Just one node title link was found.'); $result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', array(':path' => '/node/' . $node->id(), ':title' => t('Custom Text'))); @@ -50,4 +53,28 @@ public function testDropbutton() { } } + /** + * Tests dropbutton field with translation. + */ + public function testDropbuttonWithTranslation() { + // Create some test nodes. + $nodes = array(); + for ($i = 0; $i < 5; $i++) { + $nodes[] = $this->drupalCreateNode(); + } + + // Add the Italian language. + ConfigurableLanguage::createFromLangcode('it')->save(); + + $this->drupalGet('it/test-dropbutton'); + foreach ($nodes as $node) { + $result = $this->xpath('//div[contains(@class, views-field-nothing)]/span/a[contains(@href, :path) and text()=:title]', array(':path' => '/it/node/' . $node->id(), ':title' => t('Custom Text'))); + $this->assertEqual(count($result), 1, 'Just one custom text was found.'); + $result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', array(':path' => '/it/node/' . $node->id(), ':title' => $node->label())); + $this->assertEqual(count($result), 1, 'Just one node title link was found.'); + $result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', array(':path' => '/it/node/' . $node->id(), ':title' => t('Custom Text'))); + $this->assertEqual(count($result), 1, 'Just one custom link was found.'); + } + } + }