Update to Drupal 8.1.1. For more information, see https://www.drupal.org/node/2718713
This commit is contained in:
parent
c0a0d5a94c
commit
9eae24d844
669 changed files with 3873 additions and 1553 deletions
|
@ -51,7 +51,7 @@ function simpletest_requirements($phase) {
|
|||
}
|
||||
|
||||
$site_directory = 'sites/simpletest';
|
||||
if (!drupal_verify_install_file(\Drupal::root() . '/' . $site_directory, FILE_EXIST|FILE_READABLE|FILE_WRITABLE|FILE_EXECUTABLE, 'dir')) {
|
||||
if (!drupal_verify_install_file(\Drupal::root() . '/' . $site_directory, FILE_EXIST | FILE_READABLE | FILE_WRITABLE | FILE_EXECUTABLE, 'dir')) {
|
||||
$requirements['simpletest_site_directory'] = array(
|
||||
'title' => t('Simpletest site directory'),
|
||||
'value' => is_dir(\Drupal::root() . '/' . $site_directory) ? t('Not writable') : t('Missing'),
|
||||
|
|
|
@ -519,7 +519,7 @@ EOD;
|
|||
|
||||
// Write directly to active storage to avoid early instantiation of
|
||||
// the event dispatcher which can prevent modules from registering events.
|
||||
$active_storage = \Drupal::service('config.storage');
|
||||
$active_storage = \Drupal::service('config.storage');
|
||||
$extensions = $active_storage->read('core.extension');
|
||||
|
||||
foreach ($modules as $module) {
|
||||
|
|
|
@ -2,125 +2,16 @@
|
|||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Drupal\Component\Utility\Random;
|
||||
use Drupal\Tests\RandomGeneratorTrait as BaseGeneratorTrait;
|
||||
|
||||
/**
|
||||
* Provides random generator utility methods.
|
||||
*
|
||||
* @deprecated in Drupal 8.1.1, will be removed before Drupal 9.0.0.
|
||||
* The trait was moved to another namespace.
|
||||
*
|
||||
* @see \Drupal\Tests
|
||||
*/
|
||||
trait RandomGeneratorTrait {
|
||||
|
||||
/**
|
||||
* The random generator.
|
||||
*
|
||||
* @var \Drupal\Component\Utility\Random
|
||||
*/
|
||||
protected $randomGenerator;
|
||||
|
||||
/**
|
||||
* Generates a pseudo-random string of ASCII characters of codes 32 to 126.
|
||||
*
|
||||
* Do not use this method when special characters are not possible (e.g., in
|
||||
* machine or file names that have already been validated); instead, use
|
||||
* \Drupal\simpletest\TestBase::randomMachineName(). If $length is greater
|
||||
* than 3 the random string will include at least one ampersand ('&') and
|
||||
* at least one greater than ('>') character to ensure coverage for special
|
||||
* characters and avoid the introduction of random test failures.
|
||||
*
|
||||
* @param int $length
|
||||
* Length of random string to generate.
|
||||
*
|
||||
* @return string
|
||||
* Pseudo-randomly generated unique string including special characters.
|
||||
*
|
||||
* @see \Drupal\Component\Utility\Random::string()
|
||||
*/
|
||||
public function randomString($length = 8) {
|
||||
if ($length < 4) {
|
||||
return $this->getRandomGenerator()->string($length, TRUE, array($this, 'randomStringValidate'));
|
||||
}
|
||||
|
||||
// To prevent the introduction of random test failures, ensure that the
|
||||
// returned string contains a character that needs to be escaped in HTML by
|
||||
// injecting an ampersand into it.
|
||||
$replacement_pos = floor($length / 2);
|
||||
// Remove 2 from the length to account for the ampersand and greater than
|
||||
// characters.
|
||||
$string = $this->getRandomGenerator()->string($length - 2, TRUE, array($this, 'randomStringValidate'));
|
||||
return substr_replace($string, '>&', $replacement_pos, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for random string validation.
|
||||
*
|
||||
* @see \Drupal\Component\Utility\Random::string()
|
||||
*
|
||||
* @param string $string
|
||||
* The random string to validate.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the random string is valid, FALSE if not.
|
||||
*/
|
||||
public function randomStringValidate($string) {
|
||||
// Consecutive spaces causes issues for
|
||||
// \Drupal\simpletest\WebTestBase::assertLink().
|
||||
if (preg_match('/\s{2,}/', $string)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Starting or ending with a space means that length might not be what is
|
||||
// expected.
|
||||
if (preg_match('/^\s|\s$/', $string)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique random string containing letters and numbers.
|
||||
*
|
||||
* Do not use this method when testing unvalidated user input. Instead, use
|
||||
* \Drupal\simpletest\TestBase::randomString().
|
||||
*
|
||||
* @param int $length
|
||||
* Length of random string to generate.
|
||||
*
|
||||
* @return string
|
||||
* Randomly generated unique string.
|
||||
*
|
||||
* @see \Drupal\Component\Utility\Random::name()
|
||||
*/
|
||||
protected function randomMachineName($length = 8) {
|
||||
return $this->getRandomGenerator()->name($length, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a random PHP object.
|
||||
*
|
||||
* @param int $size
|
||||
* The number of random keys to add to the object.
|
||||
*
|
||||
* @return \stdClass
|
||||
* The generated object, with the specified number of random keys. Each key
|
||||
* has a random string value.
|
||||
*
|
||||
* @see \Drupal\Component\Utility\Random::object()
|
||||
*/
|
||||
public function randomObject($size = 4) {
|
||||
return $this->getRandomGenerator()->object($size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the random generator for the utility methods.
|
||||
*
|
||||
* @return \Drupal\Component\Utility\Random
|
||||
* The random generator.
|
||||
*/
|
||||
protected function getRandomGenerator() {
|
||||
if (!is_object($this->randomGenerator)) {
|
||||
$this->randomGenerator = new Random();
|
||||
}
|
||||
return $this->randomGenerator;
|
||||
}
|
||||
|
||||
use BaseGeneratorTrait;
|
||||
}
|
||||
|
|
|
@ -2,39 +2,18 @@
|
|||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Drupal\Tests\SessionTestTrait as BaseSessionTestTrait;
|
||||
|
||||
/**
|
||||
* Provides methods to generate and get session name in tests.
|
||||
*
|
||||
* @deprecated in Drupal 8.1.1 will be removed before 9.0.0.
|
||||
* This was moved to another namespace.
|
||||
*
|
||||
* @see \Drupal\Tests
|
||||
*/
|
||||
trait SessionTestTrait {
|
||||
|
||||
/**
|
||||
* The name of the session cookie.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $sessionName;
|
||||
|
||||
/**
|
||||
* Generates a session cookie name.
|
||||
*
|
||||
* @param string $data
|
||||
* The data to generate session name.
|
||||
*/
|
||||
protected function generateSessionName($data) {
|
||||
$prefix = (Request::createFromGlobals()->isSecure() ? 'SSESS' : 'SESS');
|
||||
$this->sessionName = $prefix . substr(hash('sha256', $data), 0, 32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the session name in use on the child site.
|
||||
*
|
||||
* @return string
|
||||
* The name of the session cookie.
|
||||
*/
|
||||
protected function getSessionName() {
|
||||
return $this->sessionName;
|
||||
}
|
||||
use BaseSessionTestTrait;
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Drupal\Component\Assertion\Handle;
|
||||
use Drupal\Component\Render\MarkupInterface;
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
|
@ -13,6 +14,8 @@ use Drupal\Core\Config\StorageInterface;
|
|||
use Drupal\Core\Site\Settings;
|
||||
use Drupal\Core\StreamWrapper\PublicStream;
|
||||
use Drupal\Core\Utility\Error;
|
||||
use Drupal\Tests\RandomGeneratorTrait;
|
||||
use Drupal\Tests\SessionTestTrait;
|
||||
|
||||
/**
|
||||
* Base class for Drupal tests.
|
||||
|
@ -950,7 +953,7 @@ abstract class TestBase {
|
|||
}
|
||||
|
||||
$message = '<hr />ID #' . $this->verboseId . ' (<a href="' . $this->verboseClassName . '-' . ($this->verboseId - 1) . '-' . $this->testId . '.html">Previous</a> | <a href="' . $this->verboseClassName . '-' . ($this->verboseId + 1) . '-' . $this->testId . '.html">Next</a>)<hr />' . $message;
|
||||
$verbose_filename = $this->verboseClassName . '-' . $this->verboseId . '-' . $this->testId . '.html';
|
||||
$verbose_filename = $this->verboseClassName . '-' . $this->verboseId . '-' . $this->testId . '.html';
|
||||
if (file_put_contents($this->verboseDirectory . '/' . $verbose_filename, $message)) {
|
||||
$url = $this->verboseDirectoryUrl . '/' . $verbose_filename;
|
||||
// Not using \Drupal\Core\Utility\LinkGeneratorInterface::generate()
|
||||
|
@ -1017,7 +1020,7 @@ abstract class TestBase {
|
|||
|
||||
// Force assertion failures to be thrown as AssertionError for PHP 5 & 7
|
||||
// compatibility.
|
||||
\Drupal\Component\Assertion\Handle::register();
|
||||
Handle::register();
|
||||
|
||||
set_error_handler(array($this, 'errorHandler'));
|
||||
// Iterate through all the methods in this class, unless a specific list of
|
||||
|
|
|
@ -20,7 +20,7 @@ class MailCaptureTest extends WebTestBase {
|
|||
$body = $this->randomString(128);
|
||||
$message = array(
|
||||
'id' => 'drupal_mail_test',
|
||||
'headers' => array('Content-type'=> 'text/html'),
|
||||
'headers' => array('Content-type' => 'text/html'),
|
||||
'subject' => $subject,
|
||||
'to' => 'foobar@example.com',
|
||||
'body' => $body,
|
||||
|
@ -47,7 +47,7 @@ class MailCaptureTest extends WebTestBase {
|
|||
for ($index = 0; $index < 5; $index++) {
|
||||
$message = array(
|
||||
'id' => 'drupal_mail_test_' . $index,
|
||||
'headers' => array('Content-type'=> 'text/html'),
|
||||
'headers' => array('Content-type' => 'text/html'),
|
||||
'subject' => $this->randomString(64),
|
||||
'to' => $this->randomMachineName(32) . '@example.com',
|
||||
'body' => $this->randomString(512),
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\simpletest\Tests;
|
||||
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
|
||||
/**
|
||||
* This test should not load since it requires a module that is not found.
|
||||
*
|
||||
* @group simpletest
|
||||
* @dependencies simpletest_missing_module
|
||||
*/
|
||||
class MissingDependentModuleUnitTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* Ensure that this test will not be loaded despite its dependency.
|
||||
*/
|
||||
function testFail() {
|
||||
$this->fail('Running test with missing required module.');
|
||||
}
|
||||
}
|
|
@ -2,66 +2,15 @@
|
|||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Behat\Mink\WebAssert as MinkWebAssert;
|
||||
use Behat\Mink\Element\TraversableElement;
|
||||
use Behat\Mink\Exception\ElementNotFoundException;
|
||||
use Drupal\Tests\WebAssert as BaseWebAssert;
|
||||
|
||||
/**
|
||||
* Defines a class with methods for asserting presence of elements during tests.
|
||||
*
|
||||
* @deprecated in Drupal 8.1.1 will be removed before 9.0.0.
|
||||
* This was moved to another namespace.
|
||||
*
|
||||
* @see \Drupal\Tests
|
||||
*/
|
||||
class WebAssert extends MinkWebAssert {
|
||||
|
||||
/**
|
||||
* Checks that specific button exists on the current page.
|
||||
*
|
||||
* @param string $button
|
||||
* One of id|name|label|value for the button.
|
||||
* @param \Behat\Mink\Element\TraversableElement $container
|
||||
* (optional) The document to check against. Defaults to the current page.
|
||||
*
|
||||
* @return \Behat\Mink\Element\NodeElement
|
||||
* The matching element.
|
||||
*
|
||||
* @throws \Behat\Mink\Exception\ElementNotFoundException
|
||||
* When the element doesn't exist.
|
||||
*/
|
||||
public function buttonExists($button, TraversableElement $container = NULL) {
|
||||
$container = $container ?: $this->session->getPage();
|
||||
$node = $container->findButton($button);
|
||||
|
||||
if ($node === NULL) {
|
||||
throw new ElementNotFoundException($this->session, 'button', 'id|name|label|value', $button);
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that specific select field exists on the current page.
|
||||
*
|
||||
* @param string $select
|
||||
* One of id|name|label|value for the select field.
|
||||
* @param \Behat\Mink\Element\TraversableElement $container
|
||||
* (optional) The document to check against. Defaults to the current page.
|
||||
*
|
||||
* @return \Behat\Mink\Element\NodeElement
|
||||
* The matching element
|
||||
*
|
||||
* @throws \Behat\Mink\Exception\ElementNotFoundException
|
||||
* When the element doesn't exist.
|
||||
*/
|
||||
public function selectExists($select, TraversableElement $container = NULL) {
|
||||
$container = $container ?: $this->session->getPage();
|
||||
$node = $container->find('named', array(
|
||||
'select',
|
||||
$this->session->getSelectorsHandler()->xpathLiteral($select),
|
||||
));
|
||||
|
||||
if ($node === NULL) {
|
||||
throw new ElementNotFoundException($this->session, 'select', 'id|name|label|value', $select);
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
class WebAssert extends BaseWebAssert {
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ use Drupal\Core\Test\AssertMailTrait;
|
|||
use Drupal\Core\Url;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Yaml\Yaml as SymfonyYaml;
|
||||
use Zend\Diactoros\Uri;
|
||||
|
||||
/**
|
||||
|
@ -635,7 +636,7 @@ abstract class WebTestBase extends TestBase {
|
|||
copy($settings_services_file, $directory . '/services.yml');
|
||||
if ($this->strictConfigSchema) {
|
||||
// Add a listener to validate configuration schema on save.
|
||||
$yaml = new \Symfony\Component\Yaml\Yaml();
|
||||
$yaml = new SymfonyYaml();
|
||||
$content = file_get_contents($directory . '/services.yml');
|
||||
$services = $yaml->parse($content);
|
||||
$services['services']['simpletest.config_schema_checker'] = [
|
||||
|
@ -1507,7 +1508,7 @@ abstract class WebTestBase extends TestBase {
|
|||
* $edit = array(...);
|
||||
* $this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
* @endcode
|
||||
* @param $edit
|
||||
* @param $edit
|
||||
* Field data in an associative array. Changes the current input fields
|
||||
* (where possible) to the values indicated.
|
||||
*
|
||||
|
@ -2310,7 +2311,6 @@ abstract class WebTestBase extends TestBase {
|
|||
/**
|
||||
* Follows a link by partial name.
|
||||
*
|
||||
*
|
||||
* If the link is discovered and clicked, the test passes. Fail otherwise.
|
||||
*
|
||||
* @param string|\Drupal\Component\Render\MarkupInterface $label
|
||||
|
|
|
@ -20,4 +20,3 @@ class SimpletestPhpunitRunCommandTestWillDie extends UnitTestCase {
|
|||
$this->assertTrue(TRUE, 'Assertion to ensure test pass');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class SimpletestPhpunitRunCommandTest extends UnitTestCase {
|
|||
include_once __DIR__ .'/../../fixtures/simpletest_phpunit_run_command_test.php';
|
||||
$app_root = __DIR__ . '/../../../../../..';
|
||||
include_once "$app_root/core/modules/simpletest/simpletest.module";
|
||||
$container = new ContainerBuilder;
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('app.root', $app_root);
|
||||
$file_system = $this->prophesize('Drupal\Core\File\FileSystemInterface');
|
||||
$file_system->realpath('public://simpletest')->willReturn(sys_get_temp_dir());
|
||||
|
|
|
@ -25,7 +25,7 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
* @dataProvider infoParserProvider
|
||||
*/
|
||||
public function testTestInfoParser($expected, $classname, $doc_comment = NULL) {
|
||||
$info = \Drupal\simpletest\TestDiscovery::getTestInfo($classname, $doc_comment);
|
||||
$info = TestDiscovery::getTestInfo($classname, $doc_comment);
|
||||
$this->assertEquals($expected, $info);
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ class TestInfoParsingTest extends UnitTestCase {
|
|||
* Bulk delete storages and fields, and clean up afterwards.
|
||||
*/
|
||||
EOT;
|
||||
\Drupal\simpletest\TestDiscovery::getTestInfo($classname, $doc_comment);
|
||||
TestDiscovery::getTestInfo($classname, $doc_comment);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -258,7 +258,7 @@ EOT;
|
|||
* @group field
|
||||
*/
|
||||
EOT;
|
||||
$info = \Drupal\simpletest\TestDiscovery::getTestInfo($classname, $doc_comment);
|
||||
$info = TestDiscovery::getTestInfo($classname, $doc_comment);
|
||||
$this->assertEmpty($info['description']);
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue