ConvertTokensTest.php

Same filename and directory in other branches
  1. 8.9.x core/modules/user/tests/src/Unit/Plugin/migrate/process/ConvertTokensTest.php
  2. 10 core/modules/user/tests/src/Unit/Plugin/migrate/process/ConvertTokensTest.php
  3. 11.x core/modules/user/tests/src/Unit/Plugin/migrate/process/ConvertTokensTest.php

Namespace

Drupal\Tests\user\Unit\Plugin\migrate\process

File

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

View source
<?php

namespace Drupal\Tests\user\Unit\Plugin\migrate\process;

use Drupal\user\Plugin\migrate\process\ConvertTokens;
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;

/**
 * Tests the ConvertTokens plugin.
 *
 * @group user
 */
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);
  }

}

Classes

Title Deprecated Summary
ConvertTokensTest Tests the ConvertTokens plugin.

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