Chris@0: '1', 'field1' => 'f1value1', 'field2' => 'f2value1'], Chris@0: ['key' => '2', 'field1' => 'f1value2', 'field2' => 'f2value2'], Chris@0: ]; Chris@0: $ids = ['key' => ['type' => 'integer']]; Chris@0: $definition = [ Chris@0: 'migration_tags' => ['Embedded data test'], Chris@0: 'source' => [ Chris@0: 'plugin' => 'embedded_data', Chris@0: 'data_rows' => $data_rows, Chris@0: 'ids' => $ids, Chris@0: ], Chris@0: 'process' => [], Chris@0: 'destination' => ['plugin' => 'null'], Chris@0: ]; Chris@0: Chris@0: $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition); Chris@0: $source = $migration->getSourcePlugin(); Chris@0: Chris@0: // Validate the plugin returns the source data that was provided. Chris@0: $results = []; Chris@0: /** @var \Drupal\migrate\Row $row */ Chris@0: foreach ($source as $row) { Chris@17: // The plugin should not mark any rows as stubs. We need to use Chris@17: // assertSame() here because assertFalse() will pass falsy values (e.g., Chris@17: // empty arrays). Chris@17: $this->assertSame(FALSE, $row->isStub()); Chris@17: Chris@0: $data_row = $row->getSource(); Chris@0: // The "data" row returned by getSource() also includes all source Chris@0: // configuration - we remove it so we see only the data itself. Chris@0: unset($data_row['plugin']); Chris@0: unset($data_row['data_rows']); Chris@0: unset($data_row['ids']); Chris@0: $results[] = $data_row; Chris@0: } Chris@0: $this->assertIdentical($results, $data_rows); Chris@0: Chris@0: // Validate the public APIs. Chris@0: $this->assertIdentical($source->count(), count($data_rows)); Chris@0: $this->assertIdentical($source->getIds(), $ids); Chris@0: $expected_fields = [ Chris@0: 'key' => 'key', Chris@0: 'field1' => 'field1', Chris@0: 'field2' => 'field2', Chris@0: ]; Chris@0: $this->assertIdentical($source->fields(), $expected_fields); Chris@0: } Chris@0: Chris@0: }