public function AReportTokenTest::testContextReplacement in Forena Reports 8
Verify that basic Context specific token replacement works.
File
- tests/
src/ Unit/ AReportTokenTest.php, line 37
Class
- AReportTokenTest
- Class AReportTokenTest @group Forena @require module forena @coversDefaultClass \Drupal\forena\Token\ReportReplacer
Namespace
Drupal\Tests\forena\UnitCode
public function testContextReplacement() {
$data = [
'name' => 'Bob',
];
$this
->pushData($data, 'p');
// Replace the data
$text = $this->replacer
->replace('Hello {p.name}');
$this
->assertEquals('Hello Bob', $text);
$this
->popData();
$messages = [
'messages' => [
'deep' => [
'Hello {p.name}',
],
],
];
$this->replacer
->replaceNested($messages);
$this
->assertEquals('Hello Bob', $messages['messages']['deep'][0]);
}