Update to Drupal 8.2.6. For more information, see https://www.drupal.org/project/drupal/releases/8.2.6
This commit is contained in:
parent
db56c09587
commit
f1e72395cb
588 changed files with 26857 additions and 2777 deletions
|
|
@ -119,7 +119,11 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
/**
|
||||
* The temp file directory for the test environment.
|
||||
*
|
||||
* This is set in BrowserTestBase::prepareEnvironment().
|
||||
* This is set in BrowserTestBase::prepareEnvironment(). This value has to
|
||||
* match the temporary directory created in install_base_system() for test
|
||||
* installs.
|
||||
*
|
||||
* @see install_base_system()
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -351,7 +355,11 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
$driver = $this->getDefaultDriverInstance();
|
||||
|
||||
if ($driver instanceof GoutteDriver) {
|
||||
$driver->getClient()->setClient(\Drupal::httpClient());
|
||||
// Turn off curl timeout. Having a timeout is not a problem in a normal
|
||||
// test running, but it is a problem when debugging.
|
||||
/** @var \GuzzleHttp\Client $client */
|
||||
$client = $this->container->get('http_client_factory')->fromOptions(['timeout' => NULL]);
|
||||
$driver->getClient()->setClient($client);
|
||||
}
|
||||
|
||||
$session = new Session($driver);
|
||||
|
|
@ -1015,9 +1023,13 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
$directory = DRUPAL_ROOT . '/' . $this->siteDirectory;
|
||||
copy(DRUPAL_ROOT . '/sites/default/default.settings.php', $directory . '/settings.php');
|
||||
|
||||
// All file system paths are created by System module during installation.
|
||||
// The public file system path is created during installation. Additionally,
|
||||
// during tests:
|
||||
// - The temporary directory is set and created by install_base_system().
|
||||
// - The private file directory is created post install by this method.
|
||||
// @see system_requirements()
|
||||
// @see TestBase::prepareEnvironment()
|
||||
// @see install_base_system()
|
||||
$settings['settings']['file_public_path'] = (object) array(
|
||||
'value' => $this->publicFilesDirectory,
|
||||
'required' => TRUE,
|
||||
|
|
@ -1092,16 +1104,8 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
$config = $container->get('config.factory');
|
||||
|
||||
// Manually create and configure private and temporary files directories.
|
||||
// Manually create the private directory.
|
||||
file_prepare_directory($this->privateFilesDirectory, FILE_CREATE_DIRECTORY);
|
||||
file_prepare_directory($this->tempFilesDirectory, FILE_CREATE_DIRECTORY);
|
||||
// While the temporary files path could be preset/enforced in settings.php
|
||||
// like the public files directory above, some tests expect it to be
|
||||
// configurable in the UI. If declared in settings.php, it would no longer
|
||||
// be configurable.
|
||||
$config->getEditable('system.file')
|
||||
->set('path.temporary', $this->tempFilesDirectory)
|
||||
->save();
|
||||
|
||||
// Manually configure the test mail collector implementation to prevent
|
||||
// tests from sending out emails and collect them in state instead.
|
||||
|
|
|
|||
|
|
@ -74,19 +74,18 @@ class ComposerIntegrationTest extends UnitTestCase {
|
|||
public function testComposerJson() {
|
||||
foreach ($this->getPaths() as $path) {
|
||||
$json = file_get_contents($path . '/composer.json');
|
||||
|
||||
$result = json_decode($json);
|
||||
$this->assertNotNull($result, $this->getErrorMessages()[json_last_error()]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests composer.lock hash.
|
||||
* Tests composer.lock content-hash.
|
||||
*/
|
||||
public function testComposerLockHash() {
|
||||
$json = file_get_contents($this->root . '/composer.json');
|
||||
$content_hash = self::getContentHash(file_get_contents($this->root . '/composer.json'));
|
||||
$lock = json_decode(file_get_contents($this->root . '/composer.lock'), TRUE);
|
||||
$this->assertSame(md5($json), $lock['hash']);
|
||||
$this->assertSame($content_hash, $lock['content-hash']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -126,4 +125,50 @@ class ComposerIntegrationTest extends UnitTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* The following method is copied from \Composer\Package\Locker.
|
||||
*
|
||||
* @see https://github.com/composer/composer
|
||||
*/
|
||||
/**
|
||||
* Returns the md5 hash of the sorted content of the composer file.
|
||||
*
|
||||
* @param string $composerFileContents The contents of the composer file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getContentHash($composerFileContents)
|
||||
{
|
||||
$content = json_decode($composerFileContents, true);
|
||||
|
||||
$relevantKeys = array(
|
||||
'name',
|
||||
'version',
|
||||
'require',
|
||||
'require-dev',
|
||||
'conflict',
|
||||
'replace',
|
||||
'provide',
|
||||
'minimum-stability',
|
||||
'prefer-stable',
|
||||
'repositories',
|
||||
'extra',
|
||||
);
|
||||
|
||||
$relevantContent = array();
|
||||
|
||||
foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
|
||||
$relevantContent[$key] = $content[$key];
|
||||
}
|
||||
if (isset($content['config']['platform'])) {
|
||||
$relevantContent['config']['platform'] = $content['config']['platform'];
|
||||
}
|
||||
|
||||
ksort($relevantContent);
|
||||
|
||||
return md5(json_encode($relevantContent));
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace Drupal\Tests\Core\DrupalKernel {
|
|||
use Drupal\Core\DrupalKernel;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use Symfony\Component\ClassLoader\ApcClassLoader;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
|
|
@ -47,6 +48,63 @@ namespace Drupal\Tests\Core\DrupalKernel {
|
|||
Request::setFactory(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the reregistration of autoloaders if APCu available.
|
||||
*
|
||||
* This test runs in a separate process since it registers class loaders and
|
||||
* results in statics being set.
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @requires function apcu_fetch
|
||||
* @covers ::initializeSettings
|
||||
*/
|
||||
public function testInitializeSettings() {
|
||||
$request = new Request();
|
||||
$classloader = new fakeAutoloader();
|
||||
|
||||
// Create a kernel suitable for testing.
|
||||
$kernel = $this->getMockBuilder(DrupalKernel::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['do_not_mock_any_methods'])
|
||||
->getMock();
|
||||
$classloader_property = new \ReflectionProperty($kernel, 'classLoader');
|
||||
$classloader_property->setAccessible(TRUE);
|
||||
$classloader_property->setValue($kernel, $classloader);
|
||||
$method = new \ReflectionMethod($kernel, 'initializeSettings');
|
||||
$method->setAccessible(TRUE);
|
||||
|
||||
// Prepend another autoloader to simulate Drush's autoloader.
|
||||
$fake_drush_autoloader = function () {
|
||||
return NULL;
|
||||
};
|
||||
spl_autoload_register($fake_drush_autoloader, TRUE, TRUE);
|
||||
|
||||
// Before calling DrupalKernel::initializeSettings() the first autoloader
|
||||
// is the fake Drush autoloader.
|
||||
$this->assertSame($fake_drush_autoloader, spl_autoload_functions()[0]);
|
||||
|
||||
// Call DrupalKernel::initializeSettings() to simulate part of a Drupal
|
||||
// bootstrap. During the include of autoload.php Composer would prepend
|
||||
// Drupal's autoloader and then this method should not result in Drush's
|
||||
// autoloader becoming the first autoloader even if it swaps out
|
||||
// Composer's autoloader for an optimised one.
|
||||
$method->invoke($kernel, $request);
|
||||
|
||||
$autoloaders = spl_autoload_functions();
|
||||
// The first autoloader should be the APCu based autoloader.
|
||||
$this->assertInstanceOf(ApcClassLoader::class, $autoloaders[0][0]);
|
||||
// The second autoloader should be the original autoloader the kernel was
|
||||
// constructed with.
|
||||
$this->assertSame($classloader, $autoloaders[1][0]);
|
||||
// The third autoloader should be Drush's autoloader.
|
||||
$this->assertSame($fake_drush_autoloader, $autoloaders[2]);
|
||||
|
||||
// Reset the request factory because it is statically stored on the
|
||||
// request.
|
||||
Request::setFactory(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides test data for testTrustedHosts().
|
||||
*/
|
||||
|
|
@ -136,6 +194,49 @@ EOD;
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* A fake autoloader for testing
|
||||
*/
|
||||
class fakeAutoloader {
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend
|
||||
* Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = FALSE) {
|
||||
spl_autoload_register(array($this, 'loadClass'), TRUE, $prepend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister() {
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @return null
|
||||
* This class never loads.
|
||||
*/
|
||||
public function loadClass() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a file by class name while caching lookups to APC.
|
||||
*
|
||||
* @return null
|
||||
* This class never finds.
|
||||
*/
|
||||
public function findFile() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\EventSubscriber\RssResponseRelativeUrlFilter;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\Core\EventSubscriber\RssResponseRelativeUrlFilter
|
||||
* @group event_subscriber
|
||||
*/
|
||||
class RssResponseRelativeUrlFilterTest extends UnitTestCase {
|
||||
|
||||
public function providerTestOnResponse() {
|
||||
$data = [];
|
||||
|
||||
$valid_feed = <<<RSS
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0" xml:base="https://www.drupal.org">
|
||||
<channel>
|
||||
<title>Drupal.org</title>
|
||||
<link>https://www.drupal.org</link>
|
||||
<description>Come for the software, stay for the community
|
||||
D rupal is an open source content management platform powering millions of websites and applications. It’s built, used, and supported by an active and diverse community of people around the world.</description>
|
||||
<language>en</language>
|
||||
<item>
|
||||
<title>Drupal 8 turns one!</title>
|
||||
<link>https://www.drupal.org/blog/drupal-8-turns-one</link>
|
||||
<description><a href="localhost/node/1">Hello</a>
|
||||
</description>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
RSS;
|
||||
|
||||
$valid_expected_feed = <<<RSS
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0" xml:base="https://www.drupal.org">
|
||||
<channel>
|
||||
<title>Drupal.org</title>
|
||||
<link>https://www.drupal.org</link>
|
||||
<description>Come for the software, stay for the community
|
||||
D rupal is an open source content management platform powering millions of websites and applications. It’s built, used, and supported by an active and diverse community of people around the world.</description>
|
||||
<language>en</language>
|
||||
<item>
|
||||
<title>Drupal 8 turns one!</title>
|
||||
<link>https://www.drupal.org/blog/drupal-8-turns-one</link>
|
||||
<description><a href="localhost/node/1">Hello</a>
|
||||
</description>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
|
||||
RSS;
|
||||
|
||||
$data['valid-feed'] = [$valid_feed, $valid_expected_feed];
|
||||
|
||||
$invalid_feed = <<<RSS
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rss version="2.0" xml:base="https://www.drupal.org" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<channel>
|
||||
<title>Drupal.org</title>
|
||||
<link>https://www.drupal.org</link>
|
||||
<description>Come for the software, stay for the community
|
||||
D rupal is an open source content management platform powering millions of websites and applications. It’s built, used, and supported by an active and diverse community of people around the world.</description>
|
||||
<language>en</language>
|
||||
<item>
|
||||
<title>Drupal 8 turns one!</title>
|
||||
<link>https://www.drupal.org/blog/drupal-8-turns-one</link>
|
||||
<description>
|
||||
<![CDATA[
|
||||
<a href="localhost/node/1">Hello</a>
|
||||
<script>
|
||||
<!--//--><![CDATA[// ><!--
|
||||
|
||||
<!--//--><![CDATA[// ><!--
|
||||
|
||||
<!--//--><![CDATA[// ><!--
|
||||
(function(d, s, id) {
|
||||
var js, fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) return;
|
||||
js = d.createElement(s); js.id = id;
|
||||
js.src = "//connect.facebook.net/de_DE/sdk.js#xfbml=1&version=v2.3";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
}(document, 'script', 'facebook-jssdk'));
|
||||
//--><!]]]]]]><![CDATA[><![CDATA[>
|
||||
|
||||
//--><!]]]]><![CDATA[>
|
||||
|
||||
//--><!]]>
|
||||
</script>
|
||||
]]>
|
||||
</description>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
RSS;
|
||||
|
||||
|
||||
$data['invalid-feed'] = [$invalid_feed, $invalid_feed];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerTestOnResponse
|
||||
*
|
||||
* @param string $content
|
||||
* @param string $expected_content
|
||||
*/
|
||||
public function testOnResponse($content, $expected_content) {
|
||||
$event = new FilterResponseEvent(
|
||||
$this->prophesize(HttpKernelInterface::class)->reveal(),
|
||||
Request::create('/'),
|
||||
'foo',
|
||||
new Response($content, 200, [
|
||||
'Content-Type' => 'application/rss+xml'
|
||||
])
|
||||
);
|
||||
|
||||
$url_filter = new RssResponseRelativeUrlFilter();
|
||||
$url_filter->onResponse($event);
|
||||
|
||||
$this->assertEquals($expected_content, $event->getResponse()->getContent());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\Core\StringTranslation;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* Tests the TranslatableMarkup class.
|
||||
*
|
||||
* @coversDefaultClass \Drupal\Core\StringTranslation\PluralTranslatableMarkup
|
||||
* @group StringTranslation
|
||||
*/
|
||||
class PluralTranslatableMarkupTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Tests serialization of PluralTranslatableMarkup().
|
||||
*
|
||||
* @dataProvider providerPluralTranslatableMarkupSerialization
|
||||
*/
|
||||
public function testPluralTranslatableMarkupSerialization($count, $expected_text) {
|
||||
// Add a mock string translation service to the container.
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('string_translation', $this->getStringTranslationStub());
|
||||
\Drupal::setContainer($container);
|
||||
|
||||
// Create an object to serialize and unserialize.
|
||||
$markup = new PluralTranslatableMarkup($count, 'singular @count', 'plural @count');
|
||||
$serialized_markup = unserialize(serialize($markup));
|
||||
$this->assertEquals($expected_text, $serialized_markup->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for ::testPluralTranslatableMarkupSerialization().
|
||||
*/
|
||||
public function providerPluralTranslatableMarkupSerialization() {
|
||||
return [
|
||||
[1, 'singular 1'],
|
||||
[2, 'plural 2'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue