Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -1,7 +1,8 @@
langcode: en
status: true
dependencies: { }
id: personal
label: 'Personal contact form'
recipients: { }
reply: ''
weight: 0
status: true
langcode: en

View file

@ -43,14 +43,3 @@ contact.settings:
user_default_enabled:
type: boolean
label: 'Personal contact form enabled by default'
migrate.source.d6_contact_settings:
type: migrate_source_sql
label: 'Drupal 6 contact settings'
mapping:
variables:
type: sequence
label: 'Variables'
sequence:
type: string
label: 'Variable'

View file

@ -0,0 +1,12 @@
# Schema for the migration source plugins.
migrate.source.contact_settings:
type: migrate_source_sql
label: 'Drupal contact settings'
mapping:
variables:
type: sequence
label: 'Variables'
sequence:
type: string
label: 'Variable'

View file

@ -21,17 +21,17 @@ function contact_help($route_name, RouteMatchInterface $route_match) {
$contact_page = \Drupal::url('entity.contact_form.collection');
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Contact module allows visitors to contact registered users on your site, using the personal contact form, and also allows you to set up site-wide contact forms. For more information, see the <a href="!contact">online documentation for the Contact module</a>.', array('!contact' => 'https://www.drupal.org/documentation/modules/contact')) . '</p>';
$output .= '<p>' . t('The Contact module allows visitors to contact registered users on your site, using the personal contact form, and also allows you to set up site-wide contact forms. For more information, see the <a href=":contact">online documentation for the Contact module</a>.', array(':contact' => 'https://www.drupal.org/documentation/modules/contact')) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Using the personal contact form') . '</dt>';
$output .= '<dd>' . t("Site visitors can email registered users on your site by using the personal contact form, without knowing or learning the email address of the recipient. When a site visitor is viewing a user profile, the viewer will see a <em>Contact</em> tab or link, which leads to the personal contact form. The personal contact link is not shown when you are viewing your own profile, and users must have both <em>View user information</em> (to see user profiles) and <em>Use users' personal contact forms</em> permission to see the link. The user whose profile is being viewed must also have their personal contact form enabled (this is a user account setting); viewers with <em>Administer users</em> permission can bypass this setting.") . '</dd>';
$output .= '<dt>' . t('Configuring contact forms') . '</dt>';
$output .= '<dd>' . t('On the <a href="!contact_admin">Contact forms page</a>, you can configure the fields and display of the personal contact form, and you can set up one or more site-wide contact forms. Each site-wide contact form has a machine name, a label, and one or more defined recipients; when a site visitor submits the form, the field values are sent to those recipients.', array('!contact_admin' => $contact_page)) . '</dd>';
$output .= '<dd>' . t('On the <a href=":contact_admin">Contact forms page</a>, you can configure the fields and display of the personal contact form, and you can set up one or more site-wide contact forms. Each site-wide contact form has a machine name, a label, and one or more defined recipients; when a site visitor submits the form, the field values are sent to those recipients.', array(':contact_admin' => $contact_page)) . '</dd>';
$output .= '<dt>' . t('Linking to contact forms') . '</dt>';
$output .= '<dd>' . t('One site-wide contact form can be designated as the default contact form. If you choose to designate a default form, the <em>Contact</em> menu link in the <em>Footer</em> menu will link to it. You can modify this link from the <a href="!menu-settings">Menus page</a> if you have the Menu UI module installed. You can also create links to other contact forms; the URL for each form you have set up has format <em>contact/machine_name_of_form</em>.', array('!menu-settings' => $menu_page)) . '</p>';
$output .= '<dd>' . t('One site-wide contact form can be designated as the default contact form. If you choose to designate a default form, the <em>Contact</em> menu link in the <em>Footer</em> menu will link to it. You can modify this link from the <a href=":menu-settings">Menus page</a> if you have the Menu UI module installed. You can also create links to other contact forms; the URL for each form you have set up has format <em>contact/machine_name_of_form</em>.', array(':menu-settings' => $menu_page)) . '</p>';
$output .= '<dt>' . t('Adding content to contact forms') . '</dt>';
$output .= '<dd>' . t('From the <a href="!contact_admin">Contact forms page</a>, you can configure the fields to be shown on contact forms, including their labels and help text. If you would like other content (such as text or images) to appear on a contact form, use a block. You can create and edit blocks on the <a href="!blocks">Block layout page</a>, if the Block module is installed.', array('!blocks' => $block_page, '!contact_admin' => $contact_page)) . '</dd>';
$output .= '<dd>' . t('From the <a href=":contact_admin">Contact forms page</a>, you can configure the fields to be shown on contact forms, including their labels and help text. If you would like other content (such as text or images) to appear on a contact form, use a block. You can create and edit blocks on the <a href=":blocks">Block layout page</a>, if the Block module is installed.', array(':blocks' => $block_page, ':contact_admin' => $contact_page)) . '</dd>';
$output .= '</dl>';
return $output;
@ -40,8 +40,8 @@ function contact_help($route_name, RouteMatchInterface $route_match) {
$block_page = \Drupal::moduleHandler()->moduleExists('block') ? \Drupal::url('block.admin_display') : '#';
$output = '';
$output .= '<p>' . t('The <em>Personal contact form</em> is the form for site visitors to contact registered users; the name and recipients of this form cannot be edited. Other forms listed here are your configured site-wide contact forms, which site visitors can use to send mail to a centralized email address or addresses. You can edit the name and recipients of site-wide forms by choosing the <em>Edit</em> operation. You can also configure the fields and display of both personal and site-wide forms.') . '</p>';
$output .= '<p>' . t('If you have configured a default site-wide contact form, a <em>Contact</em> menu link in the <em>Footer</em> menu will link to it. You can modify this link from the <a href="!menu-settings">Menus page</a> if you have the Menu UI module installed. You can also create links to other contact forms; the URL has format contact/machine_name_of_form.', array('!menu-settings' => $menu_page)) . '</p>';
$output .= '<p>' . t('If you would like additional text to appear on a site-wide contact page, beyond field labels, use a block. You can create and edit blocks on the <a href="!blocks">Block layout page</a>, if you have the Block module installed.', array('!blocks' => $block_page)) . '</p>';
$output .= '<p>' . t('If you have configured a default site-wide contact form, a <em>Contact</em> menu link in the <em>Footer</em> menu will link to it. You can modify this link from the <a href=":menu-settings">Menus page</a> if you have the Menu UI module installed. You can also create links to other contact forms; the URL has format contact/machine_name_of_form.', array(':menu-settings' => $menu_page)) . '</p>';
$output .= '<p>' . t('If you would like additional text to appear on a site-wide contact page, beyond field labels, use a block. You can create and edit blocks on the <a href=":blocks">Block layout page</a>, if you have the Block module installed.', array(':blocks' => $block_page)) . '</p>';
return $output;
}
}
@ -122,17 +122,17 @@ function contact_mail($key, &$message, $params) {
$language = \Drupal::languageManager()->getLanguage($message['langcode']);
$variables = array(
'!site-name' => \Drupal::config('system.site')->get('name'),
'!subject' => $contact_message->getSubject(),
'!form' => !empty($params['contact_form']) ? $params['contact_form']->label() : NULL,
'!form-url' => \Drupal::url('<current>', [], ['absolute' => TRUE, 'language' => $language]),
'!sender-name' => user_format_name($sender),
'@site-name' => \Drupal::config('system.site')->get('name'),
'@subject' => $contact_message->getSubject(),
'@form' => !empty($params['contact_form']) ? $params['contact_form']->label() : NULL,
'@form-url' => \Drupal::url('<current>', [], ['absolute' => TRUE, 'language' => $language]),
'@sender-name' => $sender->getDisplayName(),
);
if ($sender->isAuthenticated()) {
$variables['!sender-url'] = $sender->url('canonical', array('absolute' => TRUE, 'language' => $language));
$variables['@sender-url'] = $sender->url('canonical', array('absolute' => TRUE, 'language' => $language));
}
else {
$variables['!sender-url'] = $params['sender']->getEmail();
$variables['@sender-url'] = $params['sender']->getEmail();
}
$options = array('langcode' => $language->getId());
@ -140,28 +140,28 @@ function contact_mail($key, &$message, $params) {
switch ($key) {
case 'page_mail':
case 'page_copy':
$message['subject'] .= t('[!form] !subject', $variables, $options);
$message['body'][] = t("!sender-name (!sender-url) sent a message using the contact form at !form-url.", $variables, $options);
$build = entity_view($contact_message, 'mail', $language->getId());
$message['subject'] .= t('[@form] @subject', $variables, $options);
$message['body'][] = t("@sender-name (@sender-url) sent a message using the contact form at @form-url.", $variables, $options);
$build = entity_view($contact_message, 'mail');
$message['body'][] = (string) \Drupal::service('renderer')->renderPlain($build);
break;
case 'page_autoreply':
$message['subject'] .= t('[!form] !subject', $variables, $options);
$message['subject'] .= t('[@form] @subject', $variables, $options);
$message['body'][] = $params['contact_form']->getReply();
break;
case 'user_mail':
case 'user_copy':
$variables += array(
'!recipient-name' => user_format_name($params['recipient']),
'!recipient-edit-url' => $params['recipient']->url('edit-form', array('absolute' => TRUE, 'language' => $language)),
'@recipient-name' => $params['recipient']->getDisplayName(),
'@recipient-edit-url' => $params['recipient']->url('edit-form', array('absolute' => TRUE, 'language' => $language)),
);
$message['subject'] .= t('[!site-name] !subject', $variables, $options);
$message['body'][] = t('Hello !recipient-name,', $variables, $options);
$message['body'][] = t("!sender-name (!sender-url) has sent you a message via your contact form at !site-name.", $variables, $options);
$message['body'][] = t("If you don't want to receive such emails, you can change your settings at !recipient-edit-url.", $variables, $options);
$build = entity_view($contact_message, 'mail', $language->getId());
$message['subject'] .= t('[@site-name] @subject', $variables, $options);
$message['body'][] = t('Hello @recipient-name,', $variables, $options);
$message['body'][] = t("@sender-name (@sender-url) has sent you a message via your contact form at @site-name.", $variables, $options);
$message['body'][] = t("If you don't want to receive such emails, you can change your settings at @recipient-edit-url.", $variables, $options);
$build = entity_view($contact_message, 'mail');
$message['body'][] = (string) \Drupal::service('renderer')->renderPlain($build);
break;
}

View file

@ -1,9 +1,10 @@
id: d6_contact_category
label: Drupal 6 contact category configuration
id: contact_category
label: Contact category configuration
migration_tags:
- Drupal 6
- Drupal 7
source:
plugin: d6_contact_category
plugin: contact_category
process:
id:
-

View file

@ -1,9 +1,9 @@
id: d6_contact_settings
label: Drupal 6 contact configuration
label: Contact configuration
migration_tags:
- Drupal 6
source:
plugin: d6_contact_settings
plugin: contact_settings
variables:
- contact_default_status
- contact_hourly_threshold
@ -12,11 +12,11 @@ process:
'flood/limit': contact_hourly_threshold
default_form:
plugin: migration
migration: d6_contact_category
migration: contact_category
source: default_category
destination:
plugin: config
config_name: contact.settings
migration_dependencies:
required:
- d6_contact_category
- contact_category

View file

@ -0,0 +1,28 @@
id: d7_contact_settings
label: Contact configuration
migration_tags:
- Drupal 7
source:
plugin: contact_settings
variables:
- contact_default_status
- contact_threshold_limit
process:
user_default_enabled: contact_default_status
'flood/limit': contact_threshold_limit
default_form:
plugin: migration
migration: contact_category
source: default_category
destination:
plugin: config
config_name: contact.settings
migration_dependencies:
required:
- contact_category
dependencies:
config:
- migrate.migration.contact_category
module:
- contact
- migrate_drupal

View file

@ -22,7 +22,7 @@ class ContactFormAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
if ($operation == 'view') {
// Do not allow access personal form via site-wide route.
return AccessResult::allowedIf($account->hasPermission('access site-wide contact form') && $entity->id() !== 'personal')->cachePerPermissions();
@ -33,7 +33,7 @@ class ContactFormAccessControlHandler extends EntityAccessControlHandler {
return AccessResult::allowedIf($account->hasPermission('administer contact forms') && $entity->id() !== 'personal')->cachePerPermissions();
}
return parent::checkAccess($entity, $operation, $langcode, $account);
return parent::checkAccess($entity, $operation, $account);
}
}

View file

@ -15,10 +15,10 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface;
interface ContactFormInterface extends ConfigEntityInterface {
/**
* Returns list of recipient e-mail addresses.
* Returns list of recipient email addresses.
*
* @return array
* List of recipient e-mail addresses.
* List of recipient email addresses.
*/
public function getRecipients();
@ -39,10 +39,10 @@ interface ContactFormInterface extends ConfigEntityInterface {
public function getWeight();
/**
* Sets list of recipient e-mail addresses.
* Sets list of recipient email addresses.
*
* @param array $recipients
* The desired list of e-mail addresses of this category.
* The desired list of email addresses of this category.
*
* @return $this
*/

View file

@ -69,8 +69,8 @@ class ContactController extends ControllerBase {
// If there are no forms, do not display the form.
if (empty($contact_form)) {
if ($this->currentUser()->hasPermission('administer contact forms')) {
drupal_set_message($this->t('The contact form has not been configured. <a href="@add">Add one or more forms</a> .', array(
'@add' => $this->url('contact.form_add'))), 'error');
drupal_set_message($this->t('The contact form has not been configured. <a href=":add">Add one or more forms</a> .', array(
':add' => $this->url('contact.form_add'))), 'error');
return array();
}
else {
@ -103,10 +103,10 @@ class ContactController extends ControllerBase {
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* Exception is thrown when user tries to access a contact form for a
* user who does not have an e-mail address configured.
* user who does not have an email address configured.
*/
public function contactPersonalPage(UserInterface $user) {
// Do not continue if the user does not have an e-mail address configured.
// Do not continue if the user does not have an email address configured.
if (!$user->getEmail()) {
throw new NotFoundHttpException();
}
@ -117,7 +117,7 @@ class ContactController extends ControllerBase {
));
$form = $this->entityFormBuilder()->getForm($message);
$form['#title'] = $this->t('Contact @username', array('@username' => $user->getUsername()));
$form['#title'] = $this->t('Contact @username', array('@username' => $user->getDisplayName()));
$form['#cache']['contexts'][] = 'user.permissions';
return $form;
}

View file

@ -91,7 +91,7 @@ class MailHandler implements MailHandlerInterface {
// For the email message, clarify that the sender name is not verified; it
// could potentially clash with a username on this site.
$sender_cloned->name = $this->t('!name (not verified)', array('!name' => $message->getSenderName()));
$sender_cloned->name = $this->t('@name (not verified)', array('@name' => $message->getSenderName()));
}
// Build email parameters.

View file

@ -8,7 +8,7 @@
namespace Drupal\contact;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Flood\FloodInterface;
@ -53,7 +53,7 @@ class MessageForm extends ContentEntityForm {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatter
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
@ -68,10 +68,10 @@ class MessageForm extends ContentEntityForm {
* The language manager service.
* @param \Drupal\contact\MailHandlerInterface $mail_handler
* The contact mail handler service.
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date service.
*/
public function __construct(EntityManagerInterface $entity_manager, FloodInterface $flood, LanguageManagerInterface $language_manager, MailHandlerInterface $mail_handler, DateFormatter $date_formatter) {
public function __construct(EntityManagerInterface $entity_manager, FloodInterface $flood, LanguageManagerInterface $language_manager, MailHandlerInterface $mail_handler, DateFormatterInterface $date_formatter) {
parent::__construct($entity_manager);
$this->flood = $flood;
$this->languageManager = $language_manager;

View file

@ -20,8 +20,8 @@ class MessageViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*/
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) {
$build = parent::getBuildDefaults($entity, $view_mode, $langcode);
protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
$build = parent::getBuildDefaults($entity, $view_mode);
// The message fields are individually rendered into email templates, so
// the entity has no template itself.
unset($build['#theme']);
@ -31,8 +31,8 @@ class MessageViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*/
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
parent::buildComponents($build, $entities, $displays, $view_mode, $langcode);
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
parent::buildComponents($build, $entities, $displays, $view_mode);
foreach ($entities as $id => $entity) {
// Add the message extra field, if enabled.

View file

@ -2,19 +2,19 @@
/**
* @file
* Contains \Drupal\contact\Plugin\migrate\source\d6\ContactCategory.
* Contains \Drupal\contact\Plugin\migrate\source\ContactCategory.
*/
namespace Drupal\contact\Plugin\migrate\source\d6;
namespace Drupal\contact\Plugin\migrate\source;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 contact category source from database.
* Contact category source from database.
*
* @MigrateSource(
* id = "d6_contact_category",
* id = "contact_category",
* source_provider = "contact"
* )
*/

View file

@ -2,16 +2,16 @@
/**
* @file
* Contains \Drupal\contact\Plugin\migrate\source\d6\ContactSettings.
* Contains \Drupal\contact\Plugin\migrate\source\ContactSettings.
*/
namespace Drupal\contact\Plugin\migrate\source\d6;
namespace Drupal\contact\Plugin\migrate\source;
use Drupal\migrate_drupal\Plugin\migrate\source\Variable;
/**
* @MigrateSource(
* id = "d6_contact_settings",
* id = "contact_settings",
* source_provider = "contact"
* )
*/
@ -20,13 +20,13 @@ class ContactSettings extends Variable {
/**
* {@inheritdoc}
*/
function initializeIterator() {
protected function initializeIterator() {
$default_category = $this->select('contact', 'c')
->fields('c', array('cid'))
->fields('c', ['cid'])
->condition('selected', 1)
->execute()
->fetchField();
return new \ArrayIterator(array($this->values() + array('default_category' => $default_category)));
return new \ArrayIterator([$this->values() + ['default_category' => $default_category]]);
}
}

View file

@ -8,6 +8,7 @@
namespace Drupal\contact\Tests;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\PlainTextOutput;
use Drupal\Core\Session\AccountInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\user\RoleInterface;
@ -79,12 +80,13 @@ class ContactPersonalTest extends WebTestBase {
$this->assertEqual($mail['reply-to'], $this->webUser->getEmail());
$this->assertEqual($mail['key'], 'user_mail');
$variables = array(
'!site-name' => $this->config('system.site')->get('name'),
'!subject' => $message['subject[0][value]'],
'!recipient-name' => $this->contactUser->getUsername(),
'@site-name' => $this->config('system.site')->get('name'),
'@subject' => $message['subject[0][value]'],
'@recipient-name' => $this->contactUser->getUsername(),
);
$this->assertEqual($mail['subject'], t('[!site-name] !subject', $variables), 'Subject is in sent message.');
$this->assertTrue(strpos($mail['body'], 'Hello ' . $variables['!recipient-name']) !== FALSE, 'Recipient name is in sent message.');
$subject = PlainTextOutput::renderFromHtml(t('[@site-name] @subject', $variables));
$this->assertEqual($mail['subject'], $subject, 'Subject is in sent message.');
$this->assertTrue(strpos($mail['body'], 'Hello ' . $variables['@recipient-name']) !== FALSE, 'Recipient name is in sent message.');
$this->assertTrue(strpos($mail['body'], $this->webUser->getUsername()) !== FALSE, 'Sender name is in sent message.');
$this->assertTrue(strpos($mail['body'], $message['message[0][value]']) !== FALSE, 'Message body is in sent message.');

View file

@ -40,6 +40,7 @@ class ContactSitewideTest extends WebTestBase {
parent::setUp();
$this->drupalPlaceBlock('system_breadcrumb_block');
$this->drupalPlaceBlock('local_actions_block');
$this->drupalPlaceBlock('page_title_block');
}
/**
@ -129,7 +130,7 @@ class ContactSitewideTest extends WebTestBase {
$max_length = EntityTypeInterface::BUNDLE_MAX_LENGTH;
$max_length_exceeded = $max_length + 1;
$this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', array($recipients[0])), '', TRUE);
$this->assertText(format_string('Machine-readable name cannot be longer than !max characters but is currently !exceeded characters long.', array('!max' => $max_length, '!exceeded' => $max_length_exceeded)));
$this->assertText(format_string('Machine-readable name cannot be longer than @max characters but is currently @exceeded characters long.', array('@max' => $max_length, '@exceeded' => $max_length_exceeded)));
$this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', array($recipients[0])), '', TRUE);
$this->assertRaw(t('Contact form %label has been added.', array('%label' => $label)));

View file

@ -0,0 +1,69 @@
<?php
/**
* @file
* Contains \Drupal\contact\Tests\Migrate\MigrateContactCategoryTest.
*/
namespace Drupal\contact\Tests\Migrate;
use Drupal\contact\Entity\ContactForm;
use Drupal\contact\ContactFormInterface;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Migrate contact categories to contact.form.*.yml.
*
* @group contact_category
*/
class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('contact');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('contact_category');
}
/**
* Performs various assertions on a single contact form entity.
*
* @param string $id
* The contact form ID.
* @param string $expected_label
* The expected label.
* @param string[] $expected_recipients
* The recipient e-mail addresses the form should have.
* @param string $expected_reply
* The expected reply message.
* @param integer $expected_weight
* The contact form's expected weight.
*/
protected function assertEntity($id, $expected_label, array $expected_recipients, $expected_reply, $expected_weight) {
/** @var \Drupal\contact\ContactFormInterface $entity */
$entity = ContactForm::load($id);
$this->assertTrue($entity instanceof ContactFormInterface);
$this->assertIdentical($expected_label, $entity->label());
$this->assertIdentical($expected_recipients, $entity->getRecipients());
$this->assertIdentical($expected_reply, $entity->getReply());
$this->assertIdentical($expected_weight, $entity->getWeight());
}
/**
* The Drupal 6 and 7 contact categories to Drupal 8 migration.
*/
public function testContactCategory() {
$this->assertEntity('website_feedback', 'Website feedback', ['admin@example.com'], '', 0);
$this->assertEntity('some_other_category', 'Some other category', ['test@example.com'], 'Thanks for contacting us, we will reply ASAP!', 1);
$this->assertEntity('a_category_much_longer_than_thir', 'A category much longer than thirty two characters', ['fortyninechars@example.com'], '', 2);
}
}

View file

@ -18,18 +18,16 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = array('contact');
public static $modules = ['contact'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_contact_category');
$this->executeMigration('contact_category');
}
/**

View file

@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\contact\Tests\Migrate\d6\MigrateContactConfigsTest.
* Contains \Drupal\contact\Tests\Migrate\d6\MigrateContactSettingsTest.
*/
namespace Drupal\contact\Tests\Migrate\d6;
@ -15,31 +15,21 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
*
* @group migrate_drupal_6
*/
class MigrateContactConfigsTest extends MigrateDrupal6TestBase {
class MigrateContactSettingsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = array('contact');
public static $modules = ['contact'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Add some id mappings for the dependent migrations.
$id_mappings = array(
'd6_contact_category' => array(
array(array(1), array('website_feedback')),
array(array(2), array('some_other_category')),
),
);
$this->prepareMigrations($id_mappings);
$this->executeMigration('d6_contact_settings');
$this->executeMigrations(['contact_category', 'd6_contact_settings']);
}
/**

View file

@ -0,0 +1,43 @@
<?php
/**
* @file
* Contains \Drupal\contact\Tests\Migrate\d7\MigrateContactSettingsTest.
*/
namespace Drupal\contact\Tests\Migrate\d7;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
/**
* Tests migration of Contact settings to configuration.
*
* @group migrate_drupal_7
*/
class MigrateContactSettingsTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['contact'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('contact_category');
$this->executeMigration('d7_contact_settings');
}
/**
* Tests migration of Contact's variables to configuration.
*/
public function testContactSettings() {
$config = $this->config('contact.settings');
$this->assertTrue($config->get('user_default_enabled'));
$this->assertIdentical(33, $config->get('flood.limit'));
$this->assertEqual('website_testing', $config->get('default_form'));
}
}

View file

@ -58,10 +58,10 @@ display:
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next '
first: first'
last: 'last »'
previous: ' Previous'
next: 'Next '
first: First'
last: 'Last »'
quantity: 9
style:
type: default
@ -133,7 +133,7 @@ display:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
cacheable: false
max-age: 0
page_1:
display_plugin: page
id: page_1
@ -146,4 +146,4 @@ display:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
cacheable: false
max-age: 0

View file

@ -2,26 +2,27 @@
/**
* @file
* Contains \Drupal\Tests\contact\Unit\Plugin\migrate\source\d6\ContactCategoryTest.
* Contains \Drupal\Tests\contact\Unit\Plugin\migrate\source\ContactCategoryTest.
*/
namespace Drupal\Tests\contact\Unit\Plugin\migrate\source\d6;
namespace Drupal\Tests\contact\Unit\Plugin\migrate\source;
use Drupal\contact\Plugin\migrate\source\ContactCategory;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 contact category source plugin.
* Tests contact_category source plugin.
*
* @group contact
*/
class ContactCategoryTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\contact\Plugin\migrate\source\d6\ContactCategory';
const PLUGIN_CLASS = ContactCategory::class;
protected $migrationConfiguration = array(
'id' => 'test',
'source' => array(
'plugin' => 'd6_contact_category',
'plugin' => 'contact_category',
),
);

View file

@ -0,0 +1,60 @@
<?php
/**
* @file
* Contains \Drupal\Tests\contact\Unit\Plugin\migrate\source\d6\ContactSettingsTest.
*/
namespace Drupal\Tests\contact\Unit\Plugin\migrate\source\d6;
use Drupal\contact\Plugin\migrate\source\ContactSettings;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 contact settings source plugin.
*
* @group contact
*/
class ContactSettingsTest extends MigrateSqlSourceTestCase {
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}
*/
protected function setUp() {
$this->databaseContents['variable'] = array(
array(
'name' => 'site_name',
'value' => serialize('Blorf!'),
),
);
$this->databaseContents['contact'] = array(
array(
'cid' => '1',
'category' => 'Website feedback',
'recipients' => 'admin@example.com',
'reply' => '',
'weight' => '0',
'selected' => '1',
)
);
parent::setUp();
}
}