class MigrateLookupTest in Drupal 8
Same name in this branch
- 8 core/modules/migrate/tests/src/Unit/MigrateLookupTest.php \Drupal\Tests\migrate\Unit\MigrateLookupTest
- 8 core/modules/migrate/tests/src/Kernel/MigrateLookupTest.php \Drupal\Tests\migrate\Kernel\MigrateLookupTest
Same name and namespace in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateLookupTest.php \Drupal\Tests\migrate\Unit\MigrateLookupTest
- 10 core/modules/migrate/tests/src/Unit/MigrateLookupTest.php \Drupal\Tests\migrate\Unit\MigrateLookupTest
Provides unit testing for the migration lookup service.
@group migrate
@coversDefaultClass \Drupal\migrate\MigrateLookup
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
- class \Drupal\Tests\migrate\Unit\MigrateLookupTest
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
Expanded class hierarchy of MigrateLookupTest
File
- core/
modules/ migrate/ tests/ src/ Unit/ MigrateLookupTest.php, line 19
Namespace
Drupal\Tests\migrate\UnitView source
class MigrateLookupTest extends MigrateTestCase {
/**
* Tests the lookup function.
*
* @covers ::lookup
*/
public function testLookup() {
$source_ids = [
'id' => '1',
];
$destination_ids = [
[
2,
],
];
$id_map = $this
->prophesize(MigrateIdMapInterface::class);
$id_map
->lookupDestinationIds($source_ids)
->willReturn($destination_ids);
$destination = $this
->prophesize(MigrateDestinationInterface::class);
$destination
->getIds()
->willReturn([
'id' => [
'type' => 'integer',
],
]);
$migration = $this
->prophesize(MigrationInterface::class);
$migration
->getIdMap()
->willReturn($id_map
->reveal());
$migration
->getDestinationPlugin()
->willReturn($destination
->reveal());
$plugin_manager = $this
->prophesize(MigrationPluginManagerInterface::class);
$plugin_manager
->createInstances('test_migration')
->willReturn([
$migration
->reveal(),
]);
$lookup = new MigrateLookup($plugin_manager
->reveal());
$this
->assertSame([
[
'id' => 2,
],
], $lookup
->lookup('test_migration', $source_ids));
}
/**
* Tests that an appropriate message is logged if a PluginException is thrown.
*/
public function testExceptionOnMigrationNotFound() {
$migration_plugin_manager = $this
->prophesize(MigrationPluginManagerInterface::class);
$migration_plugin_manager
->createInstances('bad_plugin')
->willReturn([]);
$this
->expectException(PluginNotFoundException::class);
$lookup = new MigrateLookup($migration_plugin_manager
->reveal());
$lookup
->lookup('bad_plugin', [
1,
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MigrateLookupTest:: |
public | function | Tests that an appropriate message is logged if a PluginException is thrown. | |
MigrateLookupTest:: |
public | function | Tests the lookup function. | |
MigrateTestCase:: |
protected | property | The migration ID map. | |
MigrateTestCase:: |
protected | property | An array of migration configuration values. | 16 |
MigrateTestCase:: |
protected | property | Local store for mocking setStatus()/getStatus(). | |
MigrateTestCase:: |
protected | function | Generates a table schema from a row. | |
MigrateTestCase:: |
protected | function | Gets an SQLite database connection object for use in tests. | |
MigrateTestCase:: |
protected | function | Retrieves a mocked migration. | 1 |
MigrateTestCase:: |
protected | function | Gets the value on a row for a given key. | 1 |
MigrateTestCase:: |
public | function | Tests a query. | |
MigrateTestCase:: |
protected | function | Asserts tested values during test retrieval. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 340 |