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

Issue #3455186 by joseph.olstad - Refactor of 88f1e040 for tests for D11...

Issue #3455186 by joseph.olstad - Refactor of 88f1e040 for tests for D11 phpunit 10+ compatibility refactoring test.
parent 75ae797c
No related branches found
No related tags found
No related merge requests found
Pipeline #333417 failed
......@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\Tests\cshs\Unit;
use PHPUnit\Framework\MockObject\MockObject;
use Drupal\Core\Field\EntityReferenceFieldItemListInterface;
use Drupal\Core\GeneratedLink;
use Drupal\Core\Language\LanguageInterface;
......@@ -56,16 +57,16 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
$link = $this->createMock(Link::class);
$link->method('toString')->willReturn(static::getGeneratedLink($name));
// Create a partial mock of TermInterface with the necessary methods.
$term = $this->getMockForAbstractClass(TermInterface::class, [], '', FALSE, TRUE, TRUE, [
'id', 'label', 'toLink', 'getDescription', 'setDescription',
]);
$term = $this->getMockBuilder(MockTerm::class)
->disableOriginalConstructor()
->onlyMethods(['id', 'label', 'toLink', 'getDescription', 'setDescription'])
->getMock();
$term->method('id')->willReturn(\random_int(1, 10000));
$term->method('label')->willReturn($name);
$term->method('toLink')->willReturn($link);
$term->method('getDescription')->willReturn('Description for ' . $name);
$term->method('setDescription')->willReturn(NULL);
$term->method('id')->willReturn(\random_int(1, 10000));
$term->method('label')->willReturn($name);
$term->method('toLink')->willReturn($link);
$term->method('getDescription')->willReturn('Description for ' . $name);
$term->method('setDescription')->willReturn(NULL);
// Explicitly add the 'parent' property to the mock.
$term->parent = NULL;
......@@ -316,3 +317,17 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
}
}
/**
*
*/
class MockTerm extends MockObject implements TermInterface {
public $parent;
/**
*
*/
public function __construct() {
$this->parent = NULL;
}
}
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