You are here

public function BarcodeBlockTest::testTokenIntegration in Barcodes 2.0.x

Tests using a Token module token in the value textfield.

@covers ::build

File

tests/src/Functional/BarcodeBlockTest.php, line 88

Class

BarcodeBlockTest
Tests the Barcodes module block functionality.

Namespace

Drupal\Tests\barcodes\Functional

Code

public function testTokenIntegration() {

  /** @var \Drupal\Tests\WebAssert $assert */
  $assert = $this
    ->assertSession();

  // Set "Value" using a token.
  // To prevent matching a portion of a longer URL found on the page, or
  // a URL located somewhere other than in the barcode, we enclose the URL
  // in double quotes and prepend a string.
  $this->block
    ->getPlugin()
    ->setConfigurationValue('value', 'Value="[current-page:url]"');
  $this->block
    ->getPlugin()
    ->setConfigurationValue('show_value', TRUE);
  $this->block
    ->save();
  $this
    ->drupalGet('');
  $assert
    ->pageTextContains('Value="' . $this
    ->getUrl() . '"');
}