Skip to content
Snippets Groups Projects
Commit 6e6e6a6b authored by Joseph Olstad's avatar Joseph Olstad
Browse files

Issue #3455186 by cmlara, joseph.olstad - Refactor tests for D11 phpunit 10+...

Issue #3455186 by cmlara, joseph.olstad - Refactor tests for D11 phpunit 10+ compatibility refactoring test.
parent 179b1b5c
No related branches found
No related tags found
No related merge requests found
Pipeline #332412 failed
......@@ -79,7 +79,7 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
}
/**
* Creates mock terms based on a hierarchy tree.
* Creates mock terms based on a hierarchy tree and assigns parent IDs.
*
* @param array $tree
* Array representing term hierarchy.
......@@ -89,8 +89,9 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
*/
protected function createTerms(array $tree): array {
$created = [];
$parent_relationships = [];
return array_map(function (array $lineage) use (&$created): array {
return array_map(function (array $lineage) use (&$created, &$parent_relationships): array {
$terms = [];
foreach ($lineage as $name) {
if (!isset($created[$name])) {
......@@ -105,11 +106,9 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
$terms[] = $created[$name];
}
// Set up parent hierarchy without dynamic properties.
// Set up parent IDs for the terms.
foreach (array_reverse($lineage) as $name) {
$parent_item = $this->createMock(EntityReferenceFieldItemListInterface::class);
$parent_item->target_id = ($parent = next($lineage)) ? $created[$parent]->id() : NULL;
$created[$name]->expects($this->any())->method('getParent')->willReturn($parent_item);
$parent_relationships[$name] = ($parent = next($lineage)) ? $created[$parent]->id() : NULL;
}
return $terms;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment