Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\webform\Functional;
|
||||
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\webform\Entity\Webform;
|
||||
|
||||
/**
|
||||
* These tests proof that the webform block which
|
||||
* renders the webform as a block provides the correct
|
||||
* cache tags / cache contexts so that cachability works.
|
||||
*
|
||||
* @group webform_browser
|
||||
*/
|
||||
class WebformBlockCacheTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['block', 'webform', 'page_cache', 'dynamic_page_cache', 'node'];
|
||||
|
||||
/**
|
||||
* Authenticated user.
|
||||
*
|
||||
* @var \Drupal\user\Entity\User
|
||||
*/
|
||||
private $authenticatedUser;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->authenticatedUser = $this->createUser([
|
||||
'access content',
|
||||
]);
|
||||
|
||||
$this->createContentType(['type' => 'page']);
|
||||
|
||||
Node::create([
|
||||
'title' => $this->randomString(),
|
||||
'type' => 'page',
|
||||
])->save();
|
||||
|
||||
$this->drupalPlaceBlock('webform_block', [
|
||||
'webform_id' => 'contact',
|
||||
'region' => 'footer',
|
||||
])->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that an anonymous can visit the webform block and the page is cacheable.
|
||||
*/
|
||||
public function testAnonymousVisitIsCacheable() {
|
||||
$this->drupalGet('/node/1');
|
||||
$this->assertSession()->responseContains('Contact');
|
||||
$this->assertEquals('MISS', $this->drupalGetHeader('X-Drupal-Cache'));
|
||||
$this->drupalGet('/node/1');
|
||||
$this->assertEquals('HIT', $this->drupalGetHeader('X-Drupal-Cache'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that admin user can visit the page and the it is cacheable.
|
||||
*/
|
||||
public function testAuthenticatedVisitIsCacheable() {
|
||||
$this->drupalLogin($this->authenticatedUser);
|
||||
|
||||
$this->drupalGet('/node/1');
|
||||
$this->assertSession()->responseContains('Contact');
|
||||
$this->assertEquals('MISS', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'));
|
||||
$this->drupalGet('/node/1');
|
||||
$this->assertEquals('HIT', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that if an Webform is access restricted the page can still be cached.
|
||||
*/
|
||||
public function testAuthenticatedAndRestrictedVisitIsCacheable() {
|
||||
/** @var \Drupal\webform\WebformAccessRulesManagerInterface $access_rules_manager */
|
||||
$access_rules_manager = \Drupal::service('webform.access_rules_manager');
|
||||
$default_access_rules = $access_rules_manager->getDefaultAccessRules();
|
||||
|
||||
$access_rules = [
|
||||
'create' => [
|
||||
'roles' => [],
|
||||
'users' => [],
|
||||
'permissions' => ['access content'],
|
||||
],
|
||||
] + $default_access_rules;
|
||||
|
||||
Webform::load('contact')->setAccessRules($access_rules)->save();
|
||||
|
||||
$this->drupalLogin($this->authenticatedUser);
|
||||
|
||||
$this->drupalGet('/node/1');
|
||||
$this->assertSession()->responseContains('Contact');
|
||||
$this->assertEquals('MISS', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'));
|
||||
$this->drupalGet('/node/1');
|
||||
$this->assertEquals('HIT', $this->drupalGetHeader('X-Drupal-Dynamic-Cache'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\webform\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Webform contribute browser test.
|
||||
*
|
||||
* @group webform_browser
|
||||
*/
|
||||
class WebformContributeFunctionalTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['block', 'webform'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalLogin($this->rootUser);
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test 'Contribute' section.
|
||||
*/
|
||||
public function testContribute() {
|
||||
// Check that the 'Status report' includes 'Community information'.
|
||||
$this->drupalGet('/admin/structure/webform/contribute');
|
||||
$this->assertSession()->responseContains('Community information');
|
||||
$this->assertSession()->responseContains('When you <a href="https://register.drupal.org/user/register">create a Drupal.org account</a>, you gain access to a whole ecosystem of Drupal.org sites and services.');
|
||||
|
||||
// Check that the 'Status report' includes jrockowitz's user information.
|
||||
$edit = [
|
||||
'account_type' => 'user',
|
||||
'user_id' => 'jrockowitz',
|
||||
];
|
||||
$this->drupalPostForm('/admin/structure/webform/contribute/configure', $edit, t('Save'));
|
||||
$this->assertSession()->responseContains('Community information has been saved.');
|
||||
$this->assertSession()->responseContains('Community information');
|
||||
$this->assertSession()->responseNotContains('When you <a href="https://register.drupal.org/user/register">create a Drupal.org account</a>, you gain access to a whole ecosystem of Drupal.org sites and services.');
|
||||
$this->assertSession()->responseContains('<strong><a href="https://www.drupal.org/u/jrockowitz">Jacob Rockowitz</a></strong>');
|
||||
|
||||
// Check that 'Community information' can be cleared.
|
||||
$this->drupalPostForm('/admin/structure/webform/contribute/configure', [], t('Clear'));
|
||||
$this->assertSession()->responseContains('Community information has been cleared.');
|
||||
$this->assertSession()->responseNotContains('<strong><a href="https://www.drupal.org/u/jrockowitz">Jacob Rockowitz</a></strong>');
|
||||
|
||||
// Check that 'Contribute' local task is visible.
|
||||
$this->drupalGet('/admin/structure/webform');
|
||||
$this->assertSession()->linkExists('Contribute');
|
||||
|
||||
// Check that 'Contribute' route is accessible.
|
||||
$this->drupalGet('/admin/structure/webform/contribute');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
|
||||
// Check that 'Community information' can be disabled.
|
||||
$edit = ['ui[contribute_disabled]' => TRUE];
|
||||
$this->drupalPostForm('/admin/structure/webform/config/advanced', $edit, t('Save'));
|
||||
|
||||
// Check that 'Contribute' local task is hidden.
|
||||
$this->drupalGet('/admin/structure/webform');
|
||||
$this->assertSession()->linkNotExists('Contribute');
|
||||
|
||||
// Check that 'Contribute' route is removed.
|
||||
$this->drupalGet('/admin/structure/webform/contribute');
|
||||
$this->assertSession()->statusCodeEquals(404);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,18 +16,12 @@ class WebformExampleFunctionalTest extends BrowserTestBase {
|
|||
*/
|
||||
public static $modules = ['webform'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get.
|
||||
*/
|
||||
public function testGet() {
|
||||
$this->drupalGet('/webform/contact');
|
||||
$this->verbose('hi');
|
||||
$this->assertSession()->responseContains('Contact');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\webform\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests for webform list builder.
|
||||
*
|
||||
* @group Webform
|
||||
*/
|
||||
class WebformListBuilderTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['node', 'webform', 'webform_test_submissions'];
|
||||
|
||||
/**
|
||||
* Tests the webform overview page.
|
||||
*/
|
||||
public function testWebformOverview() {
|
||||
$assert_session = $this->assertSession();
|
||||
|
||||
// Test with a superuser.
|
||||
$any_webform_user = $this->createUser([
|
||||
'access webform overview',
|
||||
'create webform',
|
||||
'edit any webform',
|
||||
'delete any webform',
|
||||
]);
|
||||
$this->drupalLogin($any_webform_user);
|
||||
$list_path = '/admin/structure/webform';
|
||||
$this->drupalGet($list_path);
|
||||
$assert_session->linkExists('Test: Submissions');
|
||||
$assert_session->linkExists('Results');
|
||||
$assert_session->linkExists('Build');
|
||||
$assert_session->linkExists('Settings');
|
||||
$assert_session->linkExists('View');
|
||||
$assert_session->linkExists('Duplicate');
|
||||
$assert_session->linkExists('Delete');
|
||||
|
||||
// Test with a user that only has submission access.
|
||||
$any_webform_submission_user = $this->createUser([
|
||||
'access webform overview',
|
||||
'view any webform submission',
|
||||
'edit any webform submission',
|
||||
'delete any webform submission',
|
||||
]);
|
||||
$this->drupalLogin($any_webform_submission_user);
|
||||
$this->drupalGet($list_path);
|
||||
// Webform name should not be a link as the user doesn't have access to the
|
||||
// submission page.
|
||||
$assert_session->linkExists('Test: Submissions');
|
||||
$assert_session->linkExists('Results');
|
||||
$assert_session->linkNotExists('Build');
|
||||
$assert_session->linkNotExists('Settings');
|
||||
$assert_session->linkExists('View');
|
||||
$assert_session->linkNotExists('Duplicate');
|
||||
$assert_session->linkNotExists('Delete');
|
||||
|
||||
// Disable webform page setting to ensure the view links get removed.
|
||||
$webform_config = \Drupal::configFactory()->getEditable('webform.webform.test_submissions');
|
||||
$settings = $webform_config->get('settings');
|
||||
$settings['page'] = FALSE;
|
||||
$webform_config->set('settings', $settings)->save();
|
||||
$this->drupalGet($list_path);
|
||||
$assert_session->linkNotExists('Test: Submissions');
|
||||
$assert_session->responseContains('Test: Submissions');
|
||||
$this->assertLinkNotInRow('Test: Submissions', 'View');
|
||||
|
||||
// Test with role that is configured via webform access settings.
|
||||
$rid = $this->drupalCreateRole(['access webform overview']);
|
||||
$special_access_user = $this->createUser();
|
||||
$special_access_user->addRole($rid);
|
||||
$special_access_user->save();
|
||||
$access = $webform_config->get('access');
|
||||
$access['view_any']['roles'][] = $rid;
|
||||
$webform_config->set('access', $access)->save();
|
||||
$this->drupalLogin($special_access_user);
|
||||
$this->drupalGet($list_path);
|
||||
$assert_session->responseContains('Test: Submissions');
|
||||
$assert_session->linkExists('Results');
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts a link is not in a row.
|
||||
*
|
||||
* @param string $row_text
|
||||
* Text to find a row.
|
||||
* @param string $link
|
||||
* The link to find.
|
||||
*
|
||||
* @throws \Exception
|
||||
* When the row can't be found.
|
||||
*/
|
||||
protected function assertLinkNotInRow($row_text, $link) {
|
||||
$row = $this->getSession()->getPage()->find('css', sprintf('table tr:contains("%s")', $row_text));
|
||||
if (!$row) {
|
||||
throw new \Exception($this->getSession()->getDriver(), 'table row', 'value', $row_text);
|
||||
}
|
||||
|
||||
$links = $row->findAll('named', ['link', $link]);
|
||||
$this->assertEmpty($links, sprintf('Link with label %s found in row %s.', $link, $row_text));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\webform\Functional;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Performs tests on the pluggable mailing framework.
|
||||
*
|
||||
* @group webform_browser
|
||||
*/
|
||||
class WebformMailTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['webform'];
|
||||
|
||||
/**
|
||||
* Checks the From: and Reply-to: headers.
|
||||
*/
|
||||
public function testFromAndReplyToHeader() {
|
||||
$language = \Drupal::languageManager()->getCurrentLanguage();
|
||||
|
||||
// Use the state system collector mail backend.
|
||||
$this->config('system.mail')->set('interface.default', 'test_mail_collector')->save();
|
||||
// Reset the state variable that holds sent messages.
|
||||
\Drupal::state()->set('system.test_mail_collector', []);
|
||||
// Send an email with a reply-to address specified.
|
||||
$from_email = 'simpletest@example.com';
|
||||
$reply_email = 'webform@example.com';
|
||||
|
||||
// Send an email and check that the From-header contains the from_name.
|
||||
\Drupal::service('plugin.manager.mail')->mail('webform', '', 'from_test@example.com', $language, ['subject' => '', 'body' => '', 'from_mail' => $from_email, 'from_name' => 'Drépal'], $reply_email);
|
||||
|
||||
$captured_emails = \Drupal::state()->get('system.test_mail_collector');
|
||||
$sent_message = end($captured_emails);
|
||||
$this->assertEqual('=?UTF-8?B?RHLDg8KpcGFs?= <simpletest@example.com>', $sent_message['headers']['From'], 'From header is correctly encoded.');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue