public function SimpleGMapFormatterTest::testFormatterOutput in Simple Google Maps 8
Same name and namespace in other branches
- 3.0.x tests/src/Kernel/SimpleGMapFormatterTest.php \Drupal\Tests\simple_gmap\Kernel\SimpleGMapFormatterTest::testFormatterOutput()
Inspect the formatter output.
Troublesome senarious :- A complex character set. A XSS attack.
File
- tests/
src/ Kernel/ SimpleGMapFormatterTest.php, line 57
Class
- SimpleGMapFormatterTest
- Tests the text formatters functionality.
Namespace
Drupal\Tests\simple_gmap\KernelCode
public function testFormatterOutput() {
$viewBuilder = \Drupal::entityTypeManager()
->getViewBuilder('node');
$renderer = \Drupal::service('renderer');
$values = [
'field_map2' => 'Place de l'Université-du-Québec, boulevard Charest Est, Québec, QC G1K',
'field_xss' => '<script>alert("hello");</script> Empire State Building',
];
foreach ($values as $field => $raw_text) {
$view = $this->node
->get($field)
->view();
$renderer
->renderRoot($view[0]);
$expected_markup = Markup::create($raw_text);
$this
->assertEquals($view[0]['#children'], $expected_markup);
}
}