updated core to 8.6.3

This commit is contained in:
2018-11-21 12:49:46 +01:00
parent 8ca34853a3
commit c92c348eee
521 changed files with 12199 additions and 4578 deletions
+8 -9
View File
@@ -124,7 +124,7 @@ abstract class BrowserTestBase extends TestCase {
/*
* Mink class for the default driver to use.
*
* Shoud be a fully qualified class name that implements
* Should be a fully-qualified class name that implements
* Behat\Mink\Driver\DriverInterface.
*
* Value can be overridden using the environment variable MINK_DRIVER_CLASS.
@@ -238,6 +238,12 @@ abstract class BrowserTestBase extends TestCase {
'hidden_field_selector' => new HiddenFieldSelector(),
]);
$session = new Session($driver, $selectors_handler);
$cookies = $this->extractCookiesFromRequest(\Drupal::request());
foreach ($cookies as $cookie_name => $values) {
foreach ($values as $value) {
$session->setCookie($cookie_name, $value);
}
}
$this->mink = new Mink();
$this->mink->registerSession('default', $session);
$this->mink->setDefaultSessionName('default');
@@ -388,14 +394,7 @@ abstract class BrowserTestBase extends TestCase {
$this->installDrupal();
// Setup Mink.
$session = $this->initMink();
$cookies = $this->extractCookiesFromRequest(\Drupal::request());
foreach ($cookies as $cookie_name => $values) {
foreach ($values as $value) {
$session->setCookie($cookie_name, $value);
}
}
$this->initMink();
// Set up the browser test output file.
$this->initBrowserOutputFile();
@@ -807,7 +807,7 @@ class DateTimePlusTest extends TestCase {
public function testValidateFormat() {
// Check that an input that does not strictly follow the input format will
// produce the desired date. In this case the year string '11' doesn't
// precisely match the 'Y' formater parameter, but PHP will parse it
// precisely match the 'Y' formatter parameter, but PHP will parse it
// regardless. However, when formatted with the same string, the year will
// be output with four digits. With the ['validate_format' => FALSE]
// $settings, this will not thrown an exception.
@@ -3,6 +3,8 @@
namespace Drupal\Tests\Component\Plugin;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Plugin\Mapper\MapperInterface;
use Drupal\Component\Plugin\PluginManagerBase;
use PHPUnit\Framework\TestCase;
/**
@@ -90,4 +92,43 @@ class PluginManagerBaseTest extends TestCase {
$this->assertEquals($configuration_array, $fallback_result['configuration']);
}
/**
* @covers ::getInstance
*/
public function testGetInstance() {
$options = [
'foo' => 'F00',
'bar' => 'bAr',
];
$instance = new \stdClass();
$mapper = $this->prophesize(MapperInterface::class);
$mapper->getInstance($options)
->shouldBeCalledTimes(1)
->willReturn($instance);
$manager = new StubPluginManagerBaseWithMapper($mapper->reveal());
$this->assertEquals($instance, $manager->getInstance($options));
}
/**
* @covers ::getInstance
*/
public function testGetInstanceWithoutMapperShouldThrowException() {
$options = [
'foo' => 'F00',
'bar' => 'bAr',
];
/** @var \Drupal\Component\Plugin\PluginManagerBase $manager */
$manager = $this->getMockBuilder(PluginManagerBase::class)
->getMockForAbstractClass();
// Set the expected exception thrown by ::getInstance.
if (method_exists($this, 'expectException')) {
$this->expectException(\BadMethodCallException::class);
$this->expectExceptionMessage(sprintf('%s does not support this method unless %s::$mapper is set.', get_class($manager), get_class($manager)));
}
else {
$this->setExpectedException(\BadMethodCallException::class, sprintf('%s does not support this method unless %s::$mapper is set.', get_class($manager), get_class($manager)));
}
$manager->getInstance($options);
}
}
@@ -0,0 +1,22 @@
<?php
namespace Drupal\Tests\Component\Plugin;
use Drupal\Component\Plugin\Mapper\MapperInterface;
use Drupal\Component\Plugin\PluginManagerBase;
/**
* Stubs \Drupal\Component\Plugin\PluginManagerBase to take a MapperInterface.
*/
final class StubPluginManagerBaseWithMapper extends PluginManagerBase {
/**
* Constructs a new instance.
*
* @param \Drupal\Component\Plugin\Mapper\MapperInterface $mapper
*/
public function __construct(MapperInterface $mapper) {
$this->mapper = $mapper;
}
}
@@ -106,7 +106,7 @@ class PhpTransliterationTest extends TestCase {
// Make some strings with two, three, and four-byte characters for testing.
// Note that the 3-byte character is overridden by the 'kg' language.
$two_byte = 'Ä Ö Ü Å Ø äöüåøhello';
// This is a Cyrrillic character that looks something like a u. See
// This is a Cyrillic character that looks something like a "u". See
// http://www.unicode.org/charts/PDF/U0400.pdf
$three_byte = html_entity_decode('&#x446;', ENT_NOQUOTES, 'UTF-8');
// This is a Canadian Aboriginal character like a triangle. See
@@ -107,7 +107,7 @@ class CssOptimizerUnitTest extends UnitTestCase {
str_replace('url(../images/icon.png)', 'url(' . file_url_transform_relative(file_create_url($path . 'images/icon.png')) . ')', file_get_contents($absolute_path . 'css_subfolder/css_input_with_import.css.optimized.css')),
],
// File. Tests:
// - Any @charaset declaration at the beginning of a file should be
// - Any @charset declaration at the beginning of a file should be
// removed without breaking subsequent CSS.
[
[
@@ -50,7 +50,7 @@ class ValidateHostnameTest extends UnitTestCase {
$data[] = ['72.21.91.99:80', 'Properly formed HTTP_HOST with IPv4 address valid.', TRUE];
$data[] = ['2607:f8b0:4004:803::1002:80', 'Properly formed HTTP_HOST with IPv6 address valid.', TRUE];
// Verfies that the IPv6 loopback address is valid.
// Verifies that the IPv6 loopback address is valid.
$data[] = ['[::1]:80', 'HTTP_HOST containing IPv6 loopback is valid.', TRUE];
return $data;
@@ -383,6 +383,14 @@ class SqlContentEntityStorageTest extends UnitTestCase {
$this->entityType->expects($this->once())
->method('getKeys')
->will($this->returnValue(['id' => 'id']));
$this->entityType->expects($this->any())
->method('hasKey')
->will($this->returnValueMap([
// SqlContentEntityStorageSchema::initializeBaseTable()
['revision', FALSE],
// SqlContentEntityStorageSchema::processBaseTable()
['id', TRUE],
]));
$this->entityType->expects($this->any())
->method('getKey')
->will($this->returnValueMap([
@@ -7,12 +7,10 @@
namespace Drupal\Tests\Core\Extension;
use Drupal\Core\Cache\MemoryBackend;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Extension\InfoParser;
use Drupal\Core\Extension\ThemeHandler;
use Drupal\Core\KeyValueStore\KeyValueMemoryFactory;
use Drupal\Core\Lock\NullLockBackend;
use Drupal\Core\State\State;
use Drupal\Tests\UnitTestCase;
@@ -80,7 +78,7 @@ class ThemeHandlerTest extends UnitTestCase {
],
]);
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->state = new State(new KeyValueMemoryFactory(), new MemoryBackend('test'), new NullLockBackend());
$this->state = new State(new KeyValueMemoryFactory());
$this->infoParser = $this->getMock('Drupal\Core\Extension\InfoParserInterface');
$this->extensionDiscovery = $this->getMockBuilder('Drupal\Core\Extension\ExtensionDiscovery')
->disableOriginalConstructor()
@@ -287,7 +287,7 @@ class FormStateDecoratorBaseTest extends UnitTestCase {
* @dataProvider providerLimitValidationErrors
*
* @param array[]|null $limit_validation_errors
* Any valid vlaue for
* Any valid value for
* \Drupal\Core\Form\FormStateInterface::getLimitValidationErrors()'s
* return value;
*/
@@ -13,7 +13,9 @@ use Drupal\Core\Access\AccessManagerInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Access\AccessResultForbidden;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\Context\CacheContextsManager;
use Drupal\Core\Controller\ControllerResolver;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Menu\LocalActionManager;
@@ -23,6 +25,7 @@ use Drupal\Core\Routing\RouteProviderInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\Tests\UnitTestCase;
use Prophecy\Argument;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
@@ -113,7 +116,15 @@ class LocalActionManagerTest extends UnitTestCase {
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->cacheBackend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
$access_result = new AccessResultForbidden();
$cache_contexts_manager = $this->prophesize(CacheContextsManager::class);
$cache_contexts_manager->assertValidTokens(Argument::any())
->willReturn(TRUE);
$container = new Container();
$container->set('cache_contexts_manager', $cache_contexts_manager->reveal());
\Drupal::setContainer($container);
$access_result = (new AccessResultForbidden())->cachePerPermissions();
$this->accessManager = $this->getMock('Drupal\Core\Access\AccessManagerInterface');
$this->accessManager->expects($this->any())
->method('checkNamedRoute')
@@ -186,6 +197,14 @@ class LocalActionManagerTest extends UnitTestCase {
}
public function getActionsForRouteProvider() {
$cache_contexts_manager = $this->prophesize(CacheContextsManager::class);
$cache_contexts_manager->assertValidTokens(Argument::any())
->willReturn(TRUE);
$container = new Container();
$container->set('cache_contexts_manager', $cache_contexts_manager->reveal());
\Drupal::setContainer($container);
// Single available and single expected plugins.
$data[] = [
'test_route',
@@ -201,7 +220,9 @@ class LocalActionManagerTest extends UnitTestCase {
],
[
'#cache' => [
'contexts' => ['route'],
'tags' => [],
'contexts' => ['route', 'user.permissions'],
'max-age' => 0,
],
'plugin_id_1' => [
'#theme' => 'menu_local_action',
@@ -210,13 +231,8 @@ class LocalActionManagerTest extends UnitTestCase {
'url' => Url::fromRoute('test_route_2'),
'localized_options' => '',
],
'#access' => AccessResult::forbidden(),
'#access' => AccessResult::forbidden()->cachePerPermissions(),
'#weight' => 0,
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => 0,
],
],
],
];
@@ -243,7 +259,9 @@ class LocalActionManagerTest extends UnitTestCase {
],
[
'#cache' => [
'contexts' => ['route'],
'tags' => [],
'contexts' => ['route', 'user.permissions'],
'max-age' => 0,
],
'plugin_id_1' => [
'#theme' => 'menu_local_action',
@@ -252,13 +270,8 @@ class LocalActionManagerTest extends UnitTestCase {
'url' => Url::fromRoute('test_route_2'),
'localized_options' => '',
],
'#access' => AccessResult::forbidden(),
'#access' => AccessResult::forbidden()->cachePerPermissions(),
'#weight' => 0,
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => 0,
],
],
],
];
@@ -286,7 +299,9 @@ class LocalActionManagerTest extends UnitTestCase {
],
[
'#cache' => [
'contexts' => ['route'],
'contexts' => ['route', 'user.permissions'],
'tags' => [],
'max-age' => 0,
],
'plugin_id_1' => [
'#theme' => 'menu_local_action',
@@ -295,13 +310,8 @@ class LocalActionManagerTest extends UnitTestCase {
'url' => Url::fromRoute('test_route_2'),
'localized_options' => '',
],
'#access' => AccessResult::forbidden(),
'#access' => AccessResult::forbidden()->cachePerPermissions(),
'#weight' => 1,
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => 0,
],
],
'plugin_id_2' => [
'#theme' => 'menu_local_action',
@@ -310,13 +320,8 @@ class LocalActionManagerTest extends UnitTestCase {
'url' => Url::fromRoute('test_route_3'),
'localized_options' => '',
],
'#access' => AccessResult::forbidden(),
'#access' => AccessResult::forbidden()->cachePerPermissions(),
'#weight' => 0,
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => 0,
],
],
],
];
@@ -346,7 +351,9 @@ class LocalActionManagerTest extends UnitTestCase {
],
[
'#cache' => [
'contexts' => ['route'],
'contexts' => ['route', 'user.permissions'],
'tags' => [],
'max-age' => 0,
],
'plugin_id_1' => [
'#theme' => 'menu_local_action',
@@ -355,13 +362,8 @@ class LocalActionManagerTest extends UnitTestCase {
'url' => Url::fromRoute('test_route_2', ['test1']),
'localized_options' => '',
],
'#access' => AccessResult::forbidden(),
'#access' => AccessResult::forbidden()->cachePerPermissions(),
'#weight' => 1,
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => 0,
],
],
'plugin_id_2' => [
'#theme' => 'menu_local_action',
@@ -370,13 +372,8 @@ class LocalActionManagerTest extends UnitTestCase {
'url' => Url::fromRoute('test_route_2', ['test2']),
'localized_options' => '',
],
'#access' => AccessResult::forbidden(),
'#access' => AccessResult::forbidden()->cachePerPermissions(),
'#weight' => 0,
'#cache' => [
'contexts' => [],
'tags' => [],
'max-age' => 0,
],
],
],
];
@@ -162,6 +162,28 @@ class LocalTaskDefaultTest extends UnitTestCase {
$this->assertEquals(['parameter' => 'example'], $this->localTaskBase->getRouteParameters($route_match));
}
/**
* Tests the getRouteParameters method for a route with upcasted parameters.
*
* @covers ::getRouteParameters
*/
public function testGetRouteParametersForDynamicRouteWithUpcastedParametersEmptyRawParameters() {
$this->pluginDefinition = [
'route_name' => 'test_route',
];
$route = new Route('/test-route/{parameter}');
$this->routeProvider->expects($this->once())
->method('getRouteByName')
->with('test_route')
->will($this->returnValue($route));
$this->setupLocalTaskDefault();
$route_match = new RouteMatch('', $route, ['parameter' => (object) 'example2']);
$this->assertEquals(['parameter' => (object) 'example2'], $this->localTaskBase->getRouteParameters($route_match));
}
/**
* Defines a data provider for testGetWeight().
*
@@ -1,62 +0,0 @@
<?php
namespace Drupal\Tests\Core\Plugin\Context;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\Core\TypedData\Plugin\DataType\StringData;
use Drupal\Core\TypedData\TypedDataManagerInterface;
use Drupal\Tests\UnitTestCase;
/**
* Tests that contexts work properly with the typed data manager.
*
* @coversDefaultClass \Drupal\Core\Plugin\Context\Context
* @group Context
*/
class ContextTypedDataTest extends UnitTestCase {
/**
* The typed data object used during testing.
*
* @var \Drupal\Core\TypedData\Plugin\DataType\StringData
*/
protected $typedData;
/**
* Tests that getting a context value does not throw fatal errors.
*
* This test ensures that the typed data manager is set correctly on the
* Context class.
*
* @covers ::getContextValue
*/
public function testGetContextValue() {
// Prepare a container that holds the typed data manager mock.
$typed_data_manager = $this->getMock(TypedDataManagerInterface::class);
$typed_data_manager->expects($this->once())
->method('getCanonicalRepresentation')
->will($this->returnCallback([$this, 'getCanonicalRepresentation']));
$container = new ContainerBuilder();
$container->set('typed_data_manager', $typed_data_manager);
\Drupal::setContainer($container);
$definition = new ContextDefinition('any');
$data_definition = DataDefinition::create('string');
$this->typedData = new StringData($data_definition);
$this->typedData->setValue('example string');
$context = new Context($definition, $this->typedData);
$value = $context->getContextValue();
$this->assertSame($value, $this->typedData->getValue());
}
/**
* Helper mock callback to return the typed data value.
*/
public function getCanonicalRepresentation() {
return $this->typedData->getValue();
}
}
@@ -9,7 +9,6 @@ namespace Drupal\Tests\Core\Render;
use Drupal\Core\Cache\MemoryBackend;
use Drupal\Core\KeyValueStore\KeyValueMemoryFactory;
use Drupal\Core\Lock\NullLockBackend;
use Drupal\Core\State\State;
use Drupal\Core\Cache\Cache;
@@ -539,7 +538,7 @@ class RendererBubblingTest extends RendererTestBase {
$this->setupMemoryCache();
// Mock the State service.
$memory_state = new State(new KeyValueMemoryFactory(), new MemoryBackend('test'), new NullLockBackend());
$memory_state = new State(new KeyValueMemoryFactory());
\Drupal::getContainer()->set('state', $memory_state);
$this->controllerResolver->expects($this->any())
->method('getControllerFromDefinition')
@@ -97,8 +97,8 @@ class UnroutedUrlAssemblerTest extends UnitTestCase {
['https://example.com/test', ['https' => FALSE], 'http://example.com/test'],
['https://example.com/test?foo=1#bar', [], 'https://example.com/test?foo=1#bar'],
'override-query' => ['https://example.com/test?foo=1#bar', ['query' => ['foo' => 2]], 'https://example.com/test?foo=2#bar'],
'override-query-merge' => ['https://example.com/test?foo=1#bar', ['query' => ['bar' => 2]], 'https://example.com/test?bar=2&foo=1#bar'],
'override-deep-query-merge' => ['https://example.com/test?foo=1#bar', ['query' => ['bar' => ['baz' => 'foo']]], 'https://example.com/test?bar%5Bbaz%5D=foo&foo=1#bar'],
'override-query-merge' => ['https://example.com/test?foo=1#bar', ['query' => ['bar' => 2]], 'https://example.com/test?foo=1&bar=2#bar'],
'override-deep-query-merge' => ['https://example.com/test?foo=1#bar', ['query' => ['bar' => ['baz' => 'foo']]], 'https://example.com/test?foo=1&bar%5Bbaz%5D=foo#bar'],
'override-fragment' => ['https://example.com/test?foo=1#bar', ['fragment' => 'baz'], 'https://example.com/test?foo=1#baz'],
['//www.drupal.org', [], '//www.drupal.org'],
];
@@ -92,10 +92,18 @@ trait DeprecationListenerTrait {
/**
* A list of deprecations to ignore whilst fixes are put in place.
*
* Do not add any new deprecations to this list. All deprecation errors will
* eventually be removed from this list.
*
* @return string[]
* A list of deprecations to ignore.
*
* @internal
*
* @todo Fix all these deprecations and remove them from this list.
* https://www.drupal.org/project/drupal/issues/2959269
*
* @see https://www.drupal.org/node/2811561
*/
public static function getSkippedDeprecations() {
return [
+1 -1
View File
@@ -371,7 +371,7 @@ trait UiHelperTrait {
* Options to be passed to Url::fromUri().
*
* @return string
* An absolute URL stsring.
* An absolute URL string.
*/
protected function buildUrl($path, array $options = []) {
if ($path instanceof Url) {
+1 -1
View File
@@ -167,7 +167,7 @@ class WebAssert extends MinkWebAssert {
* @param string $select
* One of id|name|label|value for the select field.
* @param string $option
* The option value that shoulkd not exist.
* The option value that should not exist.
* @param \Behat\Mink\Element\TraversableElement $container
* (optional) The document to check against. Defaults to the current page.
*