Update to Drupal 8.1.2. For more information, see https://www.drupal.org/project/drupal/releases/8.1.2

This commit is contained in:
Pantheon Automation 2016-06-02 15:56:09 -07:00 committed by Greg Anderson
parent 9eae24d844
commit 28556d630e
1322 changed files with 6699 additions and 2064 deletions

View file

@ -10,6 +10,7 @@ use Drupal\Core\Database\Database;
use Drupal\Core\Render\Element;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\simpletest\TestBase;
use Drupal\Core\Test\TestDatabase;
use Drupal\simpletest\TestDiscovery;
use Symfony\Component\Process\PhpExecutableFinder;
@ -212,7 +213,7 @@ function simpletest_process_phpunit_results($phpunit_results) {
// Insert the results of the PHPUnit test run into the database so the results
// are displayed along with Simpletest's results.
if (!empty($phpunit_results)) {
$query = TestBase::getDatabaseConnection()
$query = TestDatabase::getConnection()
->insert('simpletest')
->fields(array_keys($phpunit_results[0]));
foreach ($phpunit_results as $result) {
@ -428,12 +429,12 @@ function _simpletest_batch_finished($success, $results, $operations, $elapsed) {
* that ran.
*/
function simpletest_last_test_get($test_id) {
$last_prefix = TestBase::getDatabaseConnection()
$last_prefix = TestDatabase::getConnection()
->queryRange('SELECT last_prefix FROM {simpletest_test_id} WHERE test_id = :test_id', 0, 1, array(
':test_id' => $test_id,
))
->fetchField();
$last_test_class = TestBase::getDatabaseConnection()
$last_test_class = TestDatabase::getConnection()
->queryRange('SELECT test_class FROM {simpletest} WHERE test_id = :test_id ORDER BY message_id DESC', 0, 1, array(
':test_id' => $test_id,
))
@ -643,7 +644,7 @@ function simpletest_clean_temporary_directories() {
*/
function simpletest_clean_results_table($test_id = NULL) {
if (\Drupal::config('simpletest.settings')->get('clear_results')) {
$connection = TestBase::getDatabaseConnection();
$connection = TestDatabase::getConnection();
if ($test_id) {
$count = $connection->query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', array(':test_id' => $test_id))->fetchField();

View file

@ -7,7 +7,7 @@ use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Render\RenderContext;
use Symfony\Component\CssSelector\CssSelector;
use Symfony\Component\CssSelector\CssSelectorConverter;
/**
* Provides test methods to assert content.
@ -247,7 +247,7 @@ trait AssertContentTrait {
* selector to an XPath selector.
*/
protected function cssSelect($selector) {
return $this->xpath(CssSelector::toXPath($selector));
return $this->xpath((new CssSelectorConverter())->toXPath($selector));
}
/**

View file

@ -39,7 +39,6 @@ trait ContentTypeCreationTrait {
$type = NodeType::create($values);
$status = $type->save();
node_add_body_field($type);
\Drupal::service('router.builder')->rebuild();
if ($this instanceof \PHPUnit_Framework_TestCase) {
$this->assertSame($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', array('%type' => $type->id())))->__toString());

View file

@ -93,9 +93,10 @@ abstract class InstallerTestBase extends WebTestBase {
// @see WebTestBase::translatePostValues()
$this->parameters = $this->installParameters();
// Set up a minimal container (required by WebTestBase).
// Set up a minimal container (required by WebTestBase). Set cookie and
// server information so that XDebug works.
// @see install_begin_request()
$request = Request::create($GLOBALS['base_url'] . '/core/install.php');
$request = Request::create($GLOBALS['base_url'] . '/core/install.php', 'GET', [], $_COOKIE, [], $_SERVER);
$this->container = new ContainerBuilder();
$request_stack = new RequestStack();
$request_stack->push($request);

View file

@ -497,7 +497,7 @@ EOD;
* To install test modules outside of the testing environment, add
* @code
* $settings['extension_discovery_scan_tests'] = TRUE;
* @encode
* @endcode
* to your settings.php.
*
* @param array $modules

View file

@ -14,4 +14,5 @@ use Drupal\Tests\RandomGeneratorTrait as BaseGeneratorTrait;
*/
trait RandomGeneratorTrait {
use BaseGeneratorTrait;
}

View file

@ -9,10 +9,10 @@ use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Database\Database;
use Drupal\Core\Config\ConfigImporter;
use Drupal\Core\Config\StorageComparer;
use Drupal\Core\Database\ConnectionNotDefinedException;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Site\Settings;
use Drupal\Core\StreamWrapper\PublicStream;
use Drupal\Core\Test\TestDatabase;
use Drupal\Core\Utility\Error;
use Drupal\Tests\RandomGeneratorTrait;
use Drupal\Tests\SessionTestTrait;
@ -510,26 +510,7 @@ abstract class TestBase {
* The database connection to use for inserting assertions.
*/
public static function getDatabaseConnection() {
// Check whether there is a test runner connection.
// @see run-tests.sh
// @todo Convert Simpletest UI runner to create + use this connection, too.
try {
$connection = Database::getConnection('default', 'test-runner');
}
catch (ConnectionNotDefinedException $e) {
// Check whether there is a backup of the original default connection.
// @see TestBase::prepareEnvironment()
try {
$connection = Database::getConnection('default', 'simpletest_original_default');
}
catch (ConnectionNotDefinedException $e) {
// If TestBase::prepareEnvironment() or TestBase::restoreEnvironment()
// failed, the test-specific database connection does not exist
// yet/anymore, so fall back to the default of the (UI) test runner.
$connection = Database::getConnection('default', 'default');
}
}
return $connection;
return TestDatabase::getConnection();
}
/**

View file

@ -116,4 +116,5 @@ class BrokenSetUpTest extends WebTestBase {
$this->pass('The test method has run.');
}
}
}

View file

@ -23,4 +23,5 @@ class FolderTest extends WebTestBase {
$directory = file_default_scheme() . '://styles';
$this->assertTrue(file_prepare_directory($directory, FALSE), 'Directory created.');
}
}

View file

@ -58,4 +58,5 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
$this->drupalPostForm(NULL, $edit, t('Run tests'));
$this->assertText('SystemListingCompatibleTest test executed.');
}
}

View file

@ -74,4 +74,5 @@ class MailCaptureTest extends WebTestBase {
$captured_emails = $this->drupalGetMails(array('id' => 'drupal_mail_test_4'));
$this->assertEqual(count($captured_emails), 2, 'All emails with the same id are returned when filtering by id.', 'Email');
}
}

View file

@ -53,4 +53,5 @@ class MissingCheckedRequirementsTest extends WebTestBase {
$this->fail('Test ran when it failed requirements check.');
}
}
}

View file

@ -0,0 +1,22 @@
<?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.');
}
}

View file

@ -86,8 +86,8 @@ class SimpleTestBrowserTest extends WebTestBase {
$this->drupalLogout();
$system_path = $base_url . '/' . drupal_get_path('module', 'system');
$HTTP_path = $system_path .'/tests/http.php/user/login';
$https_path = $system_path .'/tests/https.php/user/login';
$HTTP_path = $system_path . '/tests/http.php/user/login';
$https_path = $system_path . '/tests/https.php/user/login';
// Generate a valid simpletest User-Agent to pass validation.
$this->assertTrue(preg_match('/simpletest\d+/', $this->databasePrefix, $matches), 'Database prefix contains simpletest prefix.');
$test_ua = drupal_generate_test_ua($matches[0]);

View file

@ -78,7 +78,7 @@ if (!function_exists('simpletest_test_stub_settings_function')) {
}
EOD;
file_put_contents($this->siteDirectory. '/' . 'settings.testing.php', $php);
file_put_contents($this->siteDirectory . '/' . 'settings.testing.php', $php);
// @see \Drupal\system\Tests\DrupalKernel\DrupalKernelSiteTest
$class = __CLASS__;
$yaml = <<<EOD
@ -284,11 +284,16 @@ EOD;
/**
* Asserts that an assertion with specified values is displayed in results.
*
* @param string $message Assertion message.
* @param string $type Assertion type.
* @param string $status Assertion status.
* @param string $file File where the assertion originated.
* @param string $function Function where the assertion originated.
* @param string $message
* Assertion message.
* @param string $type
* Assertion type.
* @param string $status
* Assertion status.
* @param string $file
* File where the assertion originated.
* @param string $function
* Function where the assertion originated.
*
* @return Assertion result.
*/

View file

@ -625,7 +625,7 @@ abstract class WebTestBase extends TestBase {
copy($settings_testing_file, $directory . '/settings.testing.php');
// Add the name of the testing class to settings.php and include the
// testing specific overrides
file_put_contents($directory . '/settings.php', "\n\$test_class = '" . get_class($this) ."';\n" . 'include DRUPAL_ROOT . \'/\' . $site_path . \'/settings.testing.php\';' ."\n", FILE_APPEND);
file_put_contents($directory . '/settings.php', "\n\$test_class = '" . get_class($this) . "';\n" . 'include DRUPAL_ROOT . \'/\' . $site_path . \'/settings.testing.php\';' . "\n", FILE_APPEND);
}
$settings_services_file = DRUPAL_ROOT . '/' . $this->originalSite . '/testing.services.yml';
if (!file_exists($settings_services_file)) {
@ -876,7 +876,7 @@ abstract class WebTestBase extends TestBase {
* To install test modules outside of the testing environment, add
* @code
* $settings['extension_discovery_scan_tests'] = TRUE;
* @encode
* @endcode
* to your settings.php.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
@ -1302,7 +1302,7 @@ abstract class WebTestBase extends TestBase {
* @param $header
* An header.
*
* @see _drupal_log_error().
* @see _drupal_log_error()
*/
protected function curlHeaderCallback($curlHandler, $header) {
// Header fields can be extended over multiple lines by preceding each
@ -2539,7 +2539,7 @@ abstract class WebTestBase extends TestBase {
* TRUE on pass, FALSE on fail.
*/
protected function assertUrl($path, array $options = array(), $message = '', $group = 'Other') {
if ($path instanceof Url) {
if ($path instanceof Url) {
$url_obj = $path;
}
elseif (UrlHelper::isExternal($path)) {
@ -2631,7 +2631,7 @@ abstract class WebTestBase extends TestBase {
* @param $override_server_vars
* An array of server variables to override.
*
* @return $request
* @return \Symfony\Component\HttpFoundation\Request
* The mocked request object.
*/
protected function prepareRequestForGenerator($clean_urls = TRUE, $override_server_vars = array()) {

View file

@ -19,4 +19,5 @@ class SimpletestPhpunitRunCommandTestWillDie extends UnitTestCase {
}
$this->assertTrue(TRUE, 'Assertion to ensure test pass');
}
}

View file

@ -2,6 +2,7 @@
namespace Drupal\Tests\simpletest\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
/**
@ -31,6 +32,14 @@ class BrowserTestBaseTest extends BrowserTestBase {
// Test page contains some text.
$this->assertSession()->pageTextContains('Test page text.');
// Test drupalGet with a url object.
$url = Url::fromRoute('test_page_test.render_title');
$this->drupalGet($url);
$this->assertSession()->statusCodeEquals(200);
// Test page contains some text.
$this->assertSession()->pageTextContains('Hello Drupal');
}
/**

View file

@ -36,6 +36,7 @@ class AssertHelperTraitTest extends UnitTestCase {
[['test safe string', 'mixed array', 'test safe string'], [$safe_string, 'mixed array', $safe_string]],
];
}
}
class AssertHelperTestClass {
@ -44,4 +45,5 @@ class AssertHelperTestClass {
public function testMethod($value) {
return $this->castSafeStrings($value);
}
}

View file

@ -36,4 +36,5 @@ class PhpUnitErrorTest extends UnitTestCase {
// didn't run.
simpletest_phpunit_xml_to_rows(1, 'foobar');
}
}

View file

@ -16,7 +16,7 @@ use Drupal\Tests\UnitTestCase;
class SimpletestPhpunitRunCommandTest extends UnitTestCase {
function testSimpletestPhpUnitRunCommand() {
include_once __DIR__ .'/../../fixtures/simpletest_phpunit_run_command_test.php';
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();