comparison core/modules/migrate/tests/src/Kernel/MigrationTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Tests\migrate\Kernel;
4
5 use Drupal\KernelTests\KernelTestBase;
6
7 /**
8 * Tests the migration plugin.
9 *
10 * @group migrate
11 *
12 * @coversDefaultClass \Drupal\migrate\Plugin\Migration
13 */
14 class MigrationTest extends KernelTestBase {
15
16 /**
17 * Enable field because we are using one of its source plugins.
18 *
19 * @var array
20 */
21 public static $modules = ['migrate', 'field'];
22
23 /**
24 * Tests Migration::set().
25 *
26 * @covers ::set
27 */
28 public function testSetInvalidation() {
29 $migration = \Drupal::service('plugin.manager.migration')->createStubMigration([
30 'source' => ['plugin' => 'empty'],
31 'destination' => ['plugin' => 'entity:entity_view_mode'],
32 ]);
33 $this->assertEqual('empty', $migration->getSourcePlugin()->getPluginId());
34 $this->assertEqual('entity:entity_view_mode', $migration->getDestinationPlugin()->getPluginId());
35
36 // Test the source plugin is invalidated.
37 $migration->set('source', ['plugin' => 'embedded_data', 'data_rows' => [], 'ids' => []]);
38 $this->assertEqual('embedded_data', $migration->getSourcePlugin()->getPluginId());
39
40 // Test the destination plugin is invalidated.
41 $migration->set('destination', ['plugin' => 'null']);
42 $this->assertEqual('null', $migration->getDestinationPlugin()->getPluginId());
43 }
44
45 }