Skip to content
Snippets Groups Projects
Commit 5e1163c5 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 176a34a6
No related branches found
No related tags found
No related merge requests found
Pipeline #333474 canceled
......@@ -12,8 +12,7 @@ use Drupal\cshs\Plugin\Field\FieldFormatter\CshsGroupByRootFormatter;
use Drupal\taxonomy\TermInterface;
use Drupal\taxonomy\TermStorageInterface;
use Drupal\Tests\UnitTestCase;
use IteratorAggregate;
use ArrayIterator;
/**
* Tests the `cshs_group_by_root` field formatter.
......@@ -304,10 +303,15 @@ class CshsGroupByRootFormatterUnitTest extends UnitTestCase {
}
}
namespace Drupal\Tests\cshs\Unit;
\ArrayIterator\IteratorAggregate\Traversableuse Drupal\taxonomy\TermInterface;
use Drupal\Core\Link;
/**
*
*/
class MockTerm implements TermInterface, IteratorAggregate {
class MockTerm implements TermInterface, \IteratorAggregate {
public $parent;
private $id;
private $label;
......@@ -320,7 +324,6 @@ class MockTerm implements TermInterface, IteratorAggregate {
$this->id = $id;
$this->label = $label;
$this->link = $link;
// Explicitly define the parent property.
$this->parent = NULL;
}
......@@ -418,10 +421,132 @@ class MockTerm implements TermInterface, IteratorAggregate {
public function setVocabularyId($vid) {}
/**
* Implement the IteratorAggregate interface.
*
*/
public function getWeight() {
return 0;
}
/**
*
*/
public function setWeight($weight) {}
/**
*
*/
public function getFieldDefinitions() {
return [];
}
/**
*
*/
public function hasField($field_name) {
return FALSE;
}
/**
*
*/
public function get($field_name) {}
/**
*
*/
public function set($field_name, $value, $notify = TRUE) {}
/**
*
*/
public function getIterator(): \Traversable {
return new \ArrayIterator([]);
}
/**
*
*/
public function bundle() {
return 'taxonomy_term';
}
/**
*
*/
public function getEntityTypeId() {
return 'taxonomy_term';
}
/**
*
*/
public function uuid() {
return 'mock-uuid';
}
/**
*
*/
public function save() {}
/**
*
*/
public function delete() {}
/**
*
*/
public function getIterator() {
return new ArrayIterator([]);
public function isNew() {
return FALSE;
}
/**
*
*/
public function enforceIsNew($value = TRUE) {}
/**
* Implementing the translation-related methods.
*/
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) {}
}
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