class IteratorTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/migrate/tests/src/Unit/process/IteratorTest.php \Drupal\Tests\migrate\Unit\process\IteratorTest
Tests the iterator process plugin.
@group migrate
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
- class \Drupal\Tests\migrate\Unit\process\IteratorTest
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
Expanded class hierarchy of IteratorTest
File
- core/
modules/ migrate/ tests/ src/ Unit/ process/ IteratorTest.php, line 20 - Contains \Drupal\Tests\migrate\Unit\process\IteratorTest.
Namespace
Drupal\Tests\migrate\Unit\processView source
class IteratorTest extends MigrateTestCase {
/**
* The iterator plugin being tested.
*
* @var \Drupal\migrate\Plugin\migrate\process\TestIterator
*/
protected $plugin;
/**
* @var array
*/
protected $migrationConfiguration = array(
'id' => 'test',
);
/**
* Tests the iterator process plugin.
*/
public function testIterator() {
$migration = $this
->getMigration();
// Set up the properties for the iterator.
$configuration = array(
'process' => array(
'foo' => 'source_foo',
'id' => 'source_id',
),
'key' => '@id',
);
$plugin = new Iterator($configuration, 'iterator', array());
// Manually create the plugins. Migration::getProcessPlugins does this
// normally but the plugin system is not available.
foreach ($configuration['process'] as $destination => $source) {
$iterator_plugins[$destination][] = new Get(array(
'source' => $source,
), 'get', array());
}
$migration
->expects($this
->at(1))
->method('getProcessPlugins')
->will($this
->returnValue($iterator_plugins));
// Set up the key plugins.
$key_plugin['key'][] = new Get(array(
'source' => '@id',
), 'get', array());
$migration
->expects($this
->at(2))
->method('getProcessPlugins')
->will($this
->returnValue($key_plugin));
$event_dispatcher = $this
->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
$migrate_executable = new MigrateExecutable($migration, $this
->getMock('Drupal\\migrate\\MigrateMessageInterface'), $event_dispatcher);
// The current value of the pipeline.
$current_value = array(
array(
'source_foo' => 'test',
'source_id' => 42,
),
);
// This is not used but the interface requires it, so create an empty row.
$row = new Row(array(), array());
// After transformation, check to make sure that source_foo and source_id's
// values ended up in the proper destinations, and that the value of the
// key (@id) is the same as the destination ID (42).
$new_value = $plugin
->transform($current_value, $migrate_executable, $row, 'test');
$this
->assertSame(count($new_value), 1);
$this
->assertSame(count($new_value[42]), 2);
$this
->assertSame($new_value[42]['foo'], 'test');
$this
->assertSame($new_value[42]['id'], 42);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
IteratorTest:: |
protected | property |
Overrides MigrateTestCase:: |
|
IteratorTest:: |
protected | property | The iterator plugin being tested. | |
IteratorTest:: |
public | function | Tests the iterator process plugin. | |
MigrateTestCase:: |
protected | property | ||
MigrateTestCase:: |
protected | property | Local store for mocking setStatus()/getStatus(). | |
MigrateTestCase:: |
protected | function | Generates a table schema from a row. | |
MigrateTestCase:: |
protected | function | Get an SQLite database connection object for use in tests. | |
MigrateTestCase:: |
protected | function | Retrieve a mocked migration. | |
MigrateTestCase:: |
protected | function | 1 | |
MigrateTestCase:: |
public | function | Tests a query | |
MigrateTestCase:: |
protected | function | Asserts tested values during test retrieval. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in 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 | 259 |