Skip to content
Snippets Groups Projects
Commit e78c9155 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 433da817
No related branches found
No related tags found
No related merge requests found
Pipeline #332462 failed
......@@ -41,10 +41,7 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
$mock->method('getSetting')->willReturnCallback(fn($key) => $settings[$key] ?? NULL);
// Create terms and establish expected hierarchy.
$terms = $this->createTerms($tree);
// Select the last term of each lineage as the "term to view".
$terms_to_view = array_map(static fn (array $lineage): TermInterface => end($lineage), $terms);
$mock->expects($this->once())->method('getEntitiesToView')->willReturn($terms_to_view);
......@@ -54,13 +51,13 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
foreach ($terms_to_view as $index => $term) {
$expected_parents = array_reverse($terms[$index]);
$term_storage->expects($this->exactly(count($terms_to_view)))
->method('loadAllParents')
// Configure `loadAllParents` to return the reversed lineage for each term.
$term_storage->method('loadAllParents')
->with($term->id())
->willReturn($expected_parents);
}
$mock->expects($this->exactly(count($terms_to_view)))->method('getTermStorage')->willReturn($term_storage);
$mock->method('getTermStorage')->willReturn($term_storage);
$mock->method('getTranslationFromContext')->willReturnArgument(0);
$elements = $mock->viewElements(
......@@ -152,9 +149,7 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
$last_value = \end($list);
$expectations[$i] = [
// Group title as the first term.
$first_value,
// Deepest child as the last term.
$last_value,
];
}
......
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