You are here

public function BambooTwigRenderTest::testField in Bamboo Twig 8.5

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/BambooTwigRenderTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigRenderTest::testField()
  2. 8.3 tests/src/Functional/BambooTwigRenderTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigRenderTest::testField()
  3. 8.4 tests/src/Functional/BambooTwigRenderTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigRenderTest::testField()

@covers Drupal\bamboo_twig_loader\TwigExtension\Render::renderField @group kevintest

File

tests/src/Functional/BambooTwigRenderTest.php, line 225

Class

BambooTwigRenderTest
Tests Renders twig filters and functions.

Namespace

Drupal\Tests\bamboo_twig\Functional

Code

public function testField() {
  $this
    ->drupalGet('/bamboo-twig-render');

  // Entity articles (nodes) title field.
  $this
    ->assertElementContains('.test-render div.render-field-title-node-1', '<span>News N°1</span>');
  $this
    ->assertElementContains('.test-render div.render-field-title-node-2', '<span>News N°2</span>');
  $this
    ->assertElementContains('.test-render div.render-field-title-node-3', '<span>News N°3</span>');
  $this
    ->assertElementContains('.test-render div.render-field-title-node-4', '<span>Article N°4</span>');
  $this
    ->assertElementContains('.test-render div.render-field-title-node-5', '<span>Article N°5</span>');

  // Entity tags (taxonomy) name field.
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-1', '<div>Tag N°1</div>');
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-2', '<div>Tag N°2</div>');
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-3', '<div>Tag N°3</div>');
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-4', '<div>Mot clé N°4</div>');
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-5', '<div>Mot clé N°5</div>');

  // Entity articles (node) tags reference field.
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-1', 'Mot clé N°4');
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-2', 'Tag N°2');
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-3', 'Tag N°3');
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-4', 'Tag N°1');
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-5', 'Tag N°5');

  // Entity file uri.
  $this
    ->assertElementContains('.test-render div.render-field-file', $this->file->filename->value);

  // Entity user username.
  $this
    ->assertElementContains('.test-render div.render-field-user', 'admin');
  $this
    ->drupalGet('/fr/bamboo-twig-render');

  // Entity articles (nodes) title field - French.
  $this
    ->assertElementContains('.test-render div.render-field-title-node-1', '<span>News N°1</span>');
  $this
    ->assertElementContains('.test-render div.render-field-title-node-2', '<span>News N°2</span>');
  $this
    ->assertElementContains('.test-render div.render-field-title-node-3', '<span>News N°3</span>');
  $this
    ->assertElementContains('.test-render div.render-field-title-node-4', '<span>Article N°4</span>');
  $this
    ->assertElementContains('.test-render div.render-field-title-node-5', '<span>Article N°5</span>');

  // Entity tags (taxonomy) name field - French.
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-1', '<div>Tag N°1</div>');
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-2', '<div>Tag N°2</div>');
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-3', '<div>Tag N°3</div>');
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-4', '<div>Mot clé N°4</div>');
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-5', '<div>Mot clé N°5</div>');

  // Entity articles (node) tags reference field - French.
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-1', 'Mot clé N°4');
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-2', 'Mot clé N°2');
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-3', 'Mot clé N°3');
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-4', 'Tag N°1');
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-5', 'Mot clé N°5');
  $this
    ->drupalGet('/de/bamboo-twig-render');

  // Entity articles (nodes) title field - German.
  $this
    ->assertElementContains('.test-render div.render-field-title-node-1', '<span>News N°1</span>');
  $this
    ->assertElementContains('.test-render div.render-field-title-node-2', '<span>News N°2</span>');
  $this
    ->assertElementContains('.test-render div.render-field-title-node-3', '<span>News N°3</span>');
  $this
    ->assertElementContains('.test-render div.render-field-title-node-4', '<span>Article N°4</span>');
  $this
    ->assertElementContains('.test-render div.render-field-title-node-5', '<span>Article N°5</span>');

  // Entity tags (taxonomy) name field - German.
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-1', '<div>Tag N°1</div>');
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-2', '<div>Tag N°2</div>');
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-3', '<div>Tag N°3</div>');
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-4', '<div>Mot clé N°4</div>');
  $this
    ->assertElementContains('.test-render div.render-field-taxonomy-term-5', '<div>Mot clé N°5</div>');

  // Entity articles (node) tags reference field - German.
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-1', 'Mot clé N°4');
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-2', 'Tag N°2');
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-3', 'Stichworte N°3');
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-4', 'Tag N°1');
  $this
    ->assertElementContains('.test-render div.render-field-reference-node-5', 'Tag N°5');
}