Skip to content
Snippets Groups Projects
Commit d8a878f2 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 96a3a2a6
No related branches found
No related tags found
No related merge requests found
Pipeline #332737 canceled
......@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\Tests\cshs\Unit;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Field\EntityReferenceFieldItemListInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Link;
......@@ -109,37 +110,31 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
* @return \Drupal\taxonomy\TermInterface
* The stubbed term object.
*/
protected function createMockTerm(int $id, string $label, Link $link, $parent = NULL): TermInterface {
$term_mock = $this->getMockBuilder(TermInterface::class)
->disableOriginalConstructor()
->onlyMethods([
'id',
'label',
'toLink',
'set',
'getFields',
'getFieldDefinition',
'getTranslatableFields',
'toArray',
])
->getMock();
$term_mock->method('id')->willReturn($id);
$term_mock->method('label')->willReturn($label);
$term_mock->method('toLink')->willReturn($link);
$term_mock->method('set')->willReturnSelf();
$term_mock->method('getFields')->willReturn([]);
$term_mock->method('getFieldDefinition')->willReturn(NULL);
$term_mock->method('getTranslatableFields')->willReturn([]);
$term_mock->method('toArray')->willReturn([]);
// Add parent if necessary.
if ($parent !== NULL) {
$term_mock->parent = $parent;
}
protected function createMockTerm(int $id, string $label, Link $link, $parent = NULL): FieldableEntityInterface {
$term_mock = $this->getMockBuilder(FieldableEntityInterface::class)
->disableOriginalConstructor()
->onlyMethods([
'id',
'label',
'toLink',
'getFields',
'getFieldDefinition',
'getTranslatableFields',
'toArray',
])
->getMock();
$term_mock->method('id')->willReturn($id);
$term_mock->method('label')->willReturn($label);
$term_mock->method('toLink')->willReturn($link);
$term_mock->method('getFields')->willReturn([]);
$term_mock->method('getFieldDefinition')->willReturn(NULL);
$term_mock->method('getTranslatableFields')->willReturn([]);
$term_mock->method('toArray')->willReturn([]);
return $term_mock;
}
return $term_mock;
}
/**
* Creates mock terms based on a hierarchy tree and assigns parent IDs.
......
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