public function CounterTest::testSetWriteCallback in Purge 8.3
@covers ::setWriteCallback
@dataProvider providerTestSetWriteCallback()
File
- tests/
src/ Unit/ Counter/ CounterTest.php, line 289
Class
- CounterTest
- @coversDefaultClass \Drupal\purge\Counter\Counter
Namespace
Drupal\Tests\purge\Unit\CounterCode
public function testSetWriteCallback($value_start, $call, $value_end) : void {
$counter = new Counter($value_start);
// Pass a callback that modifies the local $passed_value.
$passed_value = NULL;
$callback = function ($_value) use (&$passed_value) {
$passed_value = $_value;
};
$counter
->setWriteCallback($callback);
// Call the requested callback and verify that the results match.
$method = array_shift($call);
call_user_func_array([
$counter,
$method,
], $call);
$this
->assertEquals($passed_value, $value_end);
}