Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -0,0 +1,71 @@
<?php
namespace Drupal\Tests\contact\Kernel;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
/**
* Tests the message entity class.
*
* @group contact
* @see \Drupal\contact\Entity\Message
*/
class MessageEntityTest extends EntityKernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array(
'system',
'contact',
'field',
'user',
'contact_test',
);
protected function setUp() {
parent::setUp();
$this->installConfig(array('contact', 'contact_test'));
}
/**
* Test some of the methods.
*/
public function testMessageMethods() {
$message_storage = $this->container->get('entity.manager')->getStorage('contact_message');
$message = $message_storage->create(array('contact_form' => 'feedback'));
// Check for empty values first.
$this->assertEqual($message->getMessage(), '');
$this->assertEqual($message->getSenderName(), '');
$this->assertEqual($message->getSenderMail(), '');
$this->assertFalse($message->copySender());
// Check for default values.
$this->assertEqual('feedback', $message->getContactForm()->id());
$this->assertFalse($message->isPersonal());
// Set some values and check for them afterwards.
$message->setMessage('welcome_message');
$message->setSenderName('sender_name');
$message->setSenderMail('sender_mail');
$message->setCopySender(TRUE);
$this->assertEqual($message->getMessage(), 'welcome_message');
$this->assertEqual($message->getSenderName(), 'sender_name');
$this->assertEqual($message->getSenderMail(), 'sender_mail');
$this->assertTrue($message->copySender());
$no_access_user = $this->createUser(['uid' => 2]);
$access_user = $this->createUser(['uid' => 3], ['access site-wide contact form']);
$admin = $this->createUser(['uid' => 4], ['administer contact forms']);
$this->assertFalse(\Drupal::entityManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $no_access_user));
$this->assertTrue(\Drupal::entityManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $access_user));
$this->assertTrue($message->access('edit', $admin));
$this->assertFalse($message->access('edit', $access_user));
}
}

View file

@ -0,0 +1,64 @@
<?php
namespace Drupal\Tests\contact\Kernel\Migrate;
use Drupal\contact\Entity\ContactForm;
use Drupal\contact\ContactFormInterface;
use Drupal\Tests\migrate_drupal\Kernel\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 int $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

@ -0,0 +1,52 @@
<?php
namespace Drupal\Tests\contact\Kernel\Migrate\d6;
use Drupal\contact\Entity\ContactForm;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Migrate contact categories to contact.form.*.yml.
*
* @group migrate_drupal_6
*/
class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['contact'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('contact_category');
}
/**
* The Drupal 6 contact categories to Drupal 8 migration.
*/
public function testContactCategory() {
/** @var \Drupal\contact\Entity\ContactForm $contact_form */
$contact_form = ContactForm::load('website_feedback');
$this->assertIdentical('Website feedback', $contact_form->label());
$this->assertIdentical(array('admin@example.com'), $contact_form->getRecipients());
$this->assertIdentical('', $contact_form->getReply());
$this->assertIdentical(0, $contact_form->getWeight());
$contact_form = ContactForm::load('some_other_category');
$this->assertIdentical('Some other category', $contact_form->label());
$this->assertIdentical(array('test@example.com'), $contact_form->getRecipients());
$this->assertIdentical('Thanks for contacting us, we will reply ASAP!', $contact_form->getReply());
$this->assertIdentical(1, $contact_form->getWeight());
$contact_form = ContactForm::load('a_category_much_longer_than_thir');
$this->assertIdentical('A category much longer than thirty two characters', $contact_form->label());
$this->assertIdentical(array('fortyninechars@example.com'), $contact_form->getRecipients());
$this->assertIdentical('', $contact_form->getReply());
$this->assertIdentical(2, $contact_form->getWeight());
}
}

View file

@ -0,0 +1,41 @@
<?php
namespace Drupal\Tests\contact\Kernel\Migrate\d6;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to contact.settings.yml.
*
* @group migrate_drupal_6
*/
class MigrateContactSettingsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['contact'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigrations(['contact_category', 'd6_contact_settings']);
}
/**
* Tests migration of contact variables to contact.settings.yml.
*/
public function testContactSettings() {
$config = $this->config('contact.settings');
$this->assertIdentical(true, $config->get('user_default_enabled'));
$this->assertIdentical(3, $config->get('flood.limit'));
$this->assertIdentical('some_other_category', $config->get('default_form'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'contact.settings', $config->get());
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace Drupal\Tests\contact\Kernel\Migrate\d7;
use Drupal\Tests\migrate_drupal\Kernel\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

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\contact\Unit\MailHandlerTest.
*/
namespace Drupal\Tests\contact\Unit;
use Drupal\contact\MailHandler;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\Tests\contact\Unit\Plugin\migrate\source\ContactCategoryTest.
*/
namespace Drupal\Tests\contact\Unit\Plugin\migrate\source;
use Drupal\contact\Plugin\migrate\source\ContactCategory;

View file

@ -1,10 +1,5 @@
<?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;