Skip to content
Snippets Groups Projects
Commit 2cf3c534 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 97ab0247
No related branches found
No related tags found
No related merge requests found
Pipeline #332609 failed
......@@ -122,16 +122,6 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
return $term;
}
/**
* Creates mock terms based on a hierarchy tree and assigns parent IDs.
*
* @param array $tree
* Array representing term hierarchy.
*
* @return array[]
* Array of mock term hierarchies.
*/
/**
* Creates mock terms based on a hierarchy tree and assigns parent IDs.
*
......@@ -152,53 +142,19 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
$link = $this->createMock(Link::class);
$link->method('toString')->willReturn(static::getGeneratedLink($name));
// Create an anonymous class implementing TermInterface.
$term = new class($this->getFixedTermId($name), $name, $link) implements TermInterface, \IteratorAggregate {
public int $target_id;
public string $label;
public Link $link;
public ?self $parent = NULL;
/**
*
*/
public function __construct($id, $label, $link) {
$this->target_id = $id;
$this->label = $label;
$this->link = $link;
}
/**
*
*/
public function id() {
return $this->target_id;
}
/**
*
*/
public function label() {
return $this->label;
}
/**
*
*/
public function toLink($text = NULL, $rel = 'canonical', array $options = []) {
return $this->link;
}
/**
*
*/
public function getIterator() {
return new \ArrayIterator($this);
}
};
$created[$name] = $term;
// Create a partial mock of TermInterface.
$term = $this->getMockBuilder(TermInterface::class)
->disableOriginalConstructor()
->onlyMethods(['id', 'label', 'toLink'])
->getMock();
// Mock the necessary methods.
$term->method('id')->willReturn($this->getFixedTermId($name));
$term->method('label')->willReturn($name);
$term->method('toLink')->willReturn($link);
// Store the term.
$created[$name] = $term;
}
$terms[] = $created[$name];
}
......
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