class TestMigrationMock in Drupal 10
Same name and namespace in other branches
- 8 core/modules/migrate/tests/src/Unit/MigrationPluginManagerTest.php \Drupal\Tests\migrate\Unit\TestMigrationMock
- 9 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
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\migrate\Plugin\Migration implements ContainerFactoryPluginInterface, MigrationInterface, RequirementsInterface
- class \Drupal\Tests\migrate\Unit\TestMigrationMock
- class \Drupal\migrate\Plugin\Migration implements ContainerFactoryPluginInterface, MigrationInterface, RequirementsInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of TestMigrationMock
File
- core/
modules/ migrate/ tests/ src/ Unit/ MigrationPluginManagerTest.php, line 182
Namespace
Drupal\Tests\migrate\UnitView 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();
}
}