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:
Pantheon Automation 2017-02-02 16:28:38 -08:00 committed by Greg Anderson
parent db56c09587
commit f1e72395cb
588 changed files with 26857 additions and 2777 deletions

View file

@ -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;
}
}
}

View file

@ -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. Its 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>&lt;a href=&quot;localhost/node/1&quot;&gt;Hello&lt;/a&gt;
</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. Its 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>&lt;a href="localhost/node/1"&gt;Hello&lt;/a&gt;
</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. Its 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[
&lt;a href="localhost/node/1"&gt;Hello&lt;/a&gt;
<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());
}
}

View file

@ -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'],
];
}
}