Update to Drupal 8.0.1. For more information, see https://www.drupal.org/node/2627402
This commit is contained in:
parent
013aaaf2ff
commit
1a0e9d9fac
153 changed files with 1268 additions and 670 deletions
|
@ -205,7 +205,7 @@ class SafeMarkupTest extends UnitTestCase {
|
|||
restore_error_handler();
|
||||
|
||||
$this->assertEquals(E_USER_ERROR, $this->lastErrorNumber);
|
||||
$this->assertEquals('Invalid placeholder: ~placeholder', $this->lastErrorMessage);
|
||||
$this->assertEquals('Invalid placeholder (~placeholder) in string: Broken placeholder: ~placeholder', $this->lastErrorMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -516,6 +516,12 @@ class XssTest extends UnitTestCase {
|
|||
'Image tag with data attribute',
|
||||
array('img')
|
||||
),
|
||||
array(
|
||||
'<a data-a2a-url="foo"></a>',
|
||||
'<a data-a2a-url="foo"></a>',
|
||||
'Link tag with numeric data attribute',
|
||||
array('a')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -798,7 +798,7 @@ class AccessResultTest extends UnitTestCase {
|
|||
if ($op === 'OR') {
|
||||
$result = $first->orIf($second);
|
||||
}
|
||||
else if ($op === 'AND') {
|
||||
elseif ($op === 'AND') {
|
||||
$result = $first->andIf($second);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -13,6 +13,7 @@ use Drupal\Tests\UnitTestCase;
|
|||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
|
@ -106,6 +107,8 @@ class PathValidatorTest extends UnitTestCase {
|
|||
|
||||
/**
|
||||
* Tests the isValid() method with an invalid external URL.
|
||||
*
|
||||
* @covers ::isValid
|
||||
*/
|
||||
public function testIsValidWithInvalidExternalUrl() {
|
||||
$this->accessAwareRouter->expects($this->never())
|
||||
|
@ -118,6 +121,7 @@ class PathValidatorTest extends UnitTestCase {
|
|||
* Tests the isValid() method with a 'link to any page' permission.
|
||||
*
|
||||
* @covers ::isValid
|
||||
* @covers ::getPathAttributes
|
||||
*/
|
||||
public function testIsValidWithLinkToAnyPageAccount() {
|
||||
$this->account->expects($this->once())
|
||||
|
@ -189,6 +193,7 @@ class PathValidatorTest extends UnitTestCase {
|
|||
* Tests the isValid() method with a user without access to the path.
|
||||
*
|
||||
* @covers ::isValid
|
||||
* @covers ::getPathAttributes
|
||||
*/
|
||||
public function testIsValidWithAccessDenied() {
|
||||
$this->account->expects($this->once())
|
||||
|
@ -208,6 +213,72 @@ class PathValidatorTest extends UnitTestCase {
|
|||
$this->assertFalse($this->pathValidator->isValid('test-path'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::isValid
|
||||
* @covers ::getPathAttributes
|
||||
*/
|
||||
public function testIsValidWithResourceNotFound() {
|
||||
$this->account->expects($this->once())
|
||||
->method('hasPermission')
|
||||
->with('link to any page')
|
||||
->willReturn(FALSE);
|
||||
$this->accessUnawareRouter->expects($this->never())
|
||||
->method('match');
|
||||
$this->accessAwareRouter->expects($this->once())
|
||||
->method('match')
|
||||
->with('/test-path')
|
||||
->willThrowException(new ResourceNotFoundException());
|
||||
$this->pathProcessor->expects($this->once())
|
||||
->method('processInbound')
|
||||
->willReturnArgument(0);
|
||||
|
||||
$this->assertFalse($this->pathValidator->isValid('test-path'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::isValid
|
||||
* @covers ::getPathAttributes
|
||||
*/
|
||||
public function testIsValidWithParamNotConverted() {
|
||||
$this->account->expects($this->once())
|
||||
->method('hasPermission')
|
||||
->with('link to any page')
|
||||
->willReturn(FALSE);
|
||||
$this->accessUnawareRouter->expects($this->never())
|
||||
->method('match');
|
||||
$this->accessAwareRouter->expects($this->once())
|
||||
->method('match')
|
||||
->with('/test-path')
|
||||
->willThrowException(new ParamNotConvertedException());
|
||||
$this->pathProcessor->expects($this->once())
|
||||
->method('processInbound')
|
||||
->willReturnArgument(0);
|
||||
|
||||
$this->assertFalse($this->pathValidator->isValid('test-path'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::isValid
|
||||
* @covers ::getPathAttributes
|
||||
*/
|
||||
public function testIsValidWithMethodNotAllowed() {
|
||||
$this->account->expects($this->once())
|
||||
->method('hasPermission')
|
||||
->with('link to any page')
|
||||
->willReturn(FALSE);
|
||||
$this->accessUnawareRouter->expects($this->never())
|
||||
->method('match');
|
||||
$this->accessAwareRouter->expects($this->once())
|
||||
->method('match')
|
||||
->with('/test-path')
|
||||
->willThrowException(new MethodNotAllowedException([]));
|
||||
$this->pathProcessor->expects($this->once())
|
||||
->method('processInbound')
|
||||
->willReturnArgument(0);
|
||||
|
||||
$this->assertFalse($this->pathValidator->isValid('test-path'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the isValid() method with a not working param converting.
|
||||
*
|
||||
|
@ -256,6 +327,9 @@ class PathValidatorTest extends UnitTestCase {
|
|||
|
||||
/**
|
||||
* Tests the getUrlIfValid() method when there is access.
|
||||
*
|
||||
* @covers ::getUrlIfValid
|
||||
* @covers ::getPathAttributes
|
||||
*/
|
||||
public function testGetUrlIfValidWithAccess() {
|
||||
$this->account->expects($this->exactly(2))
|
||||
|
@ -287,6 +361,8 @@ class PathValidatorTest extends UnitTestCase {
|
|||
|
||||
/**
|
||||
* Tests the getUrlIfValid() method with a query in the path.
|
||||
*
|
||||
* @covers ::getUrlIfValid
|
||||
*/
|
||||
public function testGetUrlIfValidWithQuery() {
|
||||
$this->account->expects($this->once())
|
||||
|
@ -311,6 +387,8 @@ class PathValidatorTest extends UnitTestCase {
|
|||
|
||||
/**
|
||||
* Tests the getUrlIfValid() method where there is no access.
|
||||
*
|
||||
* @covers ::getUrlIfValid
|
||||
*/
|
||||
public function testGetUrlIfValidWithoutAccess() {
|
||||
$this->account->expects($this->once())
|
||||
|
@ -333,6 +411,8 @@ class PathValidatorTest extends UnitTestCase {
|
|||
|
||||
/**
|
||||
* Tests the getUrlIfValid() method with a front page + query + fragments.
|
||||
*
|
||||
* @covers ::getUrlIfValid
|
||||
*/
|
||||
public function testGetUrlIfValidWithFrontPageAndQueryAndFragments() {
|
||||
$url = $this->pathValidator->getUrlIfValid('<front>?hei=sen#berg');
|
||||
|
@ -345,6 +425,7 @@ class PathValidatorTest extends UnitTestCase {
|
|||
* Tests the getUrlIfValidWithoutAccessCheck() method.
|
||||
*
|
||||
* @covers ::getUrlIfValidWithoutAccessCheck
|
||||
* @covers ::getPathAttributes
|
||||
*/
|
||||
public function testGetUrlIfValidWithoutAccessCheck() {
|
||||
$this->account->expects($this->never())
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\Core\PathProcess\PathProcessorFrontTest
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\Core\PathProcessor;
|
||||
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Config\ImmutableConfig;
|
||||
use Drupal\Core\PathProcessor\PathProcessorFront;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Test front page path processing.
|
||||
*
|
||||
* @group PathProcessor
|
||||
* @coversDefaultClass \Drupal\Core\PathProcessor\PathProcessorFront
|
||||
*/
|
||||
class PathProcessorFrontTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Test basic inbound processing functionality.
|
||||
*
|
||||
* @covers ::processInbound
|
||||
* @dataProvider providerProcessInbound
|
||||
*/
|
||||
public function testProcessInbound($path, $expected) {
|
||||
$config_factory = $this->prophesize(ConfigFactoryInterface::class);
|
||||
$config = $this->prophesize(ImmutableConfig::class);
|
||||
$config_factory->get('system.site')
|
||||
->willReturn($config->reveal());
|
||||
$config->get('page.front')
|
||||
->willReturn('/node');
|
||||
$processor = new PathProcessorFront($config_factory->reveal());
|
||||
$this->assertEquals($expected, $processor->processInbound($path, new Request()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Inbound paths and expected results.
|
||||
*/
|
||||
public function providerProcessInbound() {
|
||||
return [
|
||||
['/', '/node'],
|
||||
['/user', '/user'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test inbound failure with broken config.
|
||||
*
|
||||
* @covers ::processInbound
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public function testProcessInboundBadConfig() {
|
||||
$config_factory = $this->prophesize(ConfigFactoryInterface::class);
|
||||
$config = $this->prophesize(ImmutableConfig::class);
|
||||
$config_factory->get('system.site')
|
||||
->willReturn($config->reveal());
|
||||
$config->get('page.front')
|
||||
->willReturn('');
|
||||
$processor = new PathProcessorFront($config_factory->reveal());
|
||||
$processor->processInbound('/', new Request());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic outbound processing functionality.
|
||||
*
|
||||
* @covers ::processOutbound
|
||||
* @dataProvider providerProcessOutbound
|
||||
*/
|
||||
public function testProcessOutbound($path, $expected) {
|
||||
$config_factory = $this->prophesize(ConfigFactoryInterface::class);
|
||||
$processor = new PathProcessorFront($config_factory->reveal());
|
||||
$this->assertEquals($expected, $processor->processOutbound($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Outbound paths and expected results.
|
||||
*/
|
||||
public function providerProcessOutbound() {
|
||||
return [
|
||||
['/<front>', '/'],
|
||||
['<front>', '<front>'],
|
||||
['/user', '/user'],
|
||||
];
|
||||
}
|
||||
}
|
|
@ -5,11 +5,15 @@
|
|||
* Contains \Drupal\Tests\Core\Render\Element\MachineNameTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\Core\Render\Element;
|
||||
namespace Drupal\Tests\Core\Render\Element {
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\Core\Render\Element\MachineName;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\Core\Render\Element\MachineName
|
||||
|
@ -42,4 +46,74 @@ class MachineNameTest extends UnitTestCase {
|
|||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers ::processMachineName
|
||||
*/
|
||||
public function testProcessMachineName() {
|
||||
$form_state = new FormState();
|
||||
|
||||
$element = [
|
||||
'#id' => 'test',
|
||||
'#field_suffix' => 'test_suffix',
|
||||
'#field_prefix' => 'test_prefix',
|
||||
'#machine_name' => [
|
||||
'source' => [
|
||||
'test_source',
|
||||
],
|
||||
'maxlength' => 32,
|
||||
'additional_property' => TRUE,
|
||||
'#additional_property_with_hash' => TRUE,
|
||||
]
|
||||
];
|
||||
|
||||
$complete_form = [
|
||||
'test_source' => [
|
||||
'#type' => 'textfield',
|
||||
'#id' => 'source',
|
||||
],
|
||||
'test_machine_name' => $element
|
||||
];
|
||||
|
||||
$form_state->setCompleteForm($complete_form);
|
||||
|
||||
$language = $this->prophesize(LanguageInterface::class);
|
||||
$language->getId()->willReturn('xx-lolspeak');
|
||||
|
||||
$language_manager = $this->prophesize(LanguageManagerInterface::class);
|
||||
$language_manager->getCurrentLanguage()->willReturn($language);
|
||||
|
||||
$container = $this->prophesize(ContainerInterface::class);
|
||||
$container->get('language_manager')->willReturn($language_manager->reveal());
|
||||
\Drupal::setContainer($container->reveal());
|
||||
|
||||
$element = MachineName::processMachineName($element, $form_state, $complete_form);
|
||||
$settings = $element['#attached']['drupalSettings']['machineName']['#source'];
|
||||
|
||||
$allowed_options = [
|
||||
'replace_pattern',
|
||||
'replace',
|
||||
'maxlength',
|
||||
'target',
|
||||
'label',
|
||||
'field_prefix',
|
||||
'field_suffix',
|
||||
'suffix'
|
||||
];
|
||||
$this->assertEmpty(array_diff_key($settings, array_flip($allowed_options)));
|
||||
foreach ($allowed_options as $key) {
|
||||
$this->assertArrayHasKey($key, $settings);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
if (!function_exists('t')) {
|
||||
function t($string, array $args = []) {
|
||||
return strtr($string, $args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue