update drupal

This commit is contained in:
Tessier
2020-10-15 11:59:37 +02:00
parent ebb5db14b5
commit d8b9162932
558 changed files with 5954 additions and 4475 deletions
@@ -1216,7 +1216,7 @@ DOCBLOCK;
$this->assertInstanceOf(Null::class, $result[0]);
}
public function testSetValuesExeption()
public function testSetValuesException()
{
$this->expectException('\Doctrine\Common\Annotations\AnnotationException');
$this->expectExceptionMessage('[Creation Error] The annotation @SomeAnnotationClassNameWithoutConstructor declared on some class does not have a property named "invalidaProperty". Available properties: data, name');
@@ -112,6 +112,23 @@ class DateTimePlusTest extends TestCase {
);
}
/**
* Tests DateTimePlus::checkArray().
*
* @param mixed $array
* Input argument for DateTimePlus::checkArray().
* @param bool $expected
* The expected result of DateTimePlus::checkArray().
*
* @dataProvider providerTestCheckArray
*/
public function testCheckArray(array $array, $expected) {
$this->assertSame(
$expected,
DateTimePlus::checkArray($array)
);
}
/**
* Test creating dates from timestamps, and manipulating timezones.
*
@@ -442,6 +459,30 @@ class DateTimePlusTest extends TestCase {
];
}
/**
* Data provider for testCheckArray.
*
* @return array
* An array of arrays, each containing:
* - 'array' - Input for DateTimePlus::checkArray().
* - 'expected' - Expected output for DateTimePlus::checkArray().
*
* @see testCheckArray
*/
public function providerTestCheckArray() {
return [
'Date array, date only' => [['year' => 2010, 'month' => 2, 'day' => 28], TRUE],
'Date array with hour' => [['year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 10], TRUE],
'One year larger than the documented upper limit of checkdate()' => [['year' => 32768, 'month' => 1, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0], FALSE],
'One year smaller than the documented lower limit of checkdate()' => [['year' => 0, 'month' => 1, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0], FALSE],
'Invalid month from date array' => [['year' => 2010, 'month' => 27, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0], FALSE],
'Invalid hour from date array' => [['year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 80, 'minute' => 0, 'second' => 0], FALSE],
'Invalid minute from date array.' => [['year' => 2010, 'month' => 7, 'day' => 8, 'hour' => 8, 'minute' => 88, 'second' => 0], FALSE],
'Missing day' => [['year' => 2059, 'month' => 1, 'second' => 1], FALSE],
'Zero day' => [['year' => 2059, 'month' => 1, 'day' => 0], FALSE],
];
}
/**
* Provides data for testDateTimezone.
*
@@ -254,7 +254,7 @@ class ContainerTest extends TestCase {
* @covers ::getAlternatives
* @covers ::getServiceAlternatives
*/
public function testGetForNonExistantService() {
public function testGetForNonExistentService() {
$this->expectException(ServiceNotFoundException::class);
$this->container->get('service_not_exists');
}
@@ -286,7 +286,7 @@ class ContainerTest extends TestCase {
* @covers ::createService
* @covers ::resolveServicesAndParameters
*/
public function testGetForNonExistantParameterDependency() {
public function testGetForNonExistentParameterDependency() {
$service = $this->container->get('service_parameter_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE);
$this->assertNull($service, 'Service is NULL.');
}
@@ -315,7 +315,7 @@ class ContainerTest extends TestCase {
* @covers ::createService
* @covers ::resolveServicesAndParameters
*/
public function testGetForNonExistantParameterDependencyWithException() {
public function testGetForNonExistentParameterDependencyWithException() {
$this->expectException(InvalidArgumentException::class);
$this->container->get('service_parameter_not_exists');
}
@@ -327,7 +327,7 @@ class ContainerTest extends TestCase {
* @covers ::createService
* @covers ::resolveServicesAndParameters
*/
public function testGetForNonExistantServiceDependency() {
public function testGetForNonExistentServiceDependency() {
$service = $this->container->get('service_dependency_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE);
$this->assertNull($service, 'Service is NULL.');
}
@@ -340,7 +340,7 @@ class ContainerTest extends TestCase {
* @covers ::resolveServicesAndParameters
* @covers ::getAlternatives
*/
public function testGetForNonExistantServiceDependencyWithException() {
public function testGetForNonExistentServiceDependencyWithException() {
$this->expectException(ServiceNotFoundException::class);
$this->container->get('service_dependency_not_exists');
}
@@ -351,7 +351,7 @@ class ContainerTest extends TestCase {
* @covers ::get
* @covers ::createService
*/
public function testGetForNonExistantServiceWhenUsingNull() {
public function testGetForNonExistentServiceWhenUsingNull() {
$this->assertNull($this->container->get('service_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE), 'Not found service does not throw exception.');
}
@@ -360,7 +360,7 @@ class ContainerTest extends TestCase {
* @covers ::get
* @covers ::createService
*/
public function testGetForNonExistantNULLService() {
public function testGetForNonExistentNULLService() {
$this->expectException(ServiceNotFoundException::class);
$this->container->get(NULL);
}
@@ -371,7 +371,7 @@ class ContainerTest extends TestCase {
* @covers ::get
* @covers ::createService
*/
public function testGetForNonExistantServiceMultipleTimes() {
public function testGetForNonExistentServiceMultipleTimes() {
$container = new $this->containerClass();
$this->assertNull($container->get('service_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE), 'Not found service does not throw exception.');
@@ -385,7 +385,7 @@ class ContainerTest extends TestCase {
* @covers ::createService
* @covers ::getAlternatives
*/
public function testGetForNonExistantServiceWithExceptionOnSecondCall() {
public function testGetForNonExistentServiceWithExceptionOnSecondCall() {
$this->assertNull($this->container->get('service_not_exists', ContainerInterface::NULL_ON_INVALID_REFERENCE), 'Not found service does nto throw exception.');
$this->expectException(ServiceNotFoundException::class);
$this->container->get('service_not_exists');
@@ -62,7 +62,7 @@ class StaticDiscoveryDecoratorTest extends TestCase {
// Mock our StaticDiscoveryDecorator.
$mock_decorator = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\StaticDiscoveryDecorator')
->disableOriginalConstructor()
->setMethods(['registeredDefintionCallback'])
->setMethods(['registeredDefinitionCallback'])
->getMock();
// Set up the ::$registerDefinitions property.
@@ -132,7 +132,7 @@ class StaticDiscoveryDecoratorTest extends TestCase {
// Mock our StaticDiscoveryDecorator.
$mock_decorator = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\StaticDiscoveryDecorator')
->disableOriginalConstructor()
->setMethods(['registeredDefintionCallback'])
->setMethods(['registeredDefinitionCallback'])
->getMock();
// Set up the ::$registerDefinitions property.
@@ -21,9 +21,9 @@ class HtmlEscapedTextTest extends TestCase {
* @dataProvider providerToString
*/
public function testToString($text, $expected, $message) {
$escapeable_string = new HtmlEscapedText($text);
$this->assertEquals($expected, (string) $escapeable_string, $message);
$this->assertEquals($expected, $escapeable_string->jsonSerialize());
$escapable_string = new HtmlEscapedText($text);
$this->assertEquals($expected, (string) $escapable_string, $message);
$this->assertEquals($expected, $escapable_string->jsonSerialize());
}
/**
@@ -57,8 +57,8 @@ class HtmlEscapedTextTest extends TestCase {
*/
public function testCount() {
$string = 'Can I please have a <em>kitten</em>';
$escapeable_string = new HtmlEscapedText($string);
$this->assertEquals(strlen($string), $escapeable_string->count());
$escapable_string = new HtmlEscapedText($string);
$this->assertEquals(strlen($string), $escapable_string->count());
}
}
@@ -58,8 +58,8 @@ class PhpTransliterationTest extends TestCase {
// Test all characters in the Unicode range 0x01CD to 0x024F.
['ǍǎǏ', 'AaI'],
['ǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟ', 'iOoUuUuUuUuUuǝAa'],
['ǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯ', 'AaǢǣGgGgKkOoOoǮǯ'],
['ǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿ', 'jDZDzdzGgǶǷNnAaǼǽOo'],
['ǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯ', 'AaÆæGgGgKkOoOoƷʒ'],
['ǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿ', 'jDZDzdzGgǶǷNnAaÆæOo'],
['ȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏ', 'AaAaEeEeIiIiOoOo'],
['ȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟ', 'RrRrUuUuSsTtȜȝHh'],
['ȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯ', 'ȠȡȢȣZzAaEeOoOoOo'],
@@ -56,6 +56,9 @@ class BytesTest extends TestCase {
['76MRandomStringThatShouldBeIgnoredByParseSize.', 79691776],
// 76.24 GB (with typo).
['76.24 Giggabyte', 81862076662],
['1.5', 2],
['2.4', 2],
['', 0],
];
}
@@ -23,15 +23,13 @@ class UnicodeTest extends TestCase {
}
/**
* Tests multibyte encoding and decoding.
* Tests multibyte encoding.
*
* @dataProvider providerTestMimeHeader
* @covers ::mimeHeaderEncode
* @covers ::mimeHeaderDecode
*/
public function testMimeHeader($value, $encoded) {
public function testMimeHeaderEncode($value, $encoded) {
$this->assertEquals($encoded, Unicode::mimeHeaderEncode($value));
$this->assertEquals($value, Unicode::mimeHeaderDecode($encoded));
}
/**
@@ -44,9 +42,49 @@ class UnicodeTest extends TestCase {
*/
public function providerTestMimeHeader() {
return [
['tést.txt', '=?UTF-8?B?dMOpc3QudHh0?='],
// Simple ASCII characters.
['ASCII', 'ASCII'],
"Base64 encoding" => ['tést.txt', '=?UTF-8?B?dMOpc3QudHh0?='],
"ASCII characters only" => ['test.txt', 'test.txt'],
];
}
/**
* Tests multibyte decoding.
*
* @dataProvider providerTestMimeHeaderDecode
* @covers ::mimeHeaderDecode
*/
public function testMimeHeaderDecode($value, $encoded) {
$this->assertEquals($value, Unicode::mimeHeaderDecode($encoded));
}
/**
* Data provider for testMimeHeaderDecode().
*
* @return array
* An array containing a string and its encoded value.
*/
public function providerTestMimeHeaderDecode() {
return [
'Uppercase base64 encoding' => [
'tést.txt',
'=?utf-8?B?dMOpc3QudHh0?=',
],
'Uppercase quoted-printable encoding' => [
'tést.txt',
'=?UTF-8?Q?t=C3=A9st.txt?=',
],
'Lowercase base64 encoding' => [
'tést.txt',
'=?utf-8?b?dMOpc3QudHh0?=',
],
'Lowercase quoted-printable encoding' => [
'tést.txt',
'=?UTF-8?q?t=C3=A9st.txt?=',
],
'ASCII characters only' => [
'test.txt',
'test.txt',
],
];
}
@@ -192,7 +192,6 @@ class ScaffoldTest extends TestCase {
*/
public function testProjectThatScaffoldsEmptyProject() {
$fixture_name = 'project-allowing-empty-fixture';
$is_link = FALSE;
$result = $this->scaffoldSut($fixture_name, FALSE, FALSE);
$this->assertStringContainsString('The allowed package fixtures/empty-fixture does not provide a file mapping for Composer Scaffold', $result->scaffoldOutput());
$this->assertCommonDrupalAssetsWereScaffolded($result->docroot(), FALSE);
@@ -6,13 +6,13 @@ use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Package\PackageInterface;
use Composer\Package\RootPackageInterface;
use Drupal\Composer\VendorHardening\Config;
use Drupal\Composer\Plugin\VendorHardening\Config;
use Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin;
use org\bovigo\vfs\vfsStream;
use PHPUnit\Framework\TestCase;
/**
* @coversDefaultClass Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin
* @coversDefaultClass \Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin
* @group VendorHardening
*/
class VendorHardeningPluginTest extends TestCase {
@@ -36,7 +36,6 @@ class VendorHardeningPluginTest extends TestCase {
public function testCleanPackage() {
$config = $this->getMockBuilder(Config::class)
->setMethods(['getPathsForPackage'])
->disableOriginalConstructor()
->getMock();
$config->expects($this->once())
@@ -85,7 +84,6 @@ class VendorHardeningPluginTest extends TestCase {
*/
public function testCleanAllPackages() {
$config = $this->getMockBuilder(Config::class)
->setMethods(['getAllCleanupPaths'])
->disableOriginalConstructor()
->getMock();
$config->expects($this->once())
@@ -93,7 +91,6 @@ class VendorHardeningPluginTest extends TestCase {
->willReturn(['drupal/package' => ['tests']]);
$package = $this->getMockBuilder(PackageInterface::class)
->setMethods(['getName'])
->getMockForAbstractClass();
$package->expects($this->any())
->method('getName')
@@ -374,7 +374,6 @@ class AccessManagerTest extends UnitTestCase {
->with('test_route_1')
->will($this->returnValue($route));
$map = [];
$map[] = ['test_route_1', ['value' => 'example'], '/test-route-1/example'];
$this->paramConverter = $this->createMock('Drupal\Core\ParamConverter\ParamConverterManagerInterface');
@@ -423,7 +422,6 @@ class AccessManagerTest extends UnitTestCase {
->with('test_route_1')
->will($this->returnValue($route));
$map = [];
$map[] = ['test_route_1', ['value' => 'example'], '/test-route-1/example'];
$this->paramConverter = $this->createMock('Drupal\Core\ParamConverter\ParamConverterManagerInterface');
@@ -644,6 +644,24 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->assertEquals('libraries/third_party_library/css/example.css', $library['css'][0]['data']);
}
/**
* @covers ::parseLibraryInfo
*/
public function testEmptyLibraryFile() {
$this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists')
->with('empty')
->will($this->returnValue(TRUE));
$path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1);
$this->libraryDiscoveryParser->setPaths('module', 'empty', $path);
$libraries = $this->libraryDiscoveryParser->buildByExtension('empty');
$this->assertEquals([], $libraries);
}
}
/**
@@ -0,0 +1 @@
# This file intentionally left empty
@@ -36,8 +36,8 @@ class EntityTypeTest extends UnitTestCase {
*
* @dataProvider providerTestGet
*/
public function testGet(array $defintion, $key, $expected) {
$entity_type = $this->setUpEntityType($defintion);
public function testGet(array $definition, $key, $expected) {
$entity_type = $this->setUpEntityType($definition);
$this->assertSame($expected, $entity_type->get($key));
}
@@ -54,7 +54,6 @@ class FormAjaxResponseBuilderTest extends UnitTestCase {
$form_state = new FormState();
$commands = [];
$expected = [];
$this->expectException(HttpException::class);
$this->formAjaxResponseBuilder->buildResponse($request, $form, $form_state, $commands);
}
@@ -73,7 +72,6 @@ class FormAjaxResponseBuilderTest extends UnitTestCase {
$form_state->setTriggeringElement($triggering_element);
$commands = [];
$expected = [];
$this->expectException(HttpException::class);
$this->formAjaxResponseBuilder->buildResponse($request, $form, $form_state, $commands);
}
@@ -53,17 +53,6 @@ class PathProcessorTest extends UnitTestCase {
],
];
// Create a URL-based language negotiation method definition.
$method_definitions = [
LanguageNegotiationUrl::METHOD_ID => [
'class' => '\Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl',
'weight' => 9,
],
];
// Create a URL-based language negotiation method.
$method_instance = new LanguageNegotiationUrl($config);
// Create a language manager stub.
$language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface')
->getMock();
@@ -77,7 +66,6 @@ class PathProcessorTest extends UnitTestCase {
->method('getLanguageTypes')
->will($this->returnValue([LanguageInterface::TYPE_INTERFACE]));
$method_instance->setLanguageManager($language_manager);
$this->languageManager = $language_manager;
}
@@ -100,7 +100,7 @@ class HookDiscoveryTest extends UnitTestCase {
]
));
$this->assertNull($this->hookDiscovery->getDefinition('test_non_existant', FALSE));
$this->assertNull($this->hookDiscovery->getDefinition('test_non_existent', FALSE));
$plugin_definition = $this->hookDiscovery->getDefinition('test_id_1');
$this->assertEquals($plugin_definition['class'], 'Drupal\plugin_test\Plugin\plugin_test\fruit\Apple');
@@ -126,7 +126,7 @@ class HookDiscoveryTest extends UnitTestCase {
->will($this->returnValue([]));
$this->expectException(PluginNotFoundException::class);
$this->hookDiscovery->getDefinition('test_non_existant', TRUE);
$this->hookDiscovery->getDefinition('test_non_existent', TRUE);
}
protected function hookDiscoveryTestTestPlugin() {
@@ -42,7 +42,7 @@ class PluginWithFormsTraitTest extends UnitTestCase {
return [
'block plugin without forms, "configure" operation' => [$block_plugin_without_forms, 'configure', TestClass::class],
'block plugin without forms, "tickle" operation' => [$block_plugin_without_forms, 'tickle', NULL],
'block plugin withut forms, "poke" operation' => [$block_plugin_without_forms, 'poke', NULL],
'block plugin without forms, "poke" operation' => [$block_plugin_without_forms, 'poke', NULL],
'block plugin with forms, "configure" operation' => [$block_plugin_with_forms, 'configure', TestClass::class],
'block plugin with forms, "tickle" operation' => [$block_plugin_with_forms, 'tickle', NULL],
'block plugin with forms, "poke" operation' => [$block_plugin_with_forms, 'poke', static::class],
@@ -35,9 +35,9 @@ class RequestFormatRouteFilterTest extends UnitTestCase {
public function filterProvider() {
$route_without_format = new Route('/test');
$route_with_format = $route = new Route('/test');
$route_with_format = new Route('/test');
$route_with_format->setRequirement('_format', 'json');
$route_with_multiple_formats = $route = new Route('/test');
$route_with_multiple_formats = new Route('/test');
$route_with_multiple_formats->setRequirement('_format', 'json|xml');
$collection = new RouteCollection();
@@ -71,7 +71,7 @@ class RequestFormatRouteFilterTest extends UnitTestCase {
\Drupal::setContainer($container);
$collection = new RouteCollection();
$route_with_format = $route = new Route('/test');
$route_with_format = new Route('/test');
$route_with_format->setRequirement('_format', 'json');
$collection->add('test_0', $route_with_format);
$collection->add('test_1', clone $route_with_format);
@@ -102,7 +102,7 @@ class RequestFormatRouteFilterTest extends UnitTestCase {
\Drupal::setContainer($container);
$collection = new RouteCollection();
$route_with_format = $route = new Route('/test');
$route_with_format = new Route('/test');
$route_with_format->setRequirement('_format', 'json|xml');
$collection->add('sole_route_multiple_formats', $route_with_format);
@@ -57,7 +57,7 @@ class PhpUnitTestRunnerTest extends UnitTestCase {
'test_id' => $test_id,
'test_class' => 'SomeTest',
'status' => TestStatus::label(TestStatus::EXCEPTION),
'message' => 'PHPunit Test failed to complete; Error: ',
'message' => 'PHPUnit Test failed to complete; Error: ',
'message_group' => 'Other',
'function' => 'SomeTest',
'line' => '0',