Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\MigrationStorageTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateTestCase;
|
||||
|
||||
/**
|
||||
* Tests the MigrationStorage load plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class MigrationStorageTest extends MigrateTestCase {
|
||||
|
||||
protected $migrationConfiguration = array('id' => 'test_migration', 'migrationClass' => 'Drupal\migrate_drupal\Entity\Migration');
|
||||
|
||||
/**
|
||||
* Test that the entity load hooks are called on dynamic migrations.
|
||||
*
|
||||
* @dataProvider entityIdsDataProvider
|
||||
*/
|
||||
public function testMigrationStorage($entity_ids) {
|
||||
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
|
||||
$entity_type
|
||||
->expects($this->exactly(2))
|
||||
->method('isStaticallyCacheable')
|
||||
->willReturn(FALSE);
|
||||
|
||||
$load_plugin = $this->getMock('Drupal\migrate_drupal\Plugin\MigrateLoadInterface');
|
||||
$load_plugin
|
||||
->expects($this->once())
|
||||
->method('loadMultiple')
|
||||
->willReturn([]);
|
||||
|
||||
$migration = $this->getMigration();
|
||||
$migration
|
||||
->expects($this->once())
|
||||
->method('getLoadPlugin')
|
||||
->willReturn($load_plugin);
|
||||
|
||||
$storage = $this->getMock('Drupal\migrate_drupal\TestMigrationStorage', ['postLoad', 'doLoadMultiple'], [$entity_type]);
|
||||
$storage
|
||||
->expects($this->exactly(2))
|
||||
->method('postLoad');
|
||||
$storage
|
||||
->expects($this->once())
|
||||
->method('doLoadMultiple')
|
||||
->willReturn(['test_migration' => $migration]);
|
||||
|
||||
$storage->loadMultiple($entity_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* The data provider for migration storage.
|
||||
*
|
||||
* @return array
|
||||
* The entity ids.
|
||||
*/
|
||||
public function entityIdsDataProvider() {
|
||||
return [
|
||||
[['test_migration:bundle']],
|
||||
[NULL],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace Drupal\migrate_drupal;
|
||||
|
||||
class TestMigrationStorage extends MigrationStorage {
|
||||
public function __construct($entity_type) {
|
||||
$this->entityType = $entity_type;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\VariableMultiRowSourceWithHighwaterTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source;
|
||||
|
||||
/**
|
||||
* Tests variable multirow source w/ high water handling.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class VariableMultiRowSourceWithHighwaterTest extends VariableMultiRowTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->migrationConfiguration['highWaterProperty']['field'] = 'test';
|
||||
parent::setup();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\VariableMultiRowTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source;
|
||||
|
||||
/**
|
||||
* Tests D6 variable multirow source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class VariableMultiRowTest extends VariableMultiRowTestBase {
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\VariableMultiRowTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Base class for variable multirow source unit tests.
|
||||
*/
|
||||
abstract class VariableMultiRowTestBase extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\VariableMultiRow';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_variable_multirow',
|
||||
'variables' => array(
|
||||
'foo',
|
||||
'bar',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array('name' => 'foo', 'value' => 1),
|
||||
array('name' => 'bar', 'value' => FALSE),
|
||||
);
|
||||
|
||||
protected $databaseContents = array(
|
||||
'variable' => array(
|
||||
array('name' => 'foo', 'value' => 'i:1;'),
|
||||
array('name' => 'bar', 'value' => 'b:0;'),
|
||||
),
|
||||
);
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\VariableTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests the variable source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class VariableTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\Variable';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'highWaterProperty' => array('field' => 'test'),
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_variable',
|
||||
'variables' => array(
|
||||
'foo',
|
||||
'bar',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'foo' => 1,
|
||||
'bar' => FALSE,
|
||||
),
|
||||
);
|
||||
|
||||
protected $databaseContents = array(
|
||||
'variable' => array(
|
||||
array('name' => 'foo', 'value' => 'i:1;'),
|
||||
array('name' => 'bar', 'value' => 'b:0;'),
|
||||
),
|
||||
);
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\ActionTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 actions source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class ActionTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\Action';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_action',
|
||||
),
|
||||
);
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'aid' => '1',
|
||||
'type' => 'system',
|
||||
'callback' => 'system_goto_action',
|
||||
'parameters' => 'a:1:{s:3:"url";s:4:"node";}',
|
||||
'description' => 'Redirect to node list page',
|
||||
),
|
||||
array(
|
||||
'aid' => '2',
|
||||
'type' => 'system',
|
||||
'callback' => 'system_send_email_action',
|
||||
'parameters' => 'a:3:{s:9:"recipient";s:7:"%author";s:7:"subject";s:4:"Test";s:7:"message";s:4:"Test',
|
||||
'description' => 'Test notice email',
|
||||
),
|
||||
array(
|
||||
'aid' => 'comment_publish_action',
|
||||
'type' => 'comment',
|
||||
'callback' => 'comment_publish_action',
|
||||
'parameters' => null,
|
||||
'description' => null,
|
||||
),
|
||||
array(
|
||||
'aid' => 'node_publish_action',
|
||||
'type' => 'comment',
|
||||
'callback' => 'node_publish_action',
|
||||
'parameters' => null,
|
||||
'description' => null,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['actions'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\AggregatorFeedTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 aggregator feed source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class AggregatorFeedTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\AggregatorFeed';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_aggregator_feed',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'fid' => 1,
|
||||
'title' => 'feed title 1',
|
||||
'url' => 'http://example.com/feed.rss',
|
||||
'refresh' => 900,
|
||||
'checked' => 0,
|
||||
'link' => 'http://example.com',
|
||||
'description' => 'A vague description',
|
||||
'image' => '',
|
||||
'etag' => '',
|
||||
'modified' => 0,
|
||||
'block' => 5,
|
||||
),
|
||||
array(
|
||||
'fid' => 2,
|
||||
'title' => 'feed title 2',
|
||||
'url' => 'http://example.net/news.rss',
|
||||
'refresh' => 1800,
|
||||
'checked' => 0,
|
||||
'link' => 'http://example.net',
|
||||
'description' => 'An even more vague description',
|
||||
'image' => '',
|
||||
'etag' => '',
|
||||
'modified' => 0,
|
||||
'block' => 5,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
$this->databaseContents['aggregator_feed'][$k] = $row;
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\AggregatorItemTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 aggregator item source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class AggregatorItemTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\AggregatorItem';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_aggregator_item',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'iid' => 1,
|
||||
'fid' => 1,
|
||||
'title' => 'This (three) weeks in Drupal Core - January 10th 2014',
|
||||
'link' => 'https://groups.drupal.org/node/395218',
|
||||
'author' => 'larowlan',
|
||||
'description' => "<h2 id='new'>What's new with Drupal 8?</h2>",
|
||||
'timestamp' => 1389297196,
|
||||
'guid' => '395218 at https://groups.drupal.org',
|
||||
),
|
||||
);
|
||||
|
||||
protected $databaseContents = array('aggregator_item' => array(array(
|
||||
'iid' => 1,
|
||||
'fid' => 1,
|
||||
'title' => 'This (three) weeks in Drupal Core - January 10th 2014',
|
||||
'link' => 'https://groups.drupal.org/node/395218',
|
||||
'author' => 'larowlan',
|
||||
'description' => "<h2 id='new'>What's new with Drupal 8?</h2>",
|
||||
'timestamp' => 1389297196,
|
||||
'guid' => '395218 at https://groups.drupal.org',
|
||||
),
|
||||
));
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\BlockTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 block source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class BlockTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\Block';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_block',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Sample block instance query results from the source.
|
||||
*/
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'bid' => 1,
|
||||
'module' => 'block',
|
||||
'delta' => '1',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'region' => 'left',
|
||||
'visibility' => 0,
|
||||
'pages' => '',
|
||||
'title' => 'Test Title 01',
|
||||
'cache' => -1,
|
||||
),
|
||||
array(
|
||||
'bid' => 2,
|
||||
'module' => 'block',
|
||||
'delta' => '2',
|
||||
'theme' => 'garland',
|
||||
'status' => 1,
|
||||
'weight' => 5,
|
||||
'region' => 'right',
|
||||
'visibility' => 0,
|
||||
'pages' => '<front>',
|
||||
'title' => 'Test Title 02',
|
||||
'cache' => -1,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Sample block roles table.
|
||||
*/
|
||||
protected $expectedBlocksRoles = array(
|
||||
array(
|
||||
'module' => 'block',
|
||||
'delta' => 1,
|
||||
'rid' => 2,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Prepopulate database contents.
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['blocks'] = $this->expectedResults;
|
||||
$this->databaseContents['blocks_roles'] = $this->expectedBlocksRoles;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\BoxTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 block boxes source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class BoxTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\Box';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_boxes',
|
||||
),
|
||||
);
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
// These are sample result queries.
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'bid' => 1,
|
||||
'body' => '<p>I made some custom content.</p>',
|
||||
'info' => 'Static Block',
|
||||
'format' => 1,
|
||||
),
|
||||
array(
|
||||
'bid' => 2,
|
||||
'body' => '<p>I made some more custom content.</p>',
|
||||
'info' => 'Test Content',
|
||||
'format' => 1,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Prepopulate contents with results.
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['boxes'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\CommentSourceWithHighWaterTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 comment source w/ high water handling.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class CommentSourceWithHighWaterTest extends CommentTestBase {
|
||||
|
||||
const ORIGINAL_HIGH_WATER = 1382255613;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->migrationConfiguration['highWaterProperty']['field'] = 'timestamp';
|
||||
array_shift($this->expectedResults);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\CommentTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
/**
|
||||
* Tests D6 comment source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class CommentTest extends CommentTestBase {
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\CommentTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Base class for comment source unit tests.
|
||||
*/
|
||||
abstract class CommentTestBase extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\Comment';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
// This needs to be the identifier of the actual key: cid for comment, nid
|
||||
// for node and so on.
|
||||
'source' => array(
|
||||
'plugin' => 'd6_comment',
|
||||
),
|
||||
);
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'cid' => 1,
|
||||
'pid' => 0,
|
||||
'nid' => 2,
|
||||
'uid' => 3,
|
||||
'subject' => 'subject value 1',
|
||||
'comment' => 'comment value 1',
|
||||
'hostname' => 'hostname value 1',
|
||||
'timestamp' => 1382255613,
|
||||
'status' => 1,
|
||||
'thread' => '',
|
||||
'name' => '',
|
||||
'mail' => '',
|
||||
'homepage' => '',
|
||||
'format' => 'testformat1',
|
||||
'type' => 'story',
|
||||
),
|
||||
array(
|
||||
'cid' => 2,
|
||||
'pid' => 1,
|
||||
'nid' => 3,
|
||||
'uid' => 4,
|
||||
'subject' => 'subject value 2',
|
||||
'comment' => 'comment value 2',
|
||||
'hostname' => 'hostname value 2',
|
||||
'timestamp' => 1382255662,
|
||||
'status' => 1,
|
||||
'thread' => '',
|
||||
'name' => '',
|
||||
'mail' => '',
|
||||
'homepage' => '',
|
||||
'format' => 'testformat2',
|
||||
'type' => 'page',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
$this->databaseContents['comments'][$k] = $row;
|
||||
$this->databaseContents['comments'][$k]['status'] = 1 - $this->databaseContents['comments'][$k]['status'];
|
||||
}
|
||||
// Add node table data.
|
||||
$this->databaseContents['node'][] = array('nid' => 2, 'type' => 'story');
|
||||
$this->databaseContents['node'][] = array('nid' => 3, 'type' => 'page');
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\ContactCategoryTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 contact category source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class ContactCategoryTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\ContactCategory';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_contact_category',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'cid' => 1,
|
||||
'category' => 'contact category value 1',
|
||||
'recipients' => array('admin@example.com','user@example.com'),
|
||||
'reply' => 'auto reply value 1',
|
||||
'weight' => 0,
|
||||
'selected' => 0,
|
||||
),
|
||||
array(
|
||||
'cid' => 2,
|
||||
'category' => 'contact category value 2',
|
||||
'recipients' => array('admin@example.com','user@example.com'),
|
||||
'reply' => 'auto reply value 2',
|
||||
'weight' => 0,
|
||||
'selected' => 0,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
$this->databaseContents['contact'][$k] = $row;
|
||||
$this->databaseContents['contact'][$k]['recipients'] = implode(',', $row['recipients']);
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,217 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\Drupal6SqlBaseTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateTestCase;
|
||||
|
||||
/**
|
||||
* Tests the D6 SQL base class.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class Drupal6SqlBaseTest extends MigrateTestCase {
|
||||
|
||||
/**
|
||||
* Define bare minimum migration configuration.
|
||||
*/
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'Drupal6SqlBase',
|
||||
);
|
||||
|
||||
/**
|
||||
* @var \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
|
||||
*/
|
||||
protected $base;
|
||||
|
||||
/**
|
||||
* Minimum database contents needed to test Drupal6SqlBase.
|
||||
*/
|
||||
protected $databaseContents = array(
|
||||
'system' => array(
|
||||
array(
|
||||
'filename' => 'sites/all/modules/module1',
|
||||
'name' => 'module1',
|
||||
'type' => 'module',
|
||||
'status' => 1,
|
||||
'schema_version' => -1,
|
||||
),
|
||||
array(
|
||||
'filename' => 'sites/all/modules/module2',
|
||||
'name' => 'module2',
|
||||
'type' => 'module',
|
||||
'status' => 0,
|
||||
'schema_version' => 7201,
|
||||
),
|
||||
array(
|
||||
'filename' => 'sites/all/modules/test2',
|
||||
'name' => 'test2',
|
||||
'type' => 'theme',
|
||||
'status' => 1,
|
||||
'schema_version' => -1,
|
||||
),
|
||||
),
|
||||
'variable' => array(
|
||||
array(
|
||||
'name' => 'my_variable',
|
||||
'value' => 'b:1;',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$plugin = 'placeholder_id';
|
||||
$entity_manager = $this->getmock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
$this->base = new TestDrupal6SqlBase($this->migrationConfiguration, $plugin, array(), $this->getMigration(), $entity_manager);
|
||||
$this->base->setDatabase($this->getDatabase($this->databaseContents));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for Drupal6SqlBase::getSystemData().
|
||||
*/
|
||||
public function testGetSystemData() {
|
||||
$system_data = $this->base->getSystemData();
|
||||
// Should be 1 theme and 2 modules.
|
||||
$this->assertEquals(1, count($system_data['theme']));
|
||||
$this->assertEquals(2, count($system_data['module']));
|
||||
|
||||
// Calling again should be identical.
|
||||
$this->assertSame($system_data, $this->base->getSystemData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for Drupal6SqlBase::moduleExists().
|
||||
*/
|
||||
public function testDrupal6ModuleExists() {
|
||||
// This module should exist.
|
||||
$this->assertTrue($this->base->moduleExistsWrapper('module1'));
|
||||
|
||||
// These modules should not exist.
|
||||
$this->assertFalse($this->base->moduleExistsWrapper('module2'));
|
||||
$this->assertFalse($this->base->moduleExistsWrapper('module3'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for Drupal6SqlBase::getModuleSchemaVersion().
|
||||
*/
|
||||
public function testGetModuleSchemaVersion() {
|
||||
// Non-existent module.
|
||||
$this->assertFalse($this->base->getModuleSchemaVersionWrapper('module3'));
|
||||
|
||||
// Disabled module should still return schema version.
|
||||
$this->assertEquals(7201, $this->base->getModuleSchemaVersionWrapper('module2'));
|
||||
|
||||
// Enabled module.
|
||||
$this->assertEquals(-1, $this->base->getModuleSchemaVersionWrapper('module1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for Drupal6SqlBase::variableGet().
|
||||
*/
|
||||
public function testVariableGet() {
|
||||
// Test default value.
|
||||
$this->assertEquals('my_default', $this->base->variableGetWrapper('non_existent_variable', 'my_default'));
|
||||
|
||||
// Test non-default.
|
||||
$this->assertSame(TRUE, $this->base->variableGetWrapper('my_variable', FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Extends the Drupal6SqlBase abstract class.
|
||||
*/
|
||||
class TestDrupal6SqlBase extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'filename' => t('The path of the primary file for this item.'),
|
||||
'name' => t('The name of the item; e.g. node.'),
|
||||
'type' => t('The type of the item, either module, theme, or theme_engine.'),
|
||||
'owner' => t("A theme's 'parent'. Can be either a theme or an engine."),
|
||||
'status' => t('Boolean indicating whether or not this item is enabled.'),
|
||||
'throttle' => t('Boolean indicating whether this item is disabled when the throttle.module disables throttleable items.'),
|
||||
'bootstrap' => t('Boolean indicating whether this module is loaded during Drupal\'s early bootstrapping phase (e.g. even before the page cache is consulted).'),
|
||||
'schema_version' => t('The module\'s database schema version number.'),
|
||||
'weight' => t('The order in which this module\'s hooks should be invoked.'),
|
||||
'info' => t('A serialized array containing information from the module\'s .info file.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->database
|
||||
->select('system', 's')
|
||||
->fields('s', array('filename', 'name', 'schema_version'));
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tweaks Drupal6SqlBase to set a new database connection for tests.
|
||||
*
|
||||
* @param \Drupal\Core\Database\Connection
|
||||
* The new connection to use.
|
||||
*
|
||||
* @see \Drupal\Tests\migrate\Unit\MigrateSqlTestCase
|
||||
*/
|
||||
public function setDatabase(Connection $database) {
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tweaks Drupal6SqlBase to set a new module handler for tests.
|
||||
*
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface
|
||||
* The new module handler to use.
|
||||
*
|
||||
* @see \Drupal\Tests\migrate\Unit\MigrateSqlTestCase
|
||||
*/
|
||||
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
|
||||
$this->moduleHandler = $module_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper method to test protected method moduleExists().
|
||||
*/
|
||||
public function moduleExistsWrapper($module) {
|
||||
return parent::moduleExists($module);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper method to test protected method getModuleSchemaVersion().
|
||||
*/
|
||||
public function getModuleSchemaVersionWrapper($module) {
|
||||
return parent::getModuleSchemaVersion($module);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper method to test protected method variableGet().
|
||||
*/
|
||||
public function variableGetWrapper($name, $default) {
|
||||
return parent::variableGet($name, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return array();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\FieldInstancePerViewModeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 fields per view mode source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class FieldInstancePerViewModeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\FieldInstancePerViewMode';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'view_mode_test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_field_instance_per_view_mode',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 4,
|
||||
'type_name' => 'article',
|
||||
'field_name' => 'field_test',
|
||||
'type' => 'text',
|
||||
'module' => 'text',
|
||||
'weight' => 1,
|
||||
'label' => 'above',
|
||||
'display_settings' => array(
|
||||
'weight' => 1,
|
||||
'parent' => '',
|
||||
'label' => array(
|
||||
'format' => 'above',
|
||||
),
|
||||
4 => array(
|
||||
'format' => 'trimmed',
|
||||
'exclude' => 0,
|
||||
),
|
||||
),
|
||||
'widget_settings' => array(),
|
||||
),
|
||||
array(
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 'teaser',
|
||||
'type_name' => 'story',
|
||||
'field_name' => 'field_test',
|
||||
'type' => 'text',
|
||||
'module' => 'text',
|
||||
'weight' => 2,
|
||||
'label' => 'above',
|
||||
'display_settings' => array(
|
||||
'weight' => 1,
|
||||
'parent' => '',
|
||||
'label' => array(
|
||||
'format' => 'above',
|
||||
),
|
||||
'teaser' => array(
|
||||
'format' => 'trimmed',
|
||||
'exclude' => 0,
|
||||
),
|
||||
),
|
||||
'widget_settings' => array(),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $k => $field_view_mode) {
|
||||
// These are stored as serialized strings.
|
||||
$field_view_mode['display_settings'] = serialize($field_view_mode['display_settings']);
|
||||
$field_view_mode['widget_settings'] = serialize($field_view_mode['widget_settings']);
|
||||
|
||||
$this->databaseContents['content_node_field'][] = array(
|
||||
'field_name' => $field_view_mode['field_name'],
|
||||
'type' => $field_view_mode['type'],
|
||||
'module' => $field_view_mode['module'],
|
||||
);
|
||||
unset($field_view_mode['type']);
|
||||
unset($field_view_mode['module']);
|
||||
|
||||
$this->databaseContents['content_node_field_instance'][] = $field_view_mode;
|
||||
|
||||
// Update the expected display settings.
|
||||
$this->expectedResults[$k]['display_settings'] = $this->expectedResults[$k]['display_settings'][$field_view_mode['view_mode']];
|
||||
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\FieldInstanceTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 field instance source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class FieldInstanceTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\FieldInstance';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = [
|
||||
// The id of the entity, can be any string.
|
||||
'id' => 'test_fieldinstance',
|
||||
// Leave it empty for now.
|
||||
'idlist' => [],
|
||||
'source' => [
|
||||
'plugin' => 'd6_field_instance',
|
||||
],
|
||||
];
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
// These are sample result queries.
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'field_name' => 'field_body',
|
||||
'type_name' => 'page',
|
||||
'weight' => 1,
|
||||
'label' => 'body',
|
||||
'widget_type' => 'text_textarea',
|
||||
'widget_settings' => '',
|
||||
'display_settings' => '',
|
||||
'description' => '',
|
||||
'widget_module' => 'text',
|
||||
'widget_active' => 1,
|
||||
'required' => 1,
|
||||
'active' => 1,
|
||||
'global_settings' => [],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Prepopulate contents with results.
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->expectedResults[0]['widget_settings'] = [
|
||||
'rows' => 5,
|
||||
'size' => 60,
|
||||
'default_value' => [
|
||||
[
|
||||
'value' => '',
|
||||
'_error_element' => 'default_value_widget][field_body][0][value',
|
||||
'default_value_php' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->expectedResults[0]['display_settings'] = [
|
||||
'label' => [
|
||||
'format' => 'above',
|
||||
'exclude' => 0,
|
||||
],
|
||||
'teaser' => [
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
],
|
||||
'full' => [
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
],
|
||||
];
|
||||
$this->databaseContents['content_node_field_instance'] = $this->expectedResults;
|
||||
$this->databaseContents['content_node_field_instance'][0]['widget_settings'] = serialize($this->expectedResults[0]['widget_settings']);
|
||||
$this->databaseContents['content_node_field_instance'][0]['display_settings'] = serialize($this->expectedResults[0]['display_settings']);
|
||||
$this->databaseContents['content_node_field_instance'][0]['global_settings'] = 'a:0:{}';
|
||||
|
||||
$this->databaseContents['content_node_field'][0] = [
|
||||
'field_name' => 'field_body',
|
||||
'required' => 1,
|
||||
'type' => 'text',
|
||||
'active' => 1,
|
||||
'global_settings' => serialize([]),
|
||||
];
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\FieldTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 field source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class FieldTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\Field';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The id of the entity, can be any string.
|
||||
'id' => 'test_field',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_field',
|
||||
),
|
||||
);
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
// These are sample result queries.
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'field_name' => 'field_body',
|
||||
'type' => 'text',
|
||||
'global_settings' => '',
|
||||
'required' => 0,
|
||||
'multiple' => 0,
|
||||
'db_storage' => 1,
|
||||
'module' => 'text',
|
||||
'db_columns' => '',
|
||||
'active' => 1,
|
||||
'locked' => 0,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Prepopulate contents with results.
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->expectedResults[0]['global_settings'] = array(
|
||||
'text_processing' => 0,
|
||||
'max_length' => '',
|
||||
'allowed_values' => '',
|
||||
'allowed_values_php' => '',
|
||||
);
|
||||
$this->expectedResults[0]['db_columns'] = array(
|
||||
'value' => array(
|
||||
'type' => 'text',
|
||||
'size' => 'big',
|
||||
'not null' => '',
|
||||
'sortable' => 1,
|
||||
'views' => 1,
|
||||
),
|
||||
);
|
||||
$this->databaseContents['content_node_field'] = $this->expectedResults;
|
||||
$this->databaseContents['content_node_field'][0]['global_settings'] = serialize($this->databaseContents['content_node_field'][0]['global_settings']);
|
||||
$this->databaseContents['content_node_field'][0]['db_columns'] = serialize($this->databaseContents['content_node_field'][0]['db_columns']);
|
||||
|
||||
$this->databaseContents['content_node_field_instance'][0]['widget_settings'] = serialize(array());
|
||||
$this->databaseContents['content_node_field_instance'][0]['widget_type'] = 'text_textarea';
|
||||
$this->databaseContents['content_node_field_instance'][0]['field_name'] = 'field_body';
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\FileTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 file source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class FileTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\File';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_file',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'fid' => 1,
|
||||
'uid' => 1,
|
||||
'filename' => 'migrate-test-file-1.pdf',
|
||||
'filepath' => 'sites/default/files/migrate-test-file-1.pdf',
|
||||
'filemime' => 'application/pdf',
|
||||
'filesize' => 890404,
|
||||
'status' => 1,
|
||||
'timestamp' => 1382255613,
|
||||
),
|
||||
array(
|
||||
'fid' => 2,
|
||||
'uid' => 1,
|
||||
'filename' => 'migrate-test-file-2.pdf',
|
||||
'filepath' => 'sites/default/files/migrate-test-file-2.pdf',
|
||||
'filemime' => 'application/pdf',
|
||||
'filesize' => 204124,
|
||||
'status' => 1,
|
||||
'timestamp' => 1382255662,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['files'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\FilterFormatTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 filter_formats table source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class FilterFormatTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\FilterFormat';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'highWaterProperty' => array('field' => 'test'),
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_filter_formats',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'format' => 1,
|
||||
'name' => 'Filtered HTML',
|
||||
'roles' => array(1, 2),
|
||||
'cache' => 1,
|
||||
'filters' => array(
|
||||
array(
|
||||
'module' => 'filter',
|
||||
'delta' => 2,
|
||||
'weight' => 0,
|
||||
),
|
||||
array(
|
||||
'module' => 'filter',
|
||||
'delta' => 0,
|
||||
'weight' => 1,
|
||||
),
|
||||
array(
|
||||
'module' => 'filter',
|
||||
'delta' => 1,
|
||||
'weight' => 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'format' => 2,
|
||||
'name' => 'Full HTML',
|
||||
'roles' => array(),
|
||||
'cache' => 1,
|
||||
'filters' => array(
|
||||
array(
|
||||
'module' => 'filter',
|
||||
'delta' => 2,
|
||||
'weight' => 0,
|
||||
),
|
||||
array(
|
||||
'module' => 'filter',
|
||||
'delta' => 1,
|
||||
'weight' => 1,
|
||||
),
|
||||
array(
|
||||
'module' => 'filter',
|
||||
'delta' => 3,
|
||||
'weight' => 10,
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'format' => 4,
|
||||
'name' => 'Example Custom Format',
|
||||
'roles' => array(4),
|
||||
'cache' => 1,
|
||||
'filters' => array(
|
||||
// This custom format uses a filter defined by a contrib module.
|
||||
array(
|
||||
'module' => 'markdown',
|
||||
'delta' => 1,
|
||||
'weight' => 10,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$fid = 1;
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
$row['roles'] = ',' . implode(',', $row['roles']) . ',';
|
||||
foreach ($row['filters'] as $filter) {
|
||||
$this->databaseContents['filters'][$fid] = $filter;
|
||||
$this->databaseContents['filters'][$fid]['format'] = $row['format'];
|
||||
$this->databaseContents['filters'][$fid]['fid'] = $fid;
|
||||
$fid++;
|
||||
}
|
||||
unset($row['filters']);
|
||||
$this->databaseContents['filter_formats'][$k] = $row;
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\MenuLinkSourceTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 menu link source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class MenuLinkSourceTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\MenuLink';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'mlid',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
// This needs to be the identifier of the actual key: cid for comment, nid
|
||||
// for node and so on.
|
||||
'source' => array(
|
||||
'plugin' => 'drupal6_menu_link',
|
||||
),
|
||||
'sourceIds' => array(
|
||||
'mlid' => array(
|
||||
// This is where the field schema would go but for now we need to
|
||||
// specify the table alias for the key. Most likely this will be the
|
||||
// same as BASE_ALIAS.
|
||||
'alias' => 'ml',
|
||||
),
|
||||
),
|
||||
'destinationIds' => array(
|
||||
'mlid' => array(
|
||||
// This is where the field schema would go.
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 138,
|
||||
'plid' => 0,
|
||||
'link_path' => 'admin',
|
||||
'router_path' => 'admin',
|
||||
'link_title' => 'Test 1',
|
||||
'options' => array('attributes' => array('title' => 'Test menu link 1')),
|
||||
'module' => 'menu',
|
||||
'hidden' => 0,
|
||||
'external' => 0,
|
||||
'has_children' => 1,
|
||||
'expanded' => 0,
|
||||
'weight' => 15,
|
||||
'depth' => 1,
|
||||
'customized' => 1,
|
||||
'p1' => '138',
|
||||
'p2' => '0',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
),
|
||||
array(
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 139,
|
||||
'plid' => 138,
|
||||
'link_path' => 'admin/modules',
|
||||
'router_path' => 'admin/modules',
|
||||
'link_title' => 'Test 2',
|
||||
'options' => array('attributes' => array('title' => 'Test menu link 2')),
|
||||
'module' => 'menu',
|
||||
'hidden' => 0,
|
||||
'external' => 0,
|
||||
'has_children' => 0,
|
||||
'expanded' => 0,
|
||||
'weight' => 12,
|
||||
'depth' => 2,
|
||||
'customized' => 1,
|
||||
'p1' => '138',
|
||||
'p2' => '139',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
// This array stores the database.
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
$this->databaseContents['menu_links'][$k] = $row;
|
||||
$this->databaseContents['menu_links'][$k]['options'] = serialize($this->databaseContents['menu_links'][$k]['options']);
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\MenuTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 menu source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class MenuTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\Menu';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
// This needs to be the identifier of the actual key: cid for comment, nid
|
||||
// for node and so on.
|
||||
'source' => array(
|
||||
'plugin' => 'd6_menu',
|
||||
),
|
||||
);
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'menu_name' => 'menu-name-1',
|
||||
'title' => 'menu custom value 1',
|
||||
'description' => 'menu custom description value 1',
|
||||
),
|
||||
array(
|
||||
'menu_name' => 'menu-name-2',
|
||||
'title' => 'menu custom value 2',
|
||||
'description' => 'menu custom description value 2',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
// This array stores the database.
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
$this->databaseContents['menu_custom'][$k] = $row;
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\NodeByNodeTypeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 node source plugin with 'node_type' configuration.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class NodeByNodeTypeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\Node';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
// The fake configuration for the source.
|
||||
'source' => array(
|
||||
'plugin' => 'd6_node',
|
||||
'node_type' => 'page',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 1',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'timestamp' => 1279051598,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 1',
|
||||
'teaser' => 'teaser for node 1',
|
||||
'format' => 1,
|
||||
'log' => 'log message 1',
|
||||
),
|
||||
array(
|
||||
// Node fields.
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 2',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'timestamp' => 1279290908,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 2',
|
||||
'teaser' => 'teaser for node 2',
|
||||
'format' => 1,
|
||||
'log' => 'log message 2',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$database_contents = $this->expectedResults;
|
||||
array_walk($this->expectedResults, function (&$row) {
|
||||
$row['node_uid'] = $row['uid'];
|
||||
$row['revision_uid'] = $row['uid'] + 1;
|
||||
unset($row['uid']);
|
||||
});
|
||||
|
||||
$database_contents[] = array(
|
||||
// Node fields.
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'type' => 'article',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 5',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'timestamp' => 1279290908,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 5',
|
||||
'teaser' => 'body for node 5',
|
||||
'format' => 1,
|
||||
'log' => 'log message 3',
|
||||
);
|
||||
|
||||
// Add another row with an article node and make sure it is not migrated.
|
||||
|
||||
foreach ($database_contents as $k => $row) {
|
||||
foreach (array('nid', 'vid', 'title', 'uid', 'body', 'teaser', 'format', 'timestamp', 'log') as $field) {
|
||||
$this->databaseContents['node_revisions'][$k][$field] = $row[$field];
|
||||
switch ($field) {
|
||||
case 'nid': case 'vid':
|
||||
break;
|
||||
case 'uid':
|
||||
$this->databaseContents['node_revisions'][$k]['uid']++;
|
||||
break;
|
||||
default:
|
||||
unset($row[$field]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->databaseContents['node'][$k] = $row;
|
||||
}
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\NodeRevisionByNodeTypeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 node revision source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class NodeRevisionByNodeTypeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\NodeRevision';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => [],
|
||||
// The fake configuration for the source.
|
||||
'source' => [
|
||||
'plugin' => 'd6_node_revision',
|
||||
'node_type' => 'page',
|
||||
],
|
||||
'sourceIds' => [
|
||||
'vid' => [
|
||||
'alias' => 'v',
|
||||
],
|
||||
],
|
||||
'destinationIds' => [
|
||||
'vid' => [
|
||||
// This is where the field schema would go.
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
protected $databaseContents = [
|
||||
'node' => [
|
||||
[
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'vid' => 4,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 4 (node 1)',
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'type' => 'article',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'vid' => 2,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 2 (node 2)',
|
||||
],
|
||||
],
|
||||
'node_revisions' => [
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 1 (node 1)',
|
||||
'body' => 'body for revision 1 (node 1)',
|
||||
'teaser' => 'teaser for revision 1 (node 1)',
|
||||
'log' => 'log for revision 1 (node 1)',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 3,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 3 (node 1)',
|
||||
'body' => 'body for revision 3 (node 1)',
|
||||
'teaser' => 'teaser for revision 3 (node 1)',
|
||||
'log' => 'log for revision 3 (node 1)',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 4,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 4 (node 1)',
|
||||
'body' => 'body for revision 4 (node 1)',
|
||||
'teaser' => 'teaser for revision 4 (node 1)',
|
||||
'log' => 'log for revision 4 (node 1)',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 2 (node 2)',
|
||||
'body' => 'body for revision 2 (node 2)',
|
||||
'teaser' => 'teaser for revision 2 (node 2)',
|
||||
'log' => 'log for revision 2 (node 2)',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279308993,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// There are three revisions of nid 1; vid 4 is the current one. The
|
||||
// NodeRevision plugin should capture every revision EXCEPT that one.
|
||||
// nid 2 will be ignored because $this->migrationConfiguration specifies
|
||||
// a particular node type.
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'vid' => 1,
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 1,
|
||||
'title' => 'title for revision 1 (node 1)',
|
||||
'body' => 'body for revision 1 (node 1)',
|
||||
'teaser' => 'teaser for revision 1 (node 1)',
|
||||
'log' => 'log for revision 1 (node 1)',
|
||||
'format' => 1,
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'vid' => 3,
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 1,
|
||||
'title' => 'title for revision 3 (node 1)',
|
||||
'body' => 'body for revision 3 (node 1)',
|
||||
'teaser' => 'teaser for revision 3 (node 1)',
|
||||
'log' => 'log for revision 3 (node 1)',
|
||||
'format' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\NodeRevisionTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 node revision source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class NodeRevisionTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\NodeRevision';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => [],
|
||||
// The fake configuration for the source.
|
||||
'source' => [
|
||||
'plugin' => 'd6_node_revision',
|
||||
],
|
||||
'sourceIds' => [
|
||||
'vid' => [
|
||||
'alias' => 'v',
|
||||
],
|
||||
],
|
||||
'destinationIds' => [
|
||||
'vid' => [
|
||||
// This is where the field schema would go.
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
protected $databaseContents = [
|
||||
'node' => [
|
||||
[
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'vid' => 4,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 1 (node 1)',
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'type' => 'article',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'vid' => 2,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 2 (node 2)',
|
||||
],
|
||||
],
|
||||
'node_revisions' => [
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 1 (node 1)',
|
||||
'body' => 'body for revision 1 (node 1)',
|
||||
'teaser' => 'teaser for revision 1 (node 1)',
|
||||
'log' => 'log for revision 1 (node 1)',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 3,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 3 (node 1)',
|
||||
'body' => 'body for revision 3 (node 1)',
|
||||
'teaser' => 'teaser for revision 3 (node 1)',
|
||||
'log' => 'log for revision 3 (node 1)',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 4,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 4 (node 1)',
|
||||
'body' => 'body for revision 4 (node 1)',
|
||||
'teaser' => 'teaser for revision 4 (node 1)',
|
||||
'log' => 'log for revision 4 (node 1)',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 2 (node 2)',
|
||||
'body' => 'body for revision 2 (node 2)',
|
||||
'teaser' => 'teaser for revision 2 (node 2)',
|
||||
'log' => 'log for revision 2 (node 2)',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279308993,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// There are three revisions of nid 1, but the NodeRevision source ignores
|
||||
// the current revision. So only two revisions will be returned here. nid 2
|
||||
// is ignored because it only has one revision (the current one).
|
||||
protected $expectedResults = [
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'vid' => 1,
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 1,
|
||||
'title' => 'title for revision 1 (node 1)',
|
||||
'body' => 'body for revision 1 (node 1)',
|
||||
'teaser' => 'teaser for revision 1 (node 1)',
|
||||
'log' => 'log for revision 1 (node 1)',
|
||||
'format' => 1,
|
||||
],
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'vid' => 3,
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 1,
|
||||
'title' => 'title for revision 3 (node 1)',
|
||||
'body' => 'body for revision 3 (node 1)',
|
||||
'teaser' => 'teaser for revision 3 (node 1)',
|
||||
'log' => 'log for revision 3 (node 1)',
|
||||
'format' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\NodeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 node source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class NodeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\Node';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
// The fake configuration for the source.
|
||||
'source' => array(
|
||||
'plugin' => 'd6_node',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 1',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 1',
|
||||
'teaser' => 'teaser for node 1',
|
||||
'log' => '',
|
||||
'timestamp' => 1279051598,
|
||||
'format' => 1,
|
||||
),
|
||||
array(
|
||||
// Node fields.
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 2',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 2',
|
||||
'teaser' => 'teaser for node 2',
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
'format' => 1,
|
||||
),
|
||||
array(
|
||||
// Node fields.
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'type' => 'article',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 5',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 5',
|
||||
'teaser' => 'body for node 5',
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
'format' => 1,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
foreach (array('nid', 'vid', 'title', 'uid', 'body', 'teaser', 'format', 'timestamp', 'log') as $field) {
|
||||
$this->databaseContents['node_revisions'][$k][$field] = $row[$field];
|
||||
switch ($field) {
|
||||
case 'nid': case 'vid':
|
||||
break;
|
||||
case 'uid':
|
||||
$this->databaseContents['node_revisions'][$k]['uid']++;
|
||||
break;
|
||||
default:
|
||||
unset($row[$field]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->databaseContents['node'][$k] = $row;
|
||||
}
|
||||
array_walk($this->expectedResults, function (&$row) {
|
||||
$row['node_uid'] = $row['uid'];
|
||||
$row['revision_uid'] = $row['uid'] + 1;
|
||||
unset($row['uid']);
|
||||
});
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\NodeTypeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 node type source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class NodeTypeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\NodeType';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test_nodetypes',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_nodetype',
|
||||
),
|
||||
);
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
// These are sample result queries.
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'type' => 'page',
|
||||
'name' => 'Page',
|
||||
'module' => 'node',
|
||||
'description' => 'A <em>page</em>, similar in form to a <em>story</em>, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a <em>page</em> entry does not allow visitor comments and is not featured on the site\'s initial home page.',
|
||||
'help' => '',
|
||||
'title_label' => 'Title',
|
||||
'has_body' => 1,
|
||||
'body_label' => 'Body',
|
||||
'min_word_count' => 0,
|
||||
'custom' => 1,
|
||||
'modified' => 0,
|
||||
'locked' => 0,
|
||||
'orig_type' => 'page',
|
||||
),
|
||||
array(
|
||||
'type' => 'story',
|
||||
'name' => 'Story',
|
||||
'module' => 'node',
|
||||
'description' => 'A <em>story</em>, similar in form to a <em>page</em>, is ideal for creating and displaying content that informs or engages website visitors. Press releases, site announcements, and informal blog-like entries may all be created with a <em>story</em> entry. By default, a <em>story</em> entry is automatically featured on the site\'s initial home page, and provides the ability to post comments.',
|
||||
'help' => '',
|
||||
'title_label' => 'Title',
|
||||
'has_body' => 1,
|
||||
'body_label' => 'Body',
|
||||
'min_word_count' => 0,
|
||||
'custom' => 1,
|
||||
'modified' => 0,
|
||||
'locked' => 0,
|
||||
'orig_type' => 'story',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Prepopulate contents with results.
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['node_type'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\ProfileFieldTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 profile field source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class ProfileFieldTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\ProfileField';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = [
|
||||
// The id of the entity, can be any string.
|
||||
'id' => 'test_profile_fields',
|
||||
// Leave it empty for now.
|
||||
'idlist' => [],
|
||||
'source' => [
|
||||
'plugin' => 'd6_profile_field',
|
||||
],
|
||||
];
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
// These are sample result queries.
|
||||
// @todo Add multiple cases.
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'fid' => 1,
|
||||
'title' => 'First name',
|
||||
'name' => 'profile_first_name',
|
||||
'explanation' => 'First name user',
|
||||
'category' => 'profile',
|
||||
'page' => '',
|
||||
'type' => 'textfield',
|
||||
'weight' => 0,
|
||||
'required' => 1,
|
||||
'register' => 0,
|
||||
'visibility' => 2,
|
||||
'autocomplete' => 0,
|
||||
'options' => [],
|
||||
],
|
||||
[
|
||||
'fid' => 2,
|
||||
'title' => 'Last name',
|
||||
'name' => 'profile_last_name',
|
||||
'explanation' => 'Last name user',
|
||||
'category' => 'profile',
|
||||
'page' => '',
|
||||
'type' => 'textfield',
|
||||
'weight' => 0,
|
||||
'required' => 0,
|
||||
'register' => 0,
|
||||
'visibility' => 2,
|
||||
'autocomplete' => 0,
|
||||
'options' => [],
|
||||
],
|
||||
[
|
||||
'fid' => 3,
|
||||
'title' => 'Policy',
|
||||
'name' => 'profile_policy',
|
||||
'explanation' => 'A checkbox that say if you accept policy of website',
|
||||
'category' => 'profile',
|
||||
'page' => '',
|
||||
'type' => 'checkbox',
|
||||
'weight' => 0,
|
||||
'required' => 1,
|
||||
'register' => 1,
|
||||
'visibility' => 2,
|
||||
'autocomplete' => 0,
|
||||
'options' => [],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Prepopulate contents with results.
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['profile_fields'] = $this->expectedResults;
|
||||
foreach ($this->databaseContents['profile_fields'] as &$row) {
|
||||
$row['options'] = serialize([]);
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\RoleTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 role source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class RoleTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\Role';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
// This needs to be the identifier of the actual key: cid for comment, nid
|
||||
// for node and so on.
|
||||
'source' => array(
|
||||
'plugin' => 'd6_user_role',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'rid' => 1,
|
||||
'name' => 'anonymous user',
|
||||
'permissions' => array(
|
||||
'access content',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'rid' => 2,
|
||||
'name' => 'authenticated user',
|
||||
'permissions' => array(
|
||||
'access comments',
|
||||
'access content',
|
||||
'post comments',
|
||||
'post comments without approval',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'rid' => 3,
|
||||
'name' => 'administrator',
|
||||
'permissions' => array(
|
||||
'access comments',
|
||||
'administer comments',
|
||||
'post comments',
|
||||
'post comments without approval',
|
||||
'access content',
|
||||
'administer content types',
|
||||
'administer nodes',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $row) {
|
||||
$this->databaseContents['permission'][] = array(
|
||||
'perm' => implode(', ', $row['permissions']),
|
||||
'rid' => $row['rid'],
|
||||
);
|
||||
unset($row['permissions']);
|
||||
$this->databaseContents['role'][] = $row;
|
||||
}
|
||||
$this->databaseContents['filter_formats'][] = array(
|
||||
'format' => 1,
|
||||
'roles' => '',
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\TermSourceWithVocabularyFilterTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 taxonomy term source with vocabulary filter.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class TermSourceWithVocabularyFilterTest extends TermTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->migrationConfiguration['source']['vocabulary'] = array(5);
|
||||
parent::setUp();
|
||||
$this->expectedResults = array_values(array_filter($this->expectedResults, function($result) {
|
||||
return $result['vid'] == 5;
|
||||
}));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\TermTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
/**
|
||||
* Tests D6 taxonomy term source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class TermTest extends TermTestBase {
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\TermTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Base class for taxonomy term source unit tests.
|
||||
*/
|
||||
abstract class TermTestBase extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\Term';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'highWaterProperty' => array('field' => 'test'),
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_taxonomy_term',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'tid' => 1,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 1',
|
||||
'description' => 'description value 1',
|
||||
'weight' => 0,
|
||||
'parent' => array(0),
|
||||
),
|
||||
array(
|
||||
'tid' => 2,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 2',
|
||||
'description' => 'description value 2',
|
||||
'weight' => 0,
|
||||
'parent' => array(0),
|
||||
),
|
||||
array(
|
||||
'tid' => 3,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 3',
|
||||
'description' => 'description value 3',
|
||||
'weight' => 0,
|
||||
'parent' => array(0),
|
||||
),
|
||||
array(
|
||||
'tid' => 4,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 4',
|
||||
'description' => 'description value 4',
|
||||
'weight' => 1,
|
||||
'parent' => array(1),
|
||||
),
|
||||
array(
|
||||
'tid' => 5,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 5',
|
||||
'description' => 'description value 5',
|
||||
'weight' => 1,
|
||||
'parent' => array(2),
|
||||
),
|
||||
array(
|
||||
'tid' => 6,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 6',
|
||||
'description' => 'description value 6',
|
||||
'weight' => 0,
|
||||
'parent' => array(3, 2),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
foreach ($row['parent'] as $parent) {
|
||||
$this->databaseContents['term_hierarchy'][] = array(
|
||||
'tid' => $row['tid'],
|
||||
'parent' => $parent,
|
||||
);
|
||||
}
|
||||
unset($row['parent']);
|
||||
$this->databaseContents['term_data'][$k] = $row;
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\TestComment.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d6\Comment;
|
||||
|
||||
class TestComment extends Comment {
|
||||
public function setDatabase(Connection $database) {
|
||||
$this->database = $database;
|
||||
}
|
||||
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
|
||||
$this->moduleHandler = $module_handler;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\TestNode.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d6\Node;
|
||||
|
||||
/**
|
||||
* Provides a node source plugin used for unit testing.
|
||||
*/
|
||||
class TestNode extends Node {
|
||||
|
||||
/**
|
||||
* Sets the database connection for this source plugin.
|
||||
*
|
||||
* @param \Drupal\Core\Database\Connection $database
|
||||
*/
|
||||
public function setDatabase(Connection $database) {
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the module handler for this source plugin.
|
||||
*
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
*/
|
||||
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
|
||||
$this->moduleHandler = $module_handler;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\TestNodeRevision.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d6\NodeRevision;
|
||||
|
||||
/**
|
||||
* Provides a node revision source plugin used for unit testing.
|
||||
*/
|
||||
class TestNodeRevision extends NodeRevision {
|
||||
|
||||
/**
|
||||
* Sets the database connection for this source plugin.
|
||||
*
|
||||
* @param \Drupal\Core\Database\Connection $database
|
||||
*/
|
||||
public function setDatabase(Connection $database) {
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the module handler for this source plugin.
|
||||
*
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
*/
|
||||
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
|
||||
$this->moduleHandler = $module_handler;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\TestTerm.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\d6\Term;
|
||||
|
||||
class TestTerm extends Term {
|
||||
public function setDatabase(Connection $database) {
|
||||
$this->database = $database;
|
||||
}
|
||||
public function setModuleHandler(ModuleHandlerInterface $module_handler) {
|
||||
$this->moduleHandler = $module_handler;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\UrlAliasTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests the D6 url alias migrations.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class UrlAliasTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\UrlAlias';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'highWaterProperty' => array('field' => 'test'),
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_url_alias',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'pid' => 1,
|
||||
'src' => 'node/1',
|
||||
'dst' => 'test-article',
|
||||
'language' => 'en',
|
||||
),
|
||||
array(
|
||||
'pid' => 2,
|
||||
'src' => 'node/2',
|
||||
'dst' => 'another-alias',
|
||||
'language' => 'en',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $row) {
|
||||
$this->databaseContents['url_alias'][] = $row;
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\UserPictureTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 user picture source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class UserPictureTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\UserPicture';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test_user_picture',
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_user_picture',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'uid' => 1,
|
||||
'access' => 1382835435,
|
||||
'picture' => 'sites/default/files/pictures/picture-1.jpg',
|
||||
),
|
||||
array(
|
||||
'uid' => 2,
|
||||
'access' => 1382835436,
|
||||
'picture' => 'sites/default/files/pictures/picture-2.jpg',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['users'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\UserTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 user source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class UserTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\User';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_user',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'uid' => 2,
|
||||
'name' => 'admin',
|
||||
// @todo d6 hash?
|
||||
'pass' => '1234',
|
||||
'mail' => 'admin@example.com',
|
||||
'theme' => '',
|
||||
'signature' => '',
|
||||
'signature_format' => 0,
|
||||
'created' => 1279402616,
|
||||
'access' => 1322981278,
|
||||
'login' => 1322699994,
|
||||
'status' => 0,
|
||||
'timezone' => 'America/Lima',
|
||||
'language' => 'en',
|
||||
// @todo Add the file when needed.
|
||||
'picture' => 'sites/default/files/pictures/picture-1.jpg',
|
||||
'init' => 'admin@example.com',
|
||||
'data' => NULL,
|
||||
),
|
||||
array(
|
||||
'uid' => 4,
|
||||
'name' => 'alice',
|
||||
// @todo d6 hash?
|
||||
'pass' => '1234',
|
||||
'mail' => 'alice@example.com',
|
||||
'theme' => '',
|
||||
'signature' => '',
|
||||
'signature_format' => 0,
|
||||
'created' => 1322981368,
|
||||
'access' => 1322982419,
|
||||
'login' => 132298140,
|
||||
'status' => 0,
|
||||
'timezone' => 'America/Lima',
|
||||
'language' => 'en',
|
||||
'picture' => '',
|
||||
'init' => 'alice@example.com',
|
||||
'data' => NULL,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
$this->databaseContents['users'][$k] = $row;
|
||||
}
|
||||
// getDatabase() will not create empty tables, so we need to insert data
|
||||
// even if it's irrelevant to the test.
|
||||
$this->databaseContents['users_roles'] = array(
|
||||
array(
|
||||
'uid' => 99,
|
||||
'rid' => 99,
|
||||
),
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\ViewModeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 view mode source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class ViewModeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\ViewMode';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'view_mode_test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
'source' => array(
|
||||
'plugin' => 'd6_field_instance_view_mode',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => '4',
|
||||
),
|
||||
array(
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 'teaser',
|
||||
),
|
||||
array(
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 'full',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
|
||||
$this->databaseContents['content_node_field_instance'][] = array(
|
||||
'display_settings' => serialize(array(
|
||||
'weight' => '31',
|
||||
'parent' => '',
|
||||
'label' => array(
|
||||
'format' => 'above',
|
||||
),
|
||||
'teaser' => array(
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
),
|
||||
'full' => array(
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
),
|
||||
4 => array(
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
),
|
||||
)),
|
||||
);
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\VocabularyTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 vocabulary source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class VocabularyTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\Vocabulary';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = [
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => [],
|
||||
'source' => [
|
||||
'plugin' => 'd6_vocabulary',
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'vid' => 1,
|
||||
'name' => 'Tags',
|
||||
'description' => 'Tags description.',
|
||||
'help' => 1,
|
||||
'relations' => 0,
|
||||
'hierarchy' => 0,
|
||||
'multiple' => 0,
|
||||
'required' => 0,
|
||||
'tags' => 1,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'node_types' => ['page', 'article'],
|
||||
],
|
||||
[
|
||||
'vid' => 2,
|
||||
'name' => 'Categories',
|
||||
'description' => 'Categories description.',
|
||||
'help' => 1,
|
||||
'relations' => 1,
|
||||
'hierarchy' => 1,
|
||||
'multiple' => 0,
|
||||
'required' => 1,
|
||||
'tags' => 0,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'node_types' => ['article'],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as &$row) {
|
||||
foreach ($row['node_types'] as $type) {
|
||||
$this->databaseContents['vocabulary_node_types'][] = [
|
||||
'type' => $type,
|
||||
'vid' => $row['vid'],
|
||||
];
|
||||
}
|
||||
unset($row['node_types']);
|
||||
}
|
||||
$this->databaseContents['vocabulary'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue