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

Issue #3455186 by joseph.olstad - back to the wild goose chase Refactored...

Issue #3455186 by joseph.olstad - back to the wild goose chase Refactored changes to 88f1e040 for tests for D11 phpunit 10+ compatibility refactoring test dynamic properties deprecation fixes.
parent 64a0cf60
No related branches found
No related tags found
No related merge requests found
Pipeline #333681 failed
......@@ -9,7 +9,6 @@ use Drupal\Core\GeneratedLink;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Link;
use Drupal\cshs\Plugin\Field\FieldFormatter\CshsGroupByRootFormatter;
use Drupal\taxonomy\TermInterface;
use Drupal\taxonomy\TermStorageInterface;
use Drupal\Tests\UnitTestCase;
......@@ -56,23 +55,18 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
if (!isset($created[$name])) {
$link = $this->createMock(Link::class);
$link->method('toString')->willReturn(static::getGeneratedLink($name));
$created[$name] = $this->createMock(TermInterface::class);
$created[$name]->method('id')->willReturn(\random_int(1, 10000));
$created[$name]->method('label')->willReturn($name);
$created[$name]->method('toLink')->willReturn($link);
// Use a method instead of a dynamic property.
$created[$name]->method('getParentTerm')->willReturn(NULL);
$term = new CustomTerm(\random_int(1, 10000), $name, $link);
$created[$name] = $term;
}
$terms[] = $created[$name];
}
// Assign parents using a method.
// Assign parents using the new `parent` property.
$reverse = \array_reverse($lineage);
foreach ($reverse as $name) {
$parent_item = $this->createMock(EntityReferenceFieldItemListInterface::class);
$parent_item->target_id = ($parent = \next($reverse)) ? $created[$parent]->id() : NULL;
$created[$name]->method('getParentTerm')->willReturn($parent_item);
$parent_item->target_id = ($parent = \next($reverse)) ? $created[$parent]->id : NULL;
$created[$name]->parent = $parent_item;
}
return $terms;
......@@ -306,3 +300,44 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
}
}
/**
*
*/
class CustomTerm {
public $id;
public $label;
public $link;
public $parent;
/**
*
*/
public function __construct($id, $label, $link) {
$this->id = $id;
$this->label = $label;
$this->link = $link;
$this->parent = NULL;
}
/**
*
*/
public function getId() {
return $this->id;
}
/**
*
*/
public function getLabel() {
return $this->label;
}
/**
*
*/
public function toLink() {
return $this->link;
}
}
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