class ConvertTokensTest

Same name and namespace in other branches
  1. 11.x core/modules/user/tests/src/Unit/Plugin/migrate/process/ConvertTokensTest.php \Drupal\Tests\user\Unit\Plugin\migrate\process\ConvertTokensTest

Tests the ConvertTokens plugin.

@group user

Hierarchy

Expanded class hierarchy of ConvertTokensTest

File

core/modules/user/tests/src/Unit/Plugin/migrate/process/ConvertTokensTest.php, line 13

Namespace

Drupal\Tests\user\Unit\Plugin\migrate\process
View source
class ConvertTokensTest extends MigrateProcessTestCase {
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->plugin = new ConvertTokens([], 'convert_tokens', []);
  }
  
  /**
   * Tests conversion of user tokens.
   */
  public function testConvertTokens() {
    $value = $this->plugin
      ->transform('Account details for !username at !site', $this->migrateExecutable, $this->row, 'destination_property');
    $this->assertEquals('Account details for [user:name] at [site:name]', $value);
  }
  
  /**
   * Tests conversion of user tokens with a NULL value.
   */
  public function testConvertTokensNull() {
    $value = $this->plugin
      ->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
    $this->assertEquals('', $value);
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.