Skip to content
Snippets Groups Projects
Commit 7f5f0f8a 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 ed7dfc52
No related branches found
No related tags found
No related merge requests found
Pipeline #332569 failed
......@@ -73,7 +73,7 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
$this->createMock(EntityReferenceFieldItemListInterface::class),
LanguageInterface::LANGCODE_DEFAULT,
);
var_dump($elements);
var_dump($elements);
// Enhanced assertion and debugging as before
$this->assertCount(count($expectations), $elements);
......@@ -100,34 +100,42 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
*/
protected function createTerms(array $tree): array {
$created = [];
// Reset parent relationships before each test
$this->parentRelationships = [];
return array_map(function (array $lineage) use (&$created): array {
$terms = [];
$terms = [];
foreach ($lineage as $name) {
if (!isset($created[$name])) {
$link = $this->createMock(Link::class);
$link->method('toString')->willReturn(static::getGeneratedLink($name));
$link = $this->createMock(Link::class);
$link->method('toString')->willReturn(static::getGeneratedLink($name));
$term = $this->createMock(TermInterface::class);
$term->method('id')->willReturn($this->getFixedTermId($name));
$term->method('label')->willReturn($name);
$term->method('toLink')->willReturn($link);
$term = $this->createMock(TermInterface::class);
$term->method('id')->willReturn($this->getFixedTermId($name));
$term->method('label')->willReturn($name);
$term->method('toLink')->willReturn($link);
$created[$name] = $term;
// Explicitly set up the `parent` property to avoid warnings
// Assign a default `parent` value
$term->parent = NULL;
$created[$name] = $term;
}
$terms[] = $created[$name];
$terms[] = $created[$name];
}
// Set up parent relationships using the class property
$previous = NULL;
// Establish parent relationships in reverse lineage
$previous = NULL;
foreach (array_reverse($terms) as $term) {
if ($previous) {
$this->parentRelationships[$previous->id()] = $term;
$this->parentRelationships[$previous->id()] = $term;
// Explicitly set `parent` property
$previous->parent = $term;
}
$previous = $term;
$previous = $term;
}
return $terms;
return $terms;
}, $tree);
}
......
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