Skip to content
Snippets Groups Projects
Commit ca9744d0 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 86f0a39f
No related branches found
No related tags found
No related merge requests found
Pipeline #332629 failed
......@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\Tests\cshs\Unit;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\EntityReferenceFieldItemListInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Link;
......@@ -111,71 +112,320 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
*/
protected function createMockTerm(int $id, string $label, Link $link, $parent = NULL): TermInterface {
return new class($id, $label, $link, $parent) implements TermInterface, \IteratorAggregate {
private $id;
private $label;
private $link;
public $parent;
public function __construct($id, $label, $link, $parent) {
$this->id = $id;
$this->label = $label;
$this->link = $link;
$this->parent = $parent;
}
private $id;
private $label;
private $link;
public $parent;
/**
*
*/
public function __construct($id, $label, $link, $parent) {
$this->id = $id;
$this->label = $label;
$this->link = $link;
$this->parent = $parent;
}
// Required methods from TermInterface
public function id() {
return $this->id;
}
/**
* Required methods from TermInterface and EntityInterface.
*/
public function id() {
return $this->id;
}
public function label() {
return $this->label;
}
/**
*
*/
public function label() {
return $this->label;
}
public function toLink($text = NULL, $rel = 'canonical', array $options = []) {
return $this->link;
}
/**
*
*/
public function toLink($text = NULL, $rel = 'canonical', array $options = []) {
return $this->link;
}
public function getName() { return $this->label; }
public function setName($name) { $this->label = $name; }
public function getWeight() { return 0; }
public function setWeight($weight) {}
/**
*
*/
public function getVocabularyId() {
return 'default';
}
// Implement the getIterator() method for IteratorAggregate.
public function getIterator() {
return new \ArrayIterator([]);
}
/**
*
*/
public function setVocabularyId($vid) {}
/**
*
*/
public function getDescription() {}
/**
*
*/
public function setDescription($description) {}
/**
*
*/
public function getFormat() {}
/**
*
*/
public function setFormat($format) {}
/**
*
*/
public function getName() {
return $this->label;
}
/**
*
*/
public function setName($name) {
$this->label = $name;
}
/**
*
*/
public function getWeight() {
return 0;
}
/**
*
*/
public function setWeight($weight) {}
/**
*
*/
public function getParentIds() {
return [];
}
/**
*
*/
public function setParentIds(array $parent_ids) {}
/**
*
*/
public function getParents() {
return [];
}
/**
*
*/
public function getChildren() {
return [];
}
/**
* Implement the getIterator() method for IteratorAggregate.
*/
public function getIterator() {
return new \ArrayIterator([]);
}
/**
* Methods required by EntityPublishedInterface.
*/
public function isPublished() {
return TRUE;
}
/**
*
*/
public function setPublished() {}
/**
* Methods required by EntityInterface.
*/
public function bundle() {}
/**
*
*/
public function getEntityTypeId() {
return 'taxonomy_term';
}
/**
*
*/
public function uuid() {
return 'mock-uuid';
}
/**
*
*/
public function save() {}
/**
*
*/
public function delete() {}
/**
*
*/
public function isNew() {
return FALSE;
}
/**
*
*/
public function enforceIsNew($value = TRUE) {}
/**
*
*/
public function labelCallback() {}
/**
*
*/
public function toUrl($rel = 'canonical', array $options = []) {}
/**
*
*/
public function createDuplicate() {}
/**
*
*/
public function getCacheTagsToInvalidate() {
return [];
}
/**
*
*/
public function hasLinkTemplate($key) {
return FALSE;
}
/**
*
*/
public function toLinkTemplate($key, $text = NULL, array $options = []) {
return $this->link;
}
/**
* Methods required by FieldableEntityInterface.
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {}
/**
*
*/
public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle) {}
/**
*
*/
public function hasField($field_name) {
return FALSE;
}
/**
*
*/
public function get($field_name) {}
/**
*
*/
public function set($field_name, $value) {}
/**
*
*/
public function getFields() {
return [];
}
/**
*
*/
public function getFieldDefinitions() {
return [];
}
/**
*
*/
public function getFieldName($field_name) {
return $field_name;
}
/**
*
*/
public function getTranslation($langcode) {
return $this;
}
/**
*
*/
public function hasTranslation($langcode) {
return FALSE;
}
/**
*
*/
public function getTranslationLanguages($include_default = TRUE) {
return [];
}
/**
*
*/
public function addTranslation($langcode, array $values = []) {}
/**
*
*/
public function removeTranslation($langcode) {}
/**
*
*/
public function isDefaultTranslation() {
return TRUE;
}
/**
*
*/
public function setDefaultTranslation($is_default_translation) {}
/**
* Ensure this class implements Traversable.
*/
public function getIterator() {
return new \ArrayIterator([]);
}
// Methods required by EntityInterface
public function bundle() {}
public function getEntityTypeId() {}
public function uuid() {}
public function save() {}
public function delete() {}
public function isNew() {}
public function enforceIsNew($value = true) {}
public function labelCallback() {}
public function toUrl($rel = 'canonical', array $options = []) {}
public function createDuplicate() {}
public function getCacheTagsToInvalidate() { return []; }
public function hasLinkTemplate($key) { return false; }
public function toLinkTemplate($key, $text = NULL, array $options = []) { return $this->link; }
// Methods required by EntityPublishedInterface
public function isPublished() { return TRUE; }
public function setPublished() {} // Updated to match Drupal 11's method signature
// Additional methods required by TermInterface
public function getDescription() {}
public function setDescription($description) {}
public function getFormat() {}
public function setFormat($format) {}
public function getVocabularyId() { return 'default'; }
public function setVocabularyId($vid) {}
public function getParentIds() { return []; }
public function setParentIds(array $parent_ids) {}
public function getParents() { return []; }
public function getChildren() { return []; }
};
}
......
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