Skip to content
Snippets Groups Projects
Verified Commit 9f6b172c authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3119761 by dww, aleevas, Hardik_Patel_12, quietone, tedbow,...

Issue #3119761 by dww, aleevas, Hardik_Patel_12, quietone, tedbow, _utsavsharma, smustgrave, xjm, longwave: Replace multiple test methods in InfoParserUnitTest with 1 testInfoException and a dataprovider
parent 9cdd6488
No related branches found
No related tags found
33 merge requests!12227Issue #3181946 by jonmcl, mglaman,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!7526Expose roles in response,!7352Draft: Resolve #3203489 "Set filename as",!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3668Resolve #3347842 "Deprecate the trusted",!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3478Issue #3337882: Deleted menus are not removed from content type config,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #111495 canceled
......@@ -55,94 +55,101 @@ public function testInfoParserNonExisting() {
/**
* Tests if correct exception is thrown for a broken info file.
*
* @covers ::parse
* @param string $yaml
* The YAML to use to create the file to parse.
* @param string $expected_exception_message
* The expected exception message.
*
* @dataProvider providerInfoException
*/
public function testInfoParserBroken() {
$broken_info = <<<BROKEN_INFO
# info.yml for testing broken YAML parsing exception handling.
name: File
type: module
description: 'Defines a file field type.'
package: Core
version: VERSION
core_version_requirement: '*'
dependencies::;;
- field
BROKEN_INFO;
public function testInfoException($yaml, $expected_exception_message): void {
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
'broken.info.txt' => $broken_info,
"broken.info.txt" => $yaml,
"broken-duplicate.info.txt" => $yaml,
],
]);
$filename = vfsStream::url('modules/fixtures/broken.info.txt');
$this->expectException('\Drupal\Core\Extension\InfoParserException');
$this->expectExceptionMessage('broken.info.txt');
$this->infoParser->parse($filename);
try {
$this->infoParser->parse(vfsStream::url("modules/fixtures/broken.info.txt"));
}
catch (InfoParserException $exception) {
$this->assertSame("$expected_exception_message vfs://modules/fixtures/broken.info.txt", $exception->getMessage());
}
$this->expectException(InfoParserException::class);
$this->expectExceptionMessage("$expected_exception_message vfs://modules/fixtures/broken-duplicate.info.txt");
$this->infoParser->parse(vfsStream::url("modules/fixtures/broken-duplicate.info.txt"));
}
/**
* Tests that missing required keys are detected.
*
* @covers ::parse
* Data provider for testInfoException().
*/
public function testInfoParserMissingKeys() {
$missing_keys = <<<MISSING_KEYS
# info.yml for testing missing name, description, and type keys.
public static function providerInfoException(): array {
return [
'missing required key, type' => [
<<<YML
name: File
description: Missing key
package: Core
version: VERSION
dependencies:
- field
MISSING_KEYS;
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
'missing_keys.info.txt' => $missing_keys,
YML,
"Missing required keys (type) in",
],
]);
$filename = vfsStream::url('modules/fixtures/missing_keys.info.txt');
$this->expectException('\Drupal\Core\Extension\InfoParserException');
$this->expectExceptionMessage('Missing required keys (type, name) in vfs://modules/fixtures/missing_keys.info.txt');
$this->infoParser->parse($filename);
'missing core_version_requirement' => [
<<<YML
version: VERSION
type: module
name: Skynet
dependencies:
- self_awareness
YML,
"The 'core_version_requirement' key must be present in",
],
'missing two required keys' => [
<<<YML
package: Core
version: VERSION
dependencies:
- field
YML,
'Missing required keys (type, name) in',
],
];
}
/**
* Tests that a missing 'core_version_requirement' key is detected.
* Tests that the correct exception is thrown for a broken info file.
*
* @covers ::parse
*/
public function testMissingCoreVersionRequirement() {
$missing_core_version_requirement = <<<MISSING_CORE_VERSION_REQUIREMENT
# info.yml for testing core_version_requirement.
version: VERSION
public function testInfoParserBroken() {
$broken_info = <<<BROKEN_INFO
# info.yml for testing broken YAML parsing exception handling.
name: File
type: module
name: Skynet
dependencies:
- self_awareness
MISSING_CORE_VERSION_REQUIREMENT;
description: 'Defines a file field type.'
package: Core
version: VERSION
core_version_requirement: '*'
dependencies::;;
- field
BROKEN_INFO;
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
'missing_core_version_requirement.info.txt' => $missing_core_version_requirement,
'missing_core_version_requirement-duplicate.info.txt' => $missing_core_version_requirement,
'broken.info.txt' => $broken_info,
],
]);
$exception_message = "The 'core_version_requirement' key must be present in vfs://modules/fixtures/missing_core_version_requirement";
// Set the expected exception for the 2nd call to parse().
$filename = vfsStream::url('modules/fixtures/broken.info.txt');
$this->expectException('\Drupal\Core\Extension\InfoParserException');
$this->expectExceptionMessage("$exception_message-duplicate.info.txt");
try {
$this->infoParser->parse(vfsStream::url('modules/fixtures/missing_core_version_requirement.info.txt'));
}
catch (InfoParserException $exception) {
$this->assertSame("$exception_message.info.txt", $exception->getMessage());
$this->infoParser->parse(vfsStream::url('modules/fixtures/missing_core_version_requirement-duplicate.info.txt'));
}
$this->expectExceptionMessage('Unable to parse vfs://modules/fixtures/broken.info.txt');
$this->infoParser->parse($filename);
}
/**
......@@ -169,43 +176,6 @@ public function testTestingPackageMissingCoreVersionRequirement() {
$this->assertSame($info_values['core_version_requirement'], \Drupal::VERSION);
}
/**
* Tests that missing required key is detected.
*
* @covers ::parse
*/
public function testInfoParserMissingKey() {
$missing_key = <<<MISSING_KEY
# info.yml for testing missing type key.
name: File
description: 'Defines a file field type.'
package: Core
version: VERSION
dependencies:
- field
MISSING_KEY;
vfsStream::setup('modules');
vfsStream::create([
'fixtures' => [
'missing_key.info.txt' => $missing_key,
'missing_key-duplicate.info.txt' => $missing_key,
],
]);
// Set the expected exception for the 2nd call to parse().
$this->expectException(InfoParserException::class);
$this->expectExceptionMessage('Missing required keys (type) in vfs://modules/fixtures/missing_key-duplicate.info.txt');
try {
$this->infoParser->parse(vfsStream::url('modules/fixtures/missing_key.info.txt'));
}
catch (InfoParserException $exception) {
$this->assertSame('Missing required keys (type) in vfs://modules/fixtures/missing_key.info.txt', $exception->getMessage());
$this->infoParser->parse(vfsStream::url('modules/fixtures/missing_key-duplicate.info.txt'));
}
}
/**
* Tests common info file.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment