class TestMigrationMock

Same name and namespace in other branches
  1. 11.x core/modules/migrate/tests/src/Unit/MigrationPluginManagerTest.php \Drupal\Tests\migrate\Unit\TestMigrationMock

A mock migration plugin.

Why are we using a custom class here?

1. The function buildDependencyMigration() calls $migration->set(), which is not actually in MigrationInterface.

2. The function buildDependencyMigration() calls array_multisort on an array with mocks in it. PHPUnit mocks are really complex, and if PHP tries to compare them it will die with "Nesting level too deep".

Hierarchy

Expanded class hierarchy of TestMigrationMock

File

core/modules/migrate/tests/src/Unit/MigrationPluginManagerTest.php, line 182

Namespace

Drupal\Tests\migrate\Unit
View source
class TestMigrationMock extends Migration {
  
  /**
   * The values passed into set().
   *
   * @var array
   */
  public $set = [];
  
  /**
   * TestMigrationMock constructor.
   */
  public function __construct($id, $dependencies) {
    // Intentionally ignore parent constructor.
    $this->id = $id;
    $this->dependencies = $dependencies;
  }
  
  /**
   * {@inheritdoc}
   */
  public function id() {
    return $this->id;
  }
  
  /**
   * {@inheritdoc}
   */
  public function getMigrationDependencies() {
    return $this->dependencies;
  }
  
  /**
   * {@inheritdoc}
   */
  public function set($prop, $value) {
    $this->set[] = func_get_args();
  }

}

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