You are here

protected function TemplateControllerTest::getJson in Wysiwyg API template plugin 8.2

Same name and namespace in other branches
  1. 3.0.x tests/src/Kernel/Controller/TemplateControllerTest.php \Drupal\Tests\wysiwyg_template\Kernel\Controller\TemplateControllerTest::getJson()

Helper method to strip template json from js callback return

Parameters

$js: The javascript from the callback.

Return value

mixed The parsed json.

1 call to TemplateControllerTest::getJson()
TemplateControllerTest::testJsCallback in tests/src/Kernel/Controller/TemplateControllerTest.php
Tests the js callback.

File

tests/src/Kernel/Controller/TemplateControllerTest.php, line 141

Class

TemplateControllerTest
Tests the template controller object.

Namespace

Drupal\Tests\wysiwyg_template\Kernel\Controller

Code

protected function getJson($js) {
  preg_match('/{.*}/', $js, $matches);
  if (empty($matches[0])) {
    $this
      ->fail('No json found in ' . $js);
  }
  return json_decode($matches[0], TRUE);
}