Skip to content
Snippets Groups Projects
Commit 515a55e7 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2807879 by peaton, phenaproxima, alexpott: Convert Contact's Migrate...

Issue #2807879 by peaton, phenaproxima, alexpott: Convert Contact's Migrate source tests to new base class
parent 6b9d34c9
No related branches found
No related tags found
No related merge requests found
<?php
namespace Drupal\Tests\contact\Kernel\Plugin\migrate\source;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests D6 contact category source plugin.
*
* @covers \Drupal\contact\Plugin\migrate\source\ContactCategory
* @group contact
*/
class ContactCategoryTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['contact', 'migrate_drupal', 'user'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [
[
'source_data' => [],
'expected_data' => [],
],
];
$tests[0]['expected_data'] = [
[
'cid' => 1,
'category' => 'contact category value 1',
'recipients' => ['admin@example.com', 'user@example.com'],
'reply' => 'auto reply value 1',
'weight' => 0,
'selected' => 0,
],
[
'cid' => 2,
'category' => 'contact category value 2',
'recipients' => ['admin@example.com', 'user@example.com'],
'reply' => 'auto reply value 2',
'weight' => 0,
'selected' => 0,
],
];
foreach ($tests[0]['expected_data'] as $k => $row) {
$row['recipients'] = implode(',', $row['recipients']);
$tests[0]['source_data']['contact'][$k] = $row;
}
return $tests;
}
}
<?php
namespace Drupal\Tests\contact\Unit\Plugin\migrate\source\d6;
namespace Drupal\Tests\contact\Kernel\Plugin\migrate\source\d6;
use Drupal\contact\Plugin\migrate\source\ContactSettings;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests D6 contact settings source plugin.
*
* @covers \Drupal\contact\Plugin\migrate\source\ContactSettings
* @group contact
*/
class ContactSettingsTest extends MigrateSqlSourceTestCase {
class ContactSettingsTest extends MigrateSqlSourceTestBase {
const PLUGIN_CLASS = ContactSettings::class;
protected $migrationConfiguration = array(
'id' => 'test',
'source' => array(
'plugin' => 'd6_contact_settings',
'variables' => array('site_name'),
),
);
protected $expectedResults = array(
array(
'default_category' => '1',
'site_name' => 'Blorf!',
),
);
/**
* {@inheritdoc}
*/
public static $modules = ['contact', 'migrate_drupal', 'user'];
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->databaseContents['variable'] = array(
array(
public function providerSource() {
$tests = [];
$tests[0]['source_data']['variable'] = [
[
'name' => 'site_name',
'value' => serialize('Blorf!'),
),
);
$this->databaseContents['contact'] = array(
array(
],
];
$tests[0]['source_data']['contact'] = [
[
'cid' => '1',
'category' => 'Website feedback',
'recipients' => 'admin@example.com',
'reply' => '',
'weight' => '0',
'selected' => '1',
)
);
parent::setUp();
]
];
$tests[0]['expected_data'] = [
[
'default_category' => '1',
'site_name' => 'Blorf!',
],
];
$tests[0]['expected_count'] = NULL;
$tests[0]['configuration']['variables'] = ['site_name'];
return $tests;
}
}
<?php
namespace Drupal\Tests\contact\Unit\Plugin\migrate\source;
use Drupal\contact\Plugin\migrate\source\ContactCategory;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests contact_category source plugin.
*
* @group contact
*/
class ContactCategoryTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = ContactCategory::class;
protected $migrationConfiguration = array(
'id' => 'test',
'source' => array(
'plugin' => '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% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment