class TermMergerSpy in Term Merge 8
A term merge test class that keeps a list of called functions.
Hierarchy
- class \Drupal\Tests\term_merge\Kernel\TestDoubles\TermMergerDummy implements TermMergerInterface
- class \Drupal\Tests\term_merge\Kernel\TestDoubles\TermMergerMock
- class \Drupal\Tests\term_merge\Kernel\TestDoubles\TermMergerSpy
- class \Drupal\Tests\term_merge\Kernel\TestDoubles\TermMergerMock
Expanded class hierarchy of TermMergerSpy
1 file declares its use of TermMergerSpy
- MergeTermsConfirmTest.php in tests/
src/ Kernel/ Form/ MergeTermsConfirmTest.php
File
- tests/
src/ Kernel/ TestDoubles/ TermMergerSpy.php, line 10
Namespace
Drupal\Tests\term_merge\Kernel\TestDoublesView source
class TermMergerSpy extends TermMergerMock {
private $functionCalls = [];
/**
* {@inheritdoc}
*/
public function mergeIntoNewTerm(array $termsToMerge, $newTermLabel) {
$this->functionCalls[__FUNCTION__] = [
$termsToMerge,
$newTermLabel,
];
return parent::mergeIntoNewTerm($termsToMerge, $newTermLabel);
}
/**
* {@inheritdoc}
*/
public function mergeIntoTerm(array $termsToMerge, TermInterface $targetTerm) {
$this->functionCalls[__FUNCTION__] = [
$termsToMerge,
$targetTerm,
];
parent::mergeIntoTerm($termsToMerge, $targetTerm);
}
/**
* Checks a function was called on the object.
*/
public function assertFunctionCalled($function) {
if (!isset($this->functionCalls[$function])) {
throw new \Exception("{$function} was not called");
}
}
/**
* Returns an array of called function names.
*
* @return string[]
* An array of called function names.
*/
public function calledFunctions() {
return array_keys($this->functionCalls);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TermMergerSpy:: |
private | property | ||
TermMergerSpy:: |
public | function | Checks a function was called on the object. | |
TermMergerSpy:: |
public | function | Returns an array of called function names. | |
TermMergerSpy:: |
public | function |
Merges two or more terms into a new term. Overrides TermMergerMock:: |
|
TermMergerSpy:: |
public | function |
Merges one or more terms into an existing term. Overrides TermMergerDummy:: |