Issue #3441718 by mondrake: Fix string array keys in data sets returned by data provider methods that do not match the parameter names in Unit tests

merge-requests/7547/merge
Dave Long 2024-04-19 18:13:58 +01:00
parent 9fdd5efd31
commit f4e9c07001
No known key found for this signature in database
GPG Key ID: ED52AE211E142771
14 changed files with 322 additions and 318 deletions

View File

@ -909,441 +909,441 @@ class HTMLRestrictionsTest extends UnitTestCase {
yield 'any set + empty set' => [
'a' => new HTMLRestrictions(['a' => ['href' => TRUE]]),
'b' => HTMLRestrictions::emptySet(),
'diff' => 'a',
'intersection' => 'b',
'union' => 'a',
'expected_diff' => 'a',
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'empty set + any set' => [
'a' => HTMLRestrictions::emptySet(),
'b' => new HTMLRestrictions(['a' => ['href' => TRUE]]),
'diff' => 'a',
'intersection' => 'a',
'union' => 'b',
'expected_diff' => 'a',
'expected_intersection' => 'a',
'expected_union' => 'b',
];
// Basic cases: tags.
yield 'union of two very restricted tags' => [
'a' => new HTMLRestrictions(['a' => FALSE]),
'b' => new HTMLRestrictions(['a' => FALSE]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'a',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'a',
];
yield 'union of two very unrestricted tags' => [
'a' => new HTMLRestrictions(['a' => TRUE]),
'b' => new HTMLRestrictions(['a' => TRUE]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'a',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'a',
];
yield 'union of one very unrestricted tag with one very restricted tag' => [
'a' => new HTMLRestrictions(['a' => TRUE]),
'b' => new HTMLRestrictions(['a' => FALSE]),
'diff' => 'a',
'intersection' => 'b',
'union' => 'a',
'expected_diff' => 'a',
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'union of one very unrestricted tag with one very restricted tag — vice versa' => [
'a' => new HTMLRestrictions(['a' => FALSE]),
'b' => new HTMLRestrictions(['a' => TRUE]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
// Basic cases: attributes..
yield 'set + set with empty intersection' => [
'a' => new HTMLRestrictions(['a' => ['href' => TRUE]]),
'b' => new HTMLRestrictions(['b' => ['href' => TRUE]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['a' => ['href' => TRUE], 'b' => ['href' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['a' => ['href' => TRUE], 'b' => ['href' => TRUE]]),
];
yield 'set + identical set' => [
'a' => new HTMLRestrictions(['b' => ['href' => TRUE]]),
'b' => new HTMLRestrictions(['b' => ['href' => TRUE]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'b',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'b',
'expected_union' => 'b',
];
yield 'set + superset' => [
'a' => new HTMLRestrictions(['a' => ['href' => TRUE]]),
'b' => new HTMLRestrictions(['b' => ['href' => TRUE], 'a' => ['href' => TRUE]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
// Tag restrictions.
yield 'tag restrictions are different: <a> vs <b c>' => [
'a' => new HTMLRestrictions(['a' => FALSE]),
'b' => new HTMLRestrictions(['b' => ['c' => TRUE]]),
'diff' => 'a',
'intersect' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['a' => FALSE, 'b' => ['c' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['a' => FALSE, 'b' => ['c' => TRUE]]),
];
yield 'tag restrictions are different: <a> vs <b c> — vice versa' => [
'a' => new HTMLRestrictions(['b' => ['c' => TRUE]]),
'b' => new HTMLRestrictions(['a' => FALSE]),
'diff' => 'a',
'intersect' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['a' => FALSE, 'b' => ['c' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['a' => FALSE, 'b' => ['c' => TRUE]]),
];
yield 'tag restrictions are different: <a *> vs <b c>' => [
'a' => new HTMLRestrictions(['a' => TRUE]),
'b' => new HTMLRestrictions(['b' => ['c' => TRUE]]),
'diff' => 'a',
'intersect' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['a' => TRUE, 'b' => ['c' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['a' => TRUE, 'b' => ['c' => TRUE]]),
];
yield 'tag restrictions are different: <a *> vs <b c> — vice versa' => [
'a' => new HTMLRestrictions(['b' => ['c' => TRUE]]),
'b' => new HTMLRestrictions(['a' => TRUE]),
'diff' => 'a',
'intersect' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['a' => TRUE, 'b' => ['c' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['a' => TRUE, 'b' => ['c' => TRUE]]),
];
// Attribute restrictions.
yield 'attribute restrictions are less permissive: <a *> vs <a>' => [
'a' => new HTMLRestrictions(['a' => TRUE]),
'b' => new HTMLRestrictions(['a' => FALSE]),
'diff' => 'a',
'intersection' => 'b',
'union' => 'a',
'expected_diff' => 'a',
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'attribute restrictions are more permissive: <a> vs <a *>' => [
'a' => new HTMLRestrictions(['a' => FALSE]),
'b' => new HTMLRestrictions(['a' => TRUE]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
yield 'attribute restrictions are more permissive: <a href> vs <a *>' => [
'a' => new HTMLRestrictions(['a' => ['href' => TRUE]]),
'b' => new HTMLRestrictions(['a' => TRUE]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
yield 'attribute restrictions are more permissive: <a> vs <a href>' => [
'a' => new HTMLRestrictions(['a' => FALSE]),
'b' => new HTMLRestrictions(['a' => ['href' => TRUE]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
yield 'attribute restrictions are more restrictive: <a href> vs <a>' => [
'a' => new HTMLRestrictions(['a' => ['href' => TRUE]]),
'b' => new HTMLRestrictions(['a' => FALSE]),
'diff' => 'a',
'intersection' => 'b',
'union' => 'a',
'expected_diff' => 'a',
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'attribute restrictions are more restrictive: <a *> vs <a href>' => [
'a' => new HTMLRestrictions(['a' => TRUE]),
'b' => new HTMLRestrictions(['a' => ['href' => TRUE]]),
'diff' => 'a',
'intersection' => 'b',
'union' => 'a',
'expected_diff' => 'a',
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'attribute restrictions are different: <a href> vs <a hreflang>' => [
'a' => new HTMLRestrictions(['a' => ['href' => TRUE]]),
'b' => new HTMLRestrictions(['a' => ['hreflang' => TRUE]]),
'diff' => 'a',
'intersection' => new HTMLRestrictions(['a' => FALSE]),
'union' => new HTMLRestrictions(['a' => ['href' => TRUE, 'hreflang' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => new HTMLRestrictions(['a' => FALSE]),
'expected_union' => new HTMLRestrictions(['a' => ['href' => TRUE, 'hreflang' => TRUE]]),
];
yield 'attribute restrictions are different: <a href> vs <a hreflang> — vice versa' => [
'a' => new HTMLRestrictions(['a' => ['hreflang' => TRUE]]),
'b' => new HTMLRestrictions(['a' => ['href' => TRUE]]),
'diff' => 'a',
'intersection' => new HTMLRestrictions(['a' => FALSE]),
'union' => new HTMLRestrictions(['a' => ['href' => TRUE, 'hreflang' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => new HTMLRestrictions(['a' => FALSE]),
'expected_union' => new HTMLRestrictions(['a' => ['href' => TRUE, 'hreflang' => TRUE]]),
];
// Attribute value restriction.
yield 'attribute restrictions are different: <a hreflang="en"> vs <a hreflang="fr">' => [
'a' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]]]),
'b' => new HTMLRestrictions(['a' => ['hreflang' => ['fr' => TRUE]]]),
'diff' => 'a',
'intersection' => new HTMLRestrictions(['a' => FALSE]),
'union' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE, 'fr' => TRUE]]]),
'expected_diff' => 'a',
'expected_intersection' => new HTMLRestrictions(['a' => FALSE]),
'expected_union' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE, 'fr' => TRUE]]]),
];
yield 'attribute restrictions are different: <a hreflang="en"> vs <a hreflang="fr"> — vice versa' => [
'a' => new HTMLRestrictions(['a' => ['hreflang' => ['fr' => TRUE]]]),
'b' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]]]),
'diff' => 'a',
'intersection' => new HTMLRestrictions(['a' => FALSE]),
'union' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE, 'fr' => TRUE]]]),
'expected_diff' => 'a',
'expected_intersection' => new HTMLRestrictions(['a' => FALSE]),
'expected_union' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE, 'fr' => TRUE]]]),
];
yield 'attribute restrictions are different: <a hreflang=*> vs <a hreflang="en">' => [
'a' => new HTMLRestrictions(['a' => ['hreflang' => TRUE]]),
'b' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]]]),
'diff' => 'a',
'intersection' => 'b',
'union' => 'a',
'expected_diff' => 'a',
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'attribute restrictions are different: <a hreflang=*> vs <a hreflang="en"> — vice versa' => [
'a' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]]]),
'b' => new HTMLRestrictions(['a' => ['hreflang' => TRUE]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
yield 'attribute restrictions are different: <ol type=*> vs <ol type="A">' => [
'a' => new HTMLRestrictions(['ol' => ['type' => TRUE]]),
'b' => new HTMLRestrictions(['ol' => ['type' => ['A' => TRUE]]]),
'diff' => 'a',
'intersection' => 'b',
'union' => 'a',
'expected_diff' => 'a',
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'attribute restrictions are different: <ol type=*> vs <ol type="A"> — vice versa' => [
'b' => new HTMLRestrictions(['ol' => ['type' => ['A' => TRUE]]]),
'a' => new HTMLRestrictions(['ol' => ['type' => TRUE]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
yield 'attribute restrictions are different: <ol type=*> vs <ol type="1">' => [
'a' => new HTMLRestrictions(['ol' => ['type' => TRUE]]),
'b' => new HTMLRestrictions(['ol' => ['type' => ['1' => TRUE]]]),
'diff' => 'a',
'intersection' => 'b',
'union' => 'a',
'expected_diff' => 'a',
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'attribute restrictions are different: <ol type=*> vs <ol type="1"> — vice versa' => [
'b' => new HTMLRestrictions(['ol' => ['type' => ['1' => TRUE]]]),
'a' => new HTMLRestrictions(['ol' => ['type' => TRUE]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
yield 'attribute restrictions are the same: <ol type="1"> vs <ol type="1">' => [
'a' => new HTMLRestrictions(['ol' => ['type' => ['1' => TRUE]]]),
'b' => new HTMLRestrictions(['ol' => ['type' => ['1' => TRUE]]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'a',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'a',
];
// Complex cases.
yield 'attribute restrictions are different: <a hreflang="en"> vs <strong>' => [
'a' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]]]),
'b' => new HTMLRestrictions(['strong' => TRUE]),
'diff' => 'a',
'intersect' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]], 'strong' => TRUE]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]], 'strong' => TRUE]),
];
yield 'attribute restrictions are different: <a hreflang="en"> vs <strong> — vice versa' => [
'a' => new HTMLRestrictions(['strong' => TRUE]),
'b' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]]]),
'diff' => 'a',
'intersect' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]], 'strong' => TRUE]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]], 'strong' => TRUE]),
];
yield 'very restricted tag + slightly restricted tag' => [
'a' => new HTMLRestrictions(['a' => FALSE]),
'b' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
yield 'very restricted tag + slightly restricted tag — vice versa' => [
'a' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]]]),
'b' => new HTMLRestrictions(['a' => FALSE]),
'diff' => 'a',
'intersection' => 'b',
'union' => 'a',
'expected_diff' => 'a',
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'very unrestricted tag + slightly restricted tag' => [
'a' => new HTMLRestrictions(['a' => TRUE]),
'b' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]]]),
'diff' => 'a',
'intersection' => 'b',
'union' => 'a',
'expected_diff' => 'a',
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'very unrestricted tag + slightly restricted tag — vice versa' => [
'a' => new HTMLRestrictions(['a' => ['hreflang' => ['en' => TRUE]]]),
'b' => new HTMLRestrictions(['a' => TRUE]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
// Wildcard tag + matching tag cases.
yield 'wildcard + matching tag: attribute intersection — without possible resolving' => [
'a' => new HTMLRestrictions(['p' => ['class' => TRUE]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['p' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['p' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
];
yield 'wildcard + matching tag: attribute intersection — without possible resolving — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]),
'b' => new HTMLRestrictions(['p' => ['class' => TRUE]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['p' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['p' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
];
yield 'wildcard + matching tag: attribute intersection — WITH possible resolving' => [
'a' => new HTMLRestrictions(['p' => ['class' => TRUE]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => TRUE], 'p' => FALSE]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => new HTMLRestrictions(['p' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => new HTMLRestrictions(['p' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
];
yield 'wildcard + matching tag: attribute intersection — WITH possible resolving — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => TRUE], 'p' => FALSE]),
'b' => new HTMLRestrictions(['p' => ['class' => TRUE]]),
'diff' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]),
'intersection' => 'b',
'union' => new HTMLRestrictions(['p' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
'expected_diff' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]),
'expected_intersection' => 'b',
'expected_union' => new HTMLRestrictions(['p' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
];
yield 'wildcard + matching tag: attribute value intersection — without possible resolving' => [
'a' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]], '$text-container' => ['class' => ['text-align-center' => TRUE]]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]], '$text-container' => ['class' => ['text-align-center' => TRUE]]]),
];
yield 'wildcard + matching tag: attribute value intersection — without possible resolving — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]]]),
'b' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]], '$text-container' => ['class' => ['text-align-center' => TRUE]]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]], '$text-container' => ['class' => ['text-align-center' => TRUE]]]),
];
yield 'wildcard + matching tag: attribute value intersection — WITH possible resolving' => [
'a' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]], 'p' => FALSE]),
'diff' => new HTMLRestrictions(['p' => ['class' => ['text-align-justify' => TRUE]]]),
'intersection' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE]]]),
'union' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]], '$text-container' => ['class' => ['text-align-center' => TRUE]]]),
'expected_diff' => new HTMLRestrictions(['p' => ['class' => ['text-align-justify' => TRUE]]]),
'expected_intersection' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE]]]),
'expected_union' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]], '$text-container' => ['class' => ['text-align-center' => TRUE]]]),
];
yield 'wildcard + matching tag: attribute value intersection — WITH possible resolving — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]], 'p' => FALSE]),
'b' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]]]),
'diff' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]]]),
'intersection' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE]]]),
'union' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]], '$text-container' => ['class' => ['text-align-center' => TRUE]]]),
'expected_diff' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]]]),
'expected_intersection' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE]]]),
'expected_union' => new HTMLRestrictions(['p' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]], '$text-container' => ['class' => ['text-align-center' => TRUE]]]),
];
yield 'wildcard + matching tag: on both sides' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => TRUE, 'foo' => TRUE], 'p' => FALSE]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => TRUE], 'p' => FALSE]),
'diff' => new HTMLRestrictions(['$text-container' => ['foo' => TRUE], 'p' => ['foo' => TRUE]]),
'intersection' => new HTMLRestrictions(['$text-container' => ['class' => TRUE], 'p' => ['class' => TRUE]]),
'union' => 'a',
'expected_diff' => new HTMLRestrictions(['$text-container' => ['foo' => TRUE], 'p' => ['foo' => TRUE]]),
'expected_intersection' => new HTMLRestrictions(['$text-container' => ['class' => TRUE], 'p' => ['class' => TRUE]]),
'expected_union' => 'a',
];
yield 'wildcard + matching tag: on both sides — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => TRUE], 'p' => FALSE]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => TRUE, 'foo' => TRUE], 'p' => FALSE]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => new HTMLRestrictions(['$text-container' => ['class' => TRUE], 'p' => ['class' => TRUE]]),
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => new HTMLRestrictions(['$text-container' => ['class' => TRUE], 'p' => ['class' => TRUE]]),
'expected_union' => 'b',
];
yield 'wildcard + matching tag: wildcard resolves into matching tag, but matching tag already supports all attributes' => [
'a' => new HTMLRestrictions(['p' => TRUE]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => ['foo' => TRUE, 'bar' => TRUE]]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['p' => TRUE, '$text-container' => ['class' => ['foo' => TRUE, 'bar' => TRUE]]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['p' => TRUE, '$text-container' => ['class' => ['foo' => TRUE, 'bar' => TRUE]]]),
];
yield 'wildcard + matching tag: wildcard resolves into matching tag, but matching tag already supports all attributes — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => ['foo' => TRUE, 'bar' => TRUE]]]),
'b' => new HTMLRestrictions(['p' => TRUE]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['p' => TRUE, '$text-container' => ['class' => ['foo' => TRUE, 'bar' => TRUE]]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['p' => TRUE, '$text-container' => ['class' => ['foo' => TRUE, 'bar' => TRUE]]]),
];
// Wildcard tag + non-matching tag cases.
yield 'wildcard + non-matching tag: attribute diff — without possible resolving' => [
'a' => new HTMLRestrictions(['span' => ['class' => TRUE]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['span' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['span' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
];
yield 'wildcard + non-matching tag: attribute diff — without possible resolving — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]),
'b' => new HTMLRestrictions(['span' => ['class' => TRUE]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['span' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['span' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
];
yield 'wildcard + non-matching tag: attribute diff — WITH possible resolving' => [
'a' => new HTMLRestrictions(['span' => ['class' => TRUE]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => TRUE], 'span' => FALSE]),
'diff' => 'a',
'intersection' => new HTMLRestrictions(['span' => FALSE]),
'union' => new HTMLRestrictions(['span' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => new HTMLRestrictions(['span' => FALSE]),
'expected_union' => new HTMLRestrictions(['span' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
];
yield 'wildcard + non-matching tag: attribute diff — WITH possible resolving — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => TRUE], 'span' => FALSE]),
'b' => new HTMLRestrictions(['span' => ['class' => TRUE]]),
'diff' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]),
'intersection' => new HTMLRestrictions(['span' => FALSE]),
'union' => new HTMLRestrictions(['span' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
'expected_diff' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]),
'expected_intersection' => new HTMLRestrictions(['span' => FALSE]),
'expected_union' => new HTMLRestrictions(['span' => ['class' => TRUE], '$text-container' => ['class' => TRUE]]),
];
yield 'wildcard + non-matching tag: attribute value diff — without possible resolving' => [
'a' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => ['vertical-align-top' => TRUE]]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]], '$text-container' => ['class' => ['vertical-align-top' => TRUE]]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]], '$text-container' => ['class' => ['vertical-align-top' => TRUE]]]),
];
yield 'wildcard + non-matching tag: attribute value diff — without possible resolving — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => ['vertical-align-top' => TRUE]]]),
'b' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]], '$text-container' => ['class' => ['vertical-align-top' => TRUE]]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]], '$text-container' => ['class' => ['vertical-align-top' => TRUE]]]),
];
yield 'wildcard + non-matching tag: attribute value diff — WITH possible resolving' => [
'a' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => ['vertical-align-top' => TRUE]], 'span' => FALSE]),
'diff' => 'a',
'intersection' => new HTMLRestrictions(['span' => FALSE]),
'union' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]], '$text-container' => ['class' => ['vertical-align-top' => TRUE]]]),
'expected_diff' => 'a',
'expected_intersection' => new HTMLRestrictions(['span' => FALSE]),
'expected_union' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]], '$text-container' => ['class' => ['vertical-align-top' => TRUE]]]),
];
yield 'wildcard + non-matching tag: attribute value diff — WITH possible resolving — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => ['vertical-align-top' => TRUE]], 'span' => FALSE]),
'b' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]]]),
'diff' => new HTMLRestrictions(['$text-container' => ['class' => ['vertical-align-top' => TRUE]]]),
'intersection' => new HTMLRestrictions(['span' => FALSE]),
'union' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]], '$text-container' => ['class' => ['vertical-align-top' => TRUE]]]),
'expected_diff' => new HTMLRestrictions(['$text-container' => ['class' => ['vertical-align-top' => TRUE]]]),
'expected_intersection' => new HTMLRestrictions(['span' => FALSE]),
'expected_union' => new HTMLRestrictions(['span' => ['class' => ['vertical-align-top' => TRUE, 'vertical-align-bottom' => TRUE]], '$text-container' => ['class' => ['vertical-align-top' => TRUE]]]),
];
// Wildcard tag + wildcard tag cases.
yield 'wildcard + wildcard tag: attributes' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => TRUE, 'foo' => TRUE]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]),
'diff' => new HTMLRestrictions(['$text-container' => ['foo' => TRUE]]),
'intersection' => 'b',
'union' => 'a',
'expected_diff' => new HTMLRestrictions(['$text-container' => ['foo' => TRUE]]),
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'wildcard + wildcard tag: attributes — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => TRUE, 'foo' => TRUE]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
yield 'wildcard + wildcard tag: attribute values' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]]]),
'diff' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-justify' => TRUE]]]),
'intersection' => 'b',
'union' => 'a',
'expected_diff' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-justify' => TRUE]]]),
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'wildcard + wildcard tag: attribute values — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE]]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => ['text-align-center' => TRUE, 'text-align-justify' => TRUE]]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
// Concrete attributes + wildcard attribute cases for all 3 possible
@ -1358,44 +1358,44 @@ class HTMLRestrictionsTest extends UnitTestCase {
yield "concrete attrs + wildcard $wildcard_location attr that covers a superset" => [
'a' => new HTMLRestrictions(['img' => ['data-entity-bundle-type' => TRUE, 'data-entity-type' => TRUE]]),
'b' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
yield "concrete attrs + wildcard $wildcard_location attr that covers a superset — vice versa" => [
'a' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE]]),
'b' => new HTMLRestrictions(['img' => ['data-entity-bundle-type' => TRUE, 'data-entity-type' => TRUE]]),
'diff' => 'a',
'intersection' => 'b',
'union' => 'a',
'expected_diff' => 'a',
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield "concrete attrs + wildcard $wildcard_location attr that covers a subset" => [
'a' => new HTMLRestrictions(['img' => ['data-entity-bundle-type' => TRUE, 'data-entity-type' => TRUE, 'class' => TRUE]]),
'b' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE]]),
'diff' => new HTMLRestrictions(['img' => ['class' => TRUE]]),
'intersection' => new HTMLRestrictions(['img' => ['data-entity-bundle-type' => TRUE, 'data-entity-type' => TRUE]]),
'union' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE, 'class' => TRUE]]),
'expected_diff' => new HTMLRestrictions(['img' => ['class' => TRUE]]),
'expected_intersection' => new HTMLRestrictions(['img' => ['data-entity-bundle-type' => TRUE, 'data-entity-type' => TRUE]]),
'expected_union' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE, 'class' => TRUE]]),
];
yield "concrete attrs + wildcard $wildcard_location attr that covers a subset — vice versa" => [
'a' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE]]),
'b' => new HTMLRestrictions(['img' => ['data-entity-bundle-type' => TRUE, 'data-entity-type' => TRUE, 'class' => TRUE]]),
'diff' => 'a',
'intersection' => new HTMLRestrictions(['img' => ['data-entity-bundle-type' => TRUE, 'data-entity-type' => TRUE]]),
'union' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE, 'class' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => new HTMLRestrictions(['img' => ['data-entity-bundle-type' => TRUE, 'data-entity-type' => TRUE]]),
'expected_union' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE, 'class' => TRUE]]),
];
yield "wildcard $wildcard_location attr + wildcard $wildcard_location attr" => [
'a' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE, 'class' => TRUE]]),
'b' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE]]),
'diff' => new HTMLRestrictions(['img' => ['class' => TRUE]]),
'intersection' => 'b',
'union' => 'a',
'expected_diff' => new HTMLRestrictions(['img' => ['class' => TRUE]]),
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield "wildcard $wildcard_location attr + wildcard $wildcard_location attr — vice versa" => [
'a' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE]]),
'b' => new HTMLRestrictions(['img' => [$wildcard_attr_name => TRUE, 'class' => TRUE]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
}
@ -1403,90 +1403,90 @@ class HTMLRestrictionsTest extends UnitTestCase {
yield 'global attribute tag + global attribute tag: no overlap in attributes' => [
'a' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE]]),
'b' => new HTMLRestrictions(['*' => ['baz' => FALSE]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE, 'baz' => FALSE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE, 'baz' => FALSE]]),
];
yield 'global attribute tag + global attribute tag: no overlap in attributes — vice versa' => [
'a' => new HTMLRestrictions(['*' => ['baz' => FALSE]]),
'b' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE, 'baz' => FALSE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE, 'baz' => FALSE]]),
];
yield 'global attribute tag + global attribute tag: overlap in attributes, same attribute value restrictions' => [
'a' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]]]),
'b' => new HTMLRestrictions(['*' => ['bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]]]),
'diff' => new HTMLRestrictions(['*' => ['foo' => TRUE]]),
'intersection' => 'b',
'union' => 'a',
'expected_diff' => new HTMLRestrictions(['*' => ['foo' => TRUE]]),
'expected_intersection' => 'b',
'expected_union' => 'a',
];
yield 'global attribute tag + global attribute tag: overlap in attributes, same attribute value restrictions — vice versa' => [
'a' => new HTMLRestrictions(['*' => ['bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]]]),
'b' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]]]),
'diff' => HTMLRestrictions::emptySet(),
'intersection' => 'a',
'union' => 'b',
'expected_diff' => HTMLRestrictions::emptySet(),
'expected_intersection' => 'a',
'expected_union' => 'b',
];
yield 'global attribute tag + global attribute tag: overlap in attributes, different attribute value restrictions' => [
'a' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]]]),
'b' => new HTMLRestrictions(['*' => ['bar' => TRUE, 'dir' => TRUE, 'foo' => FALSE]]),
'diff' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE]]),
'intersection' => new HTMLRestrictions(['*' => ['bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE], 'foo' => FALSE]]),
'union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => TRUE, 'dir' => TRUE]]),
'expected_diff' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE]]),
'expected_intersection' => new HTMLRestrictions(['*' => ['bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE], 'foo' => FALSE]]),
'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => TRUE, 'dir' => TRUE]]),
];
yield 'global attribute tag + global attribute tag: overlap in attributes, different attribute value restrictions — vice versa' => [
'a' => new HTMLRestrictions(['*' => ['bar' => TRUE, 'dir' => TRUE, 'foo' => FALSE]]),
'b' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE]]]),
'diff' => 'a',
'intersection' => new HTMLRestrictions(['*' => ['bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE], 'foo' => FALSE]]),
'union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => TRUE, 'dir' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => new HTMLRestrictions(['*' => ['bar' => FALSE, 'dir' => ['ltr' => TRUE, 'rtl' => TRUE], 'foo' => FALSE]]),
'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => TRUE, 'dir' => TRUE]]),
];
// Global attribute `*` HTML tag + concrete tag.
yield 'global attribute tag + concrete tag' => [
'a' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE]]),
'b' => new HTMLRestrictions(['p' => FALSE]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], 'p' => FALSE]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], 'p' => FALSE]),
];
yield 'global attribute tag + concrete tag — vice versa' => [
'a' => new HTMLRestrictions(['p' => FALSE]),
'b' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], 'p' => FALSE]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], 'p' => FALSE]),
];
yield 'global attribute tag + concrete tag with allowed attribute' => [
'a' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE]]),
'b' => new HTMLRestrictions(['p' => ['baz' => TRUE]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], 'p' => ['baz' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], 'p' => ['baz' => TRUE]]),
];
yield 'global attribute tag + concrete tag with allowed attribute — vice versa' => [
'a' => new HTMLRestrictions(['p' => ['baz' => TRUE]]),
'b' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], 'p' => ['baz' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], 'p' => ['baz' => TRUE]]),
];
// Global attribute `*` HTML tag + wildcard tag.
yield 'global attribute tag + wildcard tag' => [
'a' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE]]),
'b' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], '$text-container' => ['class' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], '$text-container' => ['class' => TRUE]]),
];
yield 'global attribute tag + wildcard tag — vice versa' => [
'a' => new HTMLRestrictions(['$text-container' => ['class' => TRUE]]),
'b' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE]]),
'diff' => 'a',
'intersection' => HTMLRestrictions::emptySet(),
'union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], '$text-container' => ['class' => TRUE]]),
'expected_diff' => 'a',
'expected_intersection' => HTMLRestrictions::emptySet(),
'expected_union' => new HTMLRestrictions(['*' => ['foo' => TRUE, 'bar' => FALSE], '$text-container' => ['class' => TRUE]]),
];
}

View File

@ -49,36 +49,36 @@ final class FilterImageLazyLoadTest extends UnitTestCase {
public static function providerHtml(): array {
return [
'lazy loading attribute already added' => [
'input' => '<p><img src="foo.png" loading="lazy"></p>',
'output' => '<p><img src="foo.png" loading="lazy"></p>',
'html' => '<p><img src="foo.png" loading="lazy"></p>',
'expected' => '<p><img src="foo.png" loading="lazy"></p>',
],
'eager loading attribute already added' => [
'input' => '<p><img src="foo.png" loading="eager"/></p>',
'output' => '<p><img src="foo.png" loading="eager"></p>',
'html' => '<p><img src="foo.png" loading="eager"/></p>',
'expected' => '<p><img src="foo.png" loading="eager"></p>',
],
'image dimensions provided' => [
'input' => '<p><img src="foo.png" width="200" height="200"/></p>',
'output' => '<p><img src="foo.png" width="200" height="200" loading="lazy"></p>',
'html' => '<p><img src="foo.png" width="200" height="200"/></p>',
'expected' => '<p><img src="foo.png" width="200" height="200" loading="lazy"></p>',
],
'width image dimensions provided' => [
'input' => '<p><img src="foo.png" width="200"/></p>',
'output' => '<p><img src="foo.png" width="200"></p>',
'html' => '<p><img src="foo.png" width="200"/></p>',
'expected' => '<p><img src="foo.png" width="200"></p>',
],
'height image dimensions provided' => [
'input' => '<p><img src="foo.png" height="200"/></p>',
'output' => '<p><img src="foo.png" height="200"></p>',
'html' => '<p><img src="foo.png" height="200"/></p>',
'expected' => '<p><img src="foo.png" height="200"></p>',
],
'invalid loading attribute' => [
'input' => '<p><img src="foo.png" width="200" height="200" loading="foo"></p>',
'output' => '<p><img src="foo.png" width="200" height="200" loading="lazy"></p>',
'html' => '<p><img src="foo.png" width="200" height="200" loading="foo"></p>',
'expected' => '<p><img src="foo.png" width="200" height="200" loading="lazy"></p>',
],
'no image tag' => [
'input' => '<p>Lorem ipsum...</p>',
'output' => '<p>Lorem ipsum...</p>',
'html' => '<p>Lorem ipsum...</p>',
'expected' => '<p>Lorem ipsum...</p>',
],
'no image dimensions provided' => [
'input' => '<p><img src="foo.png"></p>',
'output' => '<p><img src="foo.png"></p>',
'html' => '<p><img src="foo.png"></p>',
'expected' => '<p><img src="foo.png"></p>',
],
];
}

View File

@ -512,7 +512,7 @@ class MigrateExecutableTest extends MigrateTestCase {
public static function providerTestRollback() {
return [
'Rollback delete' => [
'ID map records' => [
'id_map_records' => [
[
'source' => '1',
'destination' => '1',
@ -521,17 +521,17 @@ class MigrateExecutableTest extends MigrateTestCase {
],
],
'Rollback preserve' => [
'ID map records' => [
'id_map_records' => [
[
'source' => '1',
'destination' => '1',
'rollback_action' => MigrateIdMapInterface::ROLLBACK_PRESERVE,
],
],
'Rollback called' => FALSE,
'rollback_called' => FALSE,
],
'Rolling back a failed row' => [
'ID map records' => [
'id_map_records' => [
[
'source' => '1',
'destination' => NULL,
@ -539,10 +539,10 @@ class MigrateExecutableTest extends MigrateTestCase {
'rollback_action' => MigrateIdMapInterface::ROLLBACK_DELETE,
],
],
'Rollback called' => FALSE,
'rollback_called' => FALSE,
],
'Rolling back with ID map having records with duplicated destination ID' => [
'ID map records' => [
'id_map_records' => [
[
'source_1' => '1',
'source_2' => '1',
@ -562,11 +562,11 @@ class MigrateExecutableTest extends MigrateTestCase {
'rollback_action' => MigrateIdMapInterface::ROLLBACK_DELETE,
],
],
'Rollback called' => TRUE,
'Source ID keys' => ['source_1', 'source_2'],
'rollback_called' => TRUE,
'source_id_keys' => ['source_1', 'source_2'],
],
'Rollback NULL' => [
'ID map records' => [
'id_map_records' => [
[
'source' => '1',
'destination' => '1',
@ -575,7 +575,7 @@ class MigrateExecutableTest extends MigrateTestCase {
],
],
'Rollback missing' => [
'ID map records' => [
'id_map_records' => [
[
'source' => '1',
'destination' => '1',

View File

@ -1135,7 +1135,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
public static function getHighestIdDataProvider() {
return [
'Destination ID type integer' => [
'dest_ids' => [
'destination_ids' => [
'nid' => [
'type' => 'integer',
],
@ -1149,7 +1149,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
'expected' => 5,
],
'Destination ID types integer and string' => [
'dest_ids' => [
'destination_ids' => [
'nid' => [
'type' => 'integer',
],
@ -1200,14 +1200,14 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
public static function getHighestIdInvalidDataProvider() {
return [
'Destination ID type string' => [
'ids' => [
'destination_ids' => [
'language' => [
'type' => 'string',
],
],
],
'Destination ID types int (not integer) and string' => [
'ids' => [
'destination_ids' => [
'nid' => [
'type' => 'int',
],

View File

@ -381,7 +381,7 @@ class RowTest extends UnitTestCase {
return [
'Single Key' => [
'keys' => ['source_key_1'],
'values' => ['source_value_1'],
'expected_values' => ['source_value_1'],
],
'All Source Keys' => [
'keys' => [
@ -389,7 +389,7 @@ class RowTest extends UnitTestCase {
'source_key_2',
'@@source_key_3',
],
'values' => [
'expected_values' => [
'source_value_1',
'source_value_2',
'source_value_3',
@ -401,7 +401,7 @@ class RowTest extends UnitTestCase {
'@destination_key_2',
'@@@destination_key_3',
],
'values' => [
'expected_values' => [
'destination_value_1',
'destination_value_2',
'destination_value_3',
@ -417,7 +417,7 @@ class RowTest extends UnitTestCase {
'non_existent_source_key',
'@non_existent_destination_key',
],
'values' => [
'expected_values' => [
'source_shared_value_1',
'destination_shared_value_1',
'source_shared_value_2',

View File

@ -89,7 +89,7 @@ class SubProcessTest extends MigrateProcessTestCase {
public static function providerTestSubProcess() {
return [
'no source context' => [
'process configuration' => [
'process_configuration' => [
'process' => [
'foo' => 'source_foo',
'id' => 'source_id',
@ -98,7 +98,7 @@ class SubProcessTest extends MigrateProcessTestCase {
],
],
'default source key' => [
'process configuration' => [
'process_configuration' => [
'process' => [
'foo' => 'source_foo',
'id' => 'source_id',
@ -107,12 +107,12 @@ class SubProcessTest extends MigrateProcessTestCase {
'key' => '@id',
'include_source' => TRUE,
],
'source values' => [
'source_values' => [
'baf' => 'source_baz',
],
],
'renamed source key' => [
'process configuration' => [
'process_configuration' => [
'process' => [
'foo' => 'source_foo',
'id' => 'source_id',
@ -122,7 +122,7 @@ class SubProcessTest extends MigrateProcessTestCase {
'include_source' => TRUE,
'source_key' => 'my_source',
],
'source values' => [
'source_values' => [
'baf' => 'source_baz',
],
],
@ -176,7 +176,7 @@ class SubProcessTest extends MigrateProcessTestCase {
public static function providerTestNotFoundSubProcess() {
return [
'no key' => [
'process configuration' => [
'process_configuration' => [
'process' => [
'foo' => 'source_foo',
],
@ -184,7 +184,7 @@ class SubProcessTest extends MigrateProcessTestCase {
],
],
'lookup returns NULL' => [
'process configuration' => [
'process_configuration' => [
'process' => [
'foo' => 'source_foo',
'id' => 'source_id',

View File

@ -246,23 +246,23 @@ class FieldDiscoveryTest extends UnitTestCase {
return [
'Drupal 7' => [
'tags' => ['Drupal 7'],
'result' => '7',
'expected_result' => '7',
],
'Drupal 6' => [
'tags' => ['Drupal 6'],
'result' => '6',
'expected_result' => '6',
],
'D7 with others' => [
'tags' => ['Drupal 7', 'Translation', 'Other Tag'],
'result' => '7',
'expected_result' => '7',
],
'Both (d7 has priority)' => [
'tags' => ['Drupal 6', 'Drupal 7'],
'result' => '7',
'expected_result' => '7',
],
'Neither' => [
'tags' => ['drupal 6', 'Drupal_6', 'This contains Drupal 7 but is not'],
'result' => FALSE,
'expected_result' => FALSE,
],
];
}

View File

@ -24,7 +24,7 @@ class YamlPeclTest extends YamlTestBase {
* @covers ::decode
* @dataProvider providerEncodeDecodeTests
*/
public function testEncodeDecode($data) {
public function testEncodeDecode(array $data): void {
$this->assertEquals($data, YamlPecl::decode(YamlPecl::encode($data)));
}

View File

@ -23,7 +23,7 @@ class YamlTest extends YamlTestBase {
* @covers ::decode
* @dataProvider providerEncodeDecodeTests
*/
public function testEncodeDecode($data) {
public function testEncodeDecode(array $data): void {
$this->assertSame($data, Yaml::decode(Yaml::encode($data)));
}

View File

@ -17,6 +17,7 @@ abstract class YamlTestBase extends TestCase {
public function providerEncodeDecodeTests() {
return [
[
'data' => [
'foo' => 'bar',
'id' => 'schnitzel',
'ponies' => ['nope', 'thanks'],
@ -39,7 +40,10 @@ abstract class YamlTestBase extends TestCase {
[10],
[0 => '123456'],
],
[NULL],
],
[
'data' => [NULL],
],
];
}

View File

@ -119,14 +119,14 @@ class ColorTest extends TestCase {
// And some valid values.
$valid = [
// Shorthands without alpha.
['hex' => '#000', 'rgb' => ['red' => 0, 'green' => 0, 'blue' => 0]],
['hex' => '#fff', 'rgb' => ['red' => 255, 'green' => 255, 'blue' => 255]],
['hex' => '#abc', 'rgb' => ['red' => 170, 'green' => 187, 'blue' => 204]],
['hex' => 'cba', 'rgb' => ['red' => 204, 'green' => 187, 'blue' => 170]],
['value' => '#000', 'expected' => ['red' => 0, 'green' => 0, 'blue' => 0]],
['value' => '#fff', 'expected' => ['red' => 255, 'green' => 255, 'blue' => 255]],
['value' => '#abc', 'expected' => ['red' => 170, 'green' => 187, 'blue' => 204]],
['value' => 'cba', 'expected' => ['red' => 204, 'green' => 187, 'blue' => 170]],
// Full without alpha.
['hex' => '#000000', 'rgb' => ['red' => 0, 'green' => 0, 'blue' => 0]],
['hex' => '#ffffff', 'rgb' => ['red' => 255, 'green' => 255, 'blue' => 255]],
['hex' => '#010203', 'rgb' => ['red' => 1, 'green' => 2, 'blue' => 3]],
['value' => '#000000', 'expected' => ['red' => 0, 'green' => 0, 'blue' => 0]],
['value' => '#ffffff', 'expected' => ['red' => 255, 'green' => 255, 'blue' => 255]],
['value' => '#010203', 'expected' => ['red' => 1, 'green' => 2, 'blue' => 3]],
];
return array_merge($invalid, $valid);
}

View File

@ -76,7 +76,7 @@ class CryptTest extends TestCase {
[
'data' => 'The SHA (Secure Hash Algorithm) is one of a number of cryptographic hash functions. A cryptographic hash is like a signature for a text or a data file. SHA-256 algorithm generates an almost-unique, fixed size 256-bit (32-byte) hash. Hash is a one way function it cannot be decrypted back. This makes it suitable for password validation, challenge hash authentication, anti-tamper, digital signatures.',
// cspell:disable-next-line
'expectedHash' => '034rT6smZAVRxpq8O98cFFNLIVx_Ph1EwLZQKcmRR_s',
'expected_hash' => '034rT6smZAVRxpq8O98cFFNLIVx_Ph1EwLZQKcmRR_s',
],
[
'data' => 'SHA-256 is one of the successor hash functions to SHA-1, and is one of the strongest hash functions available.',

View File

@ -258,7 +258,7 @@ class AccessManagerTest extends UnitTestCase {
'name' => 'test_route_4',
'condition_one' => 'TRUE',
'condition_two' => 'FALSE',
'expected' => $access_kill,
'expected_access' => $access_kill,
];
$access_configurations[] = [
'name' => 'test_route_5',
@ -270,25 +270,25 @@ class AccessManagerTest extends UnitTestCase {
'name' => 'test_route_6',
'condition_one' => 'FALSE',
'condition_two' => 'NULL',
'expected' => $access_kill,
'expected_access' => $access_kill,
];
$access_configurations[] = [
'name' => 'test_route_7',
'condition_one' => 'TRUE',
'condition_two' => 'TRUE',
'expected' => $access_allow,
'expected_access' => $access_allow,
];
$access_configurations[] = [
'name' => 'test_route_8',
'condition_one' => 'FALSE',
'condition_two' => 'FALSE',
'expected' => $access_kill,
'expected_access' => $access_kill,
];
$access_configurations[] = [
'name' => 'test_route_9',
'condition_one' => 'NULL',
'condition_two' => 'NULL',
'expected' => $access_deny,
'expected_access' => $access_deny,
];
return $access_configurations;

View File

@ -127,7 +127,7 @@ class UserRolesAccessPolicyTest extends UnitTestCase {
public function calculatePermissionsProvider(): array {
$cases['no-roles'] = [
'roles' => [],
'has-admin' => FALSE,
'expect_admin_rights' => FALSE,
];
$cases['some-roles'] = [
'roles' => [
@ -140,7 +140,7 @@ class UserRolesAccessPolicyTest extends UnitTestCase {
'is_admin' => FALSE,
],
],
'has-admin' => FALSE,
'expect_admin_rights' => FALSE,
];
$cases['admin-role'] = [
'roles' => [
@ -153,7 +153,7 @@ class UserRolesAccessPolicyTest extends UnitTestCase {
'is_admin' => TRUE,
],
],
'has-admin' => TRUE,
'expect_admin_rights' => TRUE,
];
return $cases;
}