You are here

CallbackTest.php in Zircon Profile 8

Same filename and directory in other branches
  1. 8.0 core/modules/migrate/tests/src/Unit/process/CallbackTest.php

File

core/modules/migrate/tests/src/Unit/process/CallbackTest.php
View source
<?php

/**
 * @file
 * Contains \Drupal\Tests\migrate\Unit\process\CallbackTest.
 */
namespace Drupal\Tests\migrate\Unit\process;

use Drupal\migrate\Plugin\migrate\process\Callback;

/**
 * Tests the callback process plugin.
 *
 * @group migrate
 */
class CallbackTest extends MigrateProcessTestCase {

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    $this->plugin = new TestCallback();
    parent::setUp();
  }

  /**
   * Test callback with a function as callable.
   */
  public function testCallbackWithFunction() {
    $this->plugin
      ->setCallable('strtolower');
    $value = $this->plugin
      ->transform('FooBar', $this->migrateExecutable, $this->row, 'destinationproperty');
    $this
      ->assertSame($value, 'foobar');
  }

  /**
   * Test callback with a class method as callable.
   */
  public function testCallbackWithClassMethod() {
    $this->plugin
      ->setCallable(array(
      '\\Drupal\\Component\\Utility\\Unicode',
      'strtolower',
    ));
    $value = $this->plugin
      ->transform('FooBar', $this->migrateExecutable, $this->row, 'destinationproperty');
    $this
      ->assertSame($value, 'foobar');
  }

}
class TestCallback extends Callback {
  public function __construct() {
  }
  public function setCallable($callable) {
    $this->configuration['callable'] = $callable;
  }

}

Classes

Namesort descending Description
CallbackTest Tests the callback process plugin.
TestCallback